1 | <?php |
||
29 | class LocatorChain implements LocatorInterface |
||
30 | { |
||
31 | /** |
||
32 | * Dispatches a failed poll message for locators marked by "isImportant" flag |
||
33 | * |
||
34 | * @var LoggerInterface |
||
35 | */ |
||
36 | private $logger; |
||
37 | |||
38 | /** |
||
39 | * Priority queue with proxy locators |
||
40 | * |
||
41 | * It is not really needed to use data structures from php-ds extension in this context due to low objects count, |
||
42 | * it's mostly for learning purposes... also we have a little bonus - priority managing is delegated to the C-layer |
||
43 | * instead of PHP code, so a compiler pass can be simplified. |
||
44 | * |
||
45 | * @var PriorityQueue<LocatorInterface> |
||
46 | * |
||
47 | * @see https://github.com/php-ds |
||
48 | */ |
||
49 | private $proxyLocators; |
||
50 | |||
51 | /** |
||
52 | * Cached polling result for current process |
||
53 | * (otherwise we should call a `PriorityQueue::copy()` and it can be redundant) |
||
54 | * |
||
55 | * @var string[] |
||
56 | */ |
||
57 | private $_proxyList; |
||
58 | |||
59 | /** |
||
60 | * LocatorChain constructor. |
||
61 | * |
||
62 | * @param LoggerInterface $logger Dispatches a failed poll message for locators marked by "isImportant" flag |
||
63 | */ |
||
64 | public function __construct(LoggerInterface $logger) |
||
71 | |||
72 | /** |
||
73 | * Adds a proxy locator to the list for polling |
||
74 | * |
||
75 | * @param LocatorInterface $proxyLocator Provides a list with proxies available for http requests |
||
76 | * @param int $priority Locator priority in polling loop |
||
77 | * @param bool $isImportant Whenever a critical message should be raised if locator fails to locate a |
||
78 | * proxy list |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | public function addLocator(LocatorInterface $proxyLocator, int $priority, bool $isImportant = false): void |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | * |
||
94 | * @see PriorityQueue::getIterator() |
||
95 | */ |
||
96 | public function locate(): iterable |
||
112 | |||
113 | /** |
||
114 | * Polls locator for a proxy list |
||
115 | * |
||
116 | * @param LocatorInterface $proxyLocator Provides a list with proxies available for http requests |
||
117 | * @param array $parameters Parameters for locator polling |
||
118 | * |
||
119 | * @return string[] |
||
120 | */ |
||
121 | private function poll(LocatorInterface $proxyLocator, array $parameters): array |
||
158 | } |
||
159 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..