1 | <?php |
||
24 | class NumberValueBuilder extends BaseBuilder |
||
25 | { |
||
26 | /** |
||
27 | * @param RuleInterface $rule |
||
28 | * @return bool |
||
29 | */ |
||
30 | public function match(RuleInterface $rule): bool |
||
34 | |||
35 | /** |
||
36 | * @param ContextInterface $ctx |
||
37 | * @param RuleInterface $rule |
||
38 | * @return ValueInterface |
||
39 | */ |
||
40 | public function reduce(ContextInterface $ctx, RuleInterface $rule): ValueInterface |
||
46 | |||
47 | /** |
||
48 | * @param RuleInterface $rule |
||
49 | * @return float|int |
||
50 | */ |
||
51 | private function parse(RuleInterface $rule) |
||
75 | |||
76 | /** |
||
77 | * @param LeafInterface $leaf |
||
78 | * @return bool |
||
79 | */ |
||
80 | private function isHex(LeafInterface $leaf): bool |
||
84 | |||
85 | /** |
||
86 | * @param string $value |
||
87 | * @return int |
||
88 | */ |
||
89 | private function parseHex(string $value): int |
||
93 | |||
94 | /** |
||
95 | * @param LeafInterface $leaf |
||
96 | * @return bool |
||
97 | */ |
||
98 | private function isBinary(LeafInterface $leaf): bool |
||
102 | |||
103 | /** |
||
104 | * @param string $value |
||
105 | * @return int |
||
106 | */ |
||
107 | private function parseBin(string $value): int |
||
111 | |||
112 | /** |
||
113 | * @param LeafInterface $leaf |
||
114 | * @return bool |
||
115 | */ |
||
116 | private function isExponential(LeafInterface $leaf): bool |
||
120 | |||
121 | /** |
||
122 | * @param string $value |
||
123 | * @return float |
||
124 | */ |
||
125 | private function parseExponential(string $value): float |
||
129 | |||
130 | /** |
||
131 | * @param LeafInterface $leaf |
||
132 | * @return bool |
||
133 | */ |
||
134 | private function isFloat(LeafInterface $leaf): bool |
||
138 | |||
139 | /** |
||
140 | * @param string $value |
||
141 | * @return float |
||
142 | */ |
||
143 | private function parseFloat(string $value): float |
||
147 | |||
148 | /** |
||
149 | * @param LeafInterface $leaf |
||
150 | * @return bool |
||
151 | */ |
||
152 | private function isInt(LeafInterface $leaf): bool |
||
156 | |||
157 | /** |
||
158 | * @param string $value |
||
159 | * @return int |
||
160 | */ |
||
161 | private function parseInt(string $value): int |
||
165 | } |
||
166 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.