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