1 | <?php |
||
20 | class Collection extends ArrayCollection |
||
21 | { |
||
22 | /** |
||
23 | * @var array|string[] |
||
24 | */ |
||
25 | private static $proxies; |
||
26 | /** |
||
27 | * @var BaseCollection |
||
28 | */ |
||
29 | private $inner; |
||
30 | |||
31 | /** |
||
32 | * Collection constructor. |
||
33 | * @param array|iterable $elements |
||
34 | */ |
||
35 | public function __construct($elements = []) |
||
43 | |||
44 | /** |
||
45 | * @return void |
||
46 | */ |
||
47 | private function exportProxies(): void |
||
57 | |||
58 | /** |
||
59 | * @param string $name |
||
60 | * @param array $arguments |
||
61 | * @return mixed |
||
62 | * @throws \BadMethodCallException |
||
63 | */ |
||
64 | public static function __callStatic(string $name, array $arguments = []) |
||
79 | |||
80 | /** |
||
81 | * Wrap the given value in a collection if applicable. |
||
82 | * |
||
83 | * @param mixed $value |
||
84 | * @return static |
||
85 | */ |
||
86 | public static function wrap($value): self |
||
99 | |||
100 | /** |
||
101 | * @param string $name |
||
102 | * @param array $arguments |
||
103 | * @return mixed |
||
104 | * @throws \BadMethodCallException |
||
105 | */ |
||
106 | public function __call(string $name, array $arguments = []) |
||
115 | |||
116 | /** |
||
117 | * @param string $key |
||
118 | * @return HigherOrderCollectionProxy |
||
119 | * @throws \InvalidArgumentException |
||
120 | */ |
||
121 | public function __get(string $key): HigherOrderCollectionProxy |
||
130 | } |
||
131 |
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: