1 | <?php |
||
20 | class ConfiguredClientsStrategy implements DiscoveryStrategy, EventSubscriberInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var HttpClient |
||
24 | */ |
||
25 | private static $client; |
||
26 | |||
27 | /** |
||
28 | * @param HttpClient $httpClient |
||
29 | */ |
||
30 | public function __construct(HttpClient $httpClient) |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | public static function getCandidates($type) |
||
46 | |||
47 | /** |
||
48 | * Make sure to use our custom strategy |
||
49 | * @param Event $e |
||
50 | */ |
||
51 | public function onEvent(Event $e) |
||
55 | |||
56 | /** |
||
57 | * Whenever these events occur we make sure to add our strategy to the discovery. |
||
58 | * |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public static function getSubscribedEvents() |
||
68 | } |
||
69 |
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: