Conditions | 6 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
309 | public static function validateColour(Terminal $terminal, $colour, string $fallback = null) |
||
310 | { |
||
311 | if (is_int($colour)) { |
||
312 | if ($colour < 0 || $colour > 255) { |
||
313 | throw new \InvalidArgumentException("Invalid colour code"); |
||
314 | } |
||
315 | if ($terminal->getColourSupport() < 256) { |
||
316 | if ($fallback !== null) { |
||
317 | Assertion::inArray($fallback, static::getDefaultColoursNames()); |
||
318 | return $fallback; |
||
319 | } |
||
320 | return static::map256To8($colour); |
||
321 | } |
||
322 | } else { |
||
323 | Assertion::inArray($colour, static::getDefaultColoursNames()); |
||
324 | } |
||
325 | return $colour; |
||
326 | } |
||
327 | } |
||
328 |
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: