1 | <?php |
||
17 | abstract class ClassDiscovery |
||
18 | { |
||
19 | /** |
||
20 | * A list of strategies to find classes. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | private static $strategies = [ |
||
25 | Strategy\PuliBetaStrategy::class, |
||
26 | Strategy\CommonClassesStrategy::class, |
||
27 | ]; |
||
28 | |||
29 | /** |
||
30 | * Discovery cache to make the second time we use discovery faster. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | private static $cache = []; |
||
35 | |||
36 | /** |
||
37 | * Finds a class. |
||
38 | * |
||
39 | * @param string $type |
||
40 | * |
||
41 | * @return string|\Closure |
||
42 | * |
||
43 | * @throws DiscoveryFailedException |
||
44 | */ |
||
45 | 15 | protected static function findOneByType($type) |
|
80 | |||
81 | /** |
||
82 | * Get a value from cache. |
||
83 | * |
||
84 | * @param string $type |
||
85 | * |
||
86 | * @return string|null |
||
87 | */ |
||
88 | 15 | private static function getFromCache($type) |
|
103 | |||
104 | /** |
||
105 | * Store a value in cache. |
||
106 | * |
||
107 | * @param string $type |
||
108 | * @param string $class |
||
109 | */ |
||
110 | 9 | private static function storeInCache($type, $class) |
|
114 | |||
115 | /** |
||
116 | * Set new strategies and clear the cache. |
||
117 | * |
||
118 | * @param array $strategies string array of fully qualified class name to a DiscoveryStrategy |
||
119 | */ |
||
120 | 27 | public static function setStrategies(array $strategies) |
|
125 | |||
126 | /** |
||
127 | * Append a strategy at the end of the strategy queue. |
||
128 | * |
||
129 | * @param string $strategy Fully qualified class name to a DiscoveryStrategy |
||
130 | */ |
||
131 | 1 | public static function appendStrategy($strategy) |
|
136 | |||
137 | /** |
||
138 | * Prepend a strategy at the beginning of the strategy queue. |
||
139 | * |
||
140 | * @param string $strategy Fully qualified class name to a DiscoveryStrategy |
||
141 | */ |
||
142 | 1 | public static function prependStrategy($strategy) |
|
147 | |||
148 | /** |
||
149 | * Clear the cache. |
||
150 | */ |
||
151 | 27 | public static function clearCache() |
|
155 | |||
156 | /** |
||
157 | * Evaluates conditions to boolean. |
||
158 | * |
||
159 | * @param mixed $condition |
||
160 | * |
||
161 | * @return bool |
||
162 | */ |
||
163 | 7 | protected static function evaluateCondition($condition) |
|
188 | |||
189 | /** |
||
190 | * Get an instance of the $class. |
||
191 | * |
||
192 | * @param string|\Closure $class A FQCN of a class or a closure that instantiate the class. |
||
193 | * |
||
194 | * @return object |
||
195 | * |
||
196 | * @throws ClassInstantiationFailedException |
||
197 | */ |
||
198 | 5 | protected static function instantiateClass($class) |
|
214 | |||
215 | /** |
||
216 | * We want to do a "safe" version of PHP's "class_exists" because Magento has a bug |
||
217 | * (or they call it a "feature"). Magento is throwing an exception if you do class_exists() |
||
218 | * on a class that ends with "Factory" and if that file does not exits. |
||
219 | * |
||
220 | * This function will catch all potential exceptions and make sure it returns a boolean. |
||
221 | * |
||
222 | * @param string $class |
||
223 | * @param bool $autoload |
||
|
|||
224 | * |
||
225 | * @return bool |
||
226 | */ |
||
227 | public static function safeClassExists($class) |
||
235 | } |
||
236 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.