| Conditions | 2 |
| Paths | 2 |
| Total Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function make(string $driver): Grammars\SQL |
||
| 15 | { |
||
| 16 | if (!array_key_exists($driver, static::$availableOptions)) { |
||
|
|
|||
| 17 | throw new RuntimeException(sprintf('Unkown driver "%s".', $driver)); |
||
| 18 | } |
||
| 19 | |||
| 20 | $grammar = static::$availableOptions[$driver]; |
||
| 21 | |||
| 22 | return new $grammar; |
||
| 23 | } |
||
| 24 | } |
||
| 25 |
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
SomeClassto useselfinstead: