1 | <?php |
||
8 | class TypeHint |
||
9 | { |
||
10 | /** |
||
11 | * 标准化类型 |
||
12 | * 1. 基本类型, 转换成规范的拼写, 如double -> float, integer -> int |
||
13 | * 2. 对象类型, 补全namespace |
||
14 | * @param string $type 需要标准化的字符串 |
||
15 | * @param string $contextClass 当前上下文所在的类,一般传__CLASS__, 用于扫描当前文件的use信息, 以便拼上namespace |
||
16 | */ |
||
17 | 21 | static function normalize($type, $contextClass=null){ |
|
29 | /** |
||
30 | * 是否是基本类型 |
||
31 | * @param string $type |
||
32 | */ |
||
33 | 14 | static function isScalarType($type){ |
|
41 | |||
42 | /** |
||
43 | * @param $type |
||
44 | * @return bool |
||
45 | */ |
||
46 | 10 | static function isArray($type){ |
|
49 | |||
50 | /** |
||
51 | * 获取数组的类型 |
||
52 | * @param $type |
||
53 | * @return string|null |
||
54 | */ |
||
55 | 6 | static function getArrayType($type){ |
|
63 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.