|
11 | 11 |
|
12 | 12 | namespaceSymfony\Component\DependencyInjection; |
13 | 13 |
|
| 14 | +useComposer\Autoload\ClassLoader; |
14 | 15 | useComposer\InstalledVersions; |
15 | 16 | useSymfony\Component\Config\Resource\ClassExistenceResource; |
16 | 17 | useSymfony\Component\Config\Resource\ComposerResource; |
|
46 | 47 | useSymfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag; |
47 | 48 | useSymfony\Component\DependencyInjection\ParameterBag\ParameterBag; |
48 | 49 | useSymfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
| 50 | +useSymfony\Component\ErrorHandler\DebugClassLoader; |
49 | 51 | useSymfony\Component\ExpressionLanguage\Expression; |
50 | 52 | useSymfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; |
51 | 53 |
|
@@ -262,6 +264,53 @@ public function addResource(ResourceInterface $resource): static |
262 | 264 | if ($resourceinstanceof GlobResource &&$this->inVendors($resource->getPrefix())) { |
263 | 265 | return$this; |
264 | 266 | } |
| 267 | +if ($resourceinstanceof FileExistenceResource &&$this->inVendors($resource->getResource())) { |
| 268 | +return$this; |
| 269 | + } |
| 270 | +if ($resourceinstanceof FileResource &&$this->inVendors($resource->getResource())) { |
| 271 | +return$this; |
| 272 | + } |
| 273 | +if ($resourceinstanceof DirectoryResource &&$this->inVendors($resource->getResource())) { |
| 274 | +return$this; |
| 275 | + } |
| 276 | +if ($resourceinstanceof ClassExistenceResource) { |
| 277 | +$class =$resource->getResource(); |
| 278 | + |
| 279 | +$inVendor =false; |
| 280 | +foreach (spl_autoload_functions()as$autoloader) { |
| 281 | +if (!\is_array($autoloader)) { |
| 282 | +continue; |
| 283 | + } |
| 284 | + |
| 285 | +if ($autoloader[0]instanceof DebugClassLoader) { |
| 286 | +$autoloader =$autoloader[0]->getClassLoader(); |
| 287 | + } |
| 288 | + |
| 289 | +if (!\is_array($autoloader) || !$autoloader[0]instanceof ClassLoader || !$autoloader[0]->findFile(__CLASS__)) { |
| 290 | +continue; |
| 291 | + } |
| 292 | + |
| 293 | +foreach ($autoloader[0]->getPrefixesPsr4()as$prefix =>$dirs) { |
| 294 | +if ('' ===$prefix || !str_starts_with($class,$prefix)) { |
| 295 | +continue; |
| 296 | + } |
| 297 | + |
| 298 | +foreach ($dirsas$dir) { |
| 299 | +if (!$dir =realpath($dir)) { |
| 300 | +continue; |
| 301 | + } |
| 302 | + |
| 303 | +if (!$inVendor =$this->inVendors($dir)) { |
| 304 | +break3; |
| 305 | + } |
| 306 | + } |
| 307 | + } |
| 308 | + } |
| 309 | + |
| 310 | +if ($inVendor) { |
| 311 | +return$this; |
| 312 | + } |
| 313 | + } |
265 | 314 |
|
266 | 315 | $this->resources[(string)$resource] =$resource; |
267 | 316 |
|
@@ -1694,7 +1743,9 @@ private function inVendors(string $path): bool |
1694 | 1743 |
|
1695 | 1744 | foreach ($this->vendorsas$vendor) { |
1696 | 1745 | if (str_starts_with($path,$vendor) &&false !==strpbrk(substr($path,\strlen($vendor),1),'/'.\DIRECTORY_SEPARATOR)) { |
| 1746 | +$this->pathsInVendor[$vendor.'/composer'] =false; |
1697 | 1747 | $this->addResource(newFileResource($vendor.'/composer/installed.json')); |
| 1748 | +$this->pathsInVendor[$vendor.'/composer'] =true; |
1698 | 1749 |
|
1699 | 1750 | return$this->pathsInVendor[$path] =true; |
1700 | 1751 | } |
|