1 | <?php |
||
51 | class GetPrintableType |
||
52 | { |
||
53 | /** |
||
54 | * use this flag for minimum output |
||
55 | * @var int |
||
56 | */ |
||
57 | const FLAG_NONE = 0; |
||
58 | |||
59 | /** |
||
60 | * use this flag to see classnames in the return value |
||
61 | * @var int |
||
62 | */ |
||
63 | const FLAG_CLASSNAME = 1; |
||
64 | |||
65 | /** |
||
66 | * use this flag to see what kind of callable `$item` is |
||
67 | * @var int |
||
68 | */ |
||
69 | const FLAG_CALLABLE_DETAILS = 2; |
||
70 | |||
71 | /** |
||
72 | * use this flag to see the value of `$item` |
||
73 | * @var int |
||
74 | */ |
||
75 | const FLAG_SCALAR_VALUE = 4; |
||
76 | |||
77 | /** |
||
78 | * current maximum possible value for `$flags` |
||
79 | * @var int |
||
80 | */ |
||
81 | const FLAG_MAX_VALUE = 7; |
||
82 | |||
83 | /** |
||
84 | * default value for `$flags` if you don't provide one |
||
85 | * @var int |
||
86 | */ |
||
87 | const FLAG_DEFAULTS = 7; |
||
88 | |||
89 | /** |
||
90 | * what PHP type is $item? |
||
91 | * |
||
92 | * @param mixed $item |
||
93 | * the data to examine |
||
94 | * @param int $flags |
||
95 | * options to change what we put in the return value |
||
96 | * @return string |
||
97 | * the data type of $item |
||
98 | */ |
||
99 | public function getPrintableType($item, $flags = self::FLAG_DEFAULTS) |
||
103 | |||
104 | /** |
||
105 | * what PHP type is $item? |
||
106 | * |
||
107 | * @param mixed $item |
||
108 | * the data to examine |
||
109 | * @param int $flags |
||
110 | * options to change what we put in the return value |
||
111 | * @return string |
||
112 | * the data type of $item |
||
113 | */ |
||
114 | public static function of($item, $flags = self::FLAG_DEFAULTS) |
||
138 | |||
139 | /** |
||
140 | * extract the details about a PHP callable array |
||
141 | * |
||
142 | * @param array|string $item |
||
143 | * the callable() to examine |
||
144 | * @param int $flags |
||
145 | * options to change what we put in the return value |
||
146 | * @return string |
||
147 | * the data type of $item |
||
148 | */ |
||
149 | private static function returnCallableType($item, $flags) |
||
169 | |||
170 | /** |
||
171 | * turn a PHP object into the underlying PHP data type |
||
172 | * |
||
173 | * @param object $item |
||
174 | * the data to inspect |
||
175 | * @param int $flags |
||
176 | * options to change what we put in the return value |
||
177 | * @return string |
||
178 | * the data type of $item |
||
179 | */ |
||
180 | private static function returnObjectType($item, $flags) |
||
195 | |||
196 | /** |
||
197 | * extract the details about a PHP scalar value |
||
198 | * |
||
199 | * @param bool|float|int|string $item |
||
200 | * the data to examine |
||
201 | * @param int $flags |
||
202 | * options to change what we put in the return value |
||
203 | * @return string |
||
204 | * the data type of $item |
||
205 | */ |
||
206 | private static function returnScalarType($item, $flags) |
||
227 | } |
||
228 |