| @@ 174-205 (lines=32) @@ | ||
| 171 | return $finders; |
|
| 172 | } |
|
| 173 | ||
| 174 | private static function retrievePatchers(array $config): array |
|
| 175 | { |
|
| 176 | if (false === array_key_exists(self::PATCHERS_KEYWORD, $config)) { |
|
| 177 | return []; |
|
| 178 | } |
|
| 179 | ||
| 180 | $patchers = $config[self::PATCHERS_KEYWORD]; |
|
| 181 | ||
| 182 | if (false === is_array($patchers)) { |
|
| 183 | throw new InvalidArgumentException( |
|
| 184 | sprintf( |
|
| 185 | 'Expected patchers to be an array of callables, found "%s" instead.', |
|
| 186 | gettype($patchers) |
|
| 187 | ) |
|
| 188 | ); |
|
| 189 | } |
|
| 190 | ||
| 191 | foreach ($patchers as $index => $patcher) { |
|
| 192 | if (is_callable($patcher)) { |
|
| 193 | continue; |
|
| 194 | } |
|
| 195 | ||
| 196 | throw new InvalidArgumentException( |
|
| 197 | sprintf( |
|
| 198 | 'Expected patchers to be an array of callables, the "%d" element is not.', |
|
| 199 | $index |
|
| 200 | ) |
|
| 201 | ); |
|
| 202 | } |
|
| 203 | ||
| 204 | return $patchers; |
|
| 205 | } |
|
| 206 | ||
| 207 | private static function retrieveGlobalNamespaceWhitelisters(array $config): array |
|
| 208 | { |
|
| @@ 207-239 (lines=33) @@ | ||
| 204 | return $patchers; |
|
| 205 | } |
|
| 206 | ||
| 207 | private static function retrieveGlobalNamespaceWhitelisters(array $config): array |
|
| 208 | { |
|
| 209 | if (false === array_key_exists(self::GLOBAL_NAMESPACE_KEYWORD, $config)) { |
|
| 210 | return []; |
|
| 211 | } |
|
| 212 | ||
| 213 | $globalNamespace = $config[self::GLOBAL_NAMESPACE_KEYWORD]; |
|
| 214 | ||
| 215 | if (false === is_array($globalNamespace)) { |
|
| 216 | throw new InvalidArgumentException( |
|
| 217 | sprintf( |
|
| 218 | 'Expected "global_namespace" to be an array, found "%s" instead.', |
|
| 219 | gettype($globalNamespace) |
|
| 220 | ) |
|
| 221 | ); |
|
| 222 | } |
|
| 223 | ||
| 224 | foreach ($globalNamespace as $index => $className) { |
|
| 225 | if (is_string($className) || is_callable($className)) { |
|
| 226 | continue; |
|
| 227 | } |
|
| 228 | ||
| 229 | throw new InvalidArgumentException( |
|
| 230 | sprintf( |
|
| 231 | 'Expected "global_namespace" to be an array of callables or strings, the "%d" element ' |
|
| 232 | .'is not.', |
|
| 233 | $index |
|
| 234 | ) |
|
| 235 | ); |
|
| 236 | } |
|
| 237 | ||
| 238 | return $globalNamespace; |
|
| 239 | } |
|
| 240 | } |
|
| 241 | ||