Conditions | 6 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
303 | public static function validateColour(Terminal $terminal, $colour, string $fallback = null) |
||
304 | { |
||
305 | if (is_int($colour)) { |
||
306 | if ($colour < 0 || $colour > 255) { |
||
307 | throw new \InvalidArgumentException("Invalid colour code"); |
||
308 | } |
||
309 | if ($terminal->getColourSupport() < 256) { |
||
310 | if ($fallback !== null) { |
||
311 | Assertion::inArray($fallback, static::getDefaultColoursNames()); |
||
312 | return $fallback; |
||
313 | } |
||
314 | return static::map256To8($colour); |
||
315 | } |
||
316 | } |
||
317 | Assertion::inArray($colour, static::getDefaultColoursNames()); |
||
318 | return $colour; |
||
319 | } |
||
320 | } |
||
321 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: