Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] Fix optimizing ClassExistenceResource#61615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -273,46 +273,58 @@ public function addResource(ResourceInterface $resource): static | ||
| if ($resource instanceof DirectoryResource && $this->inVendors($resource->getResource())) { | ||
| return $this; | ||
| } | ||
| if (!$resource instanceof ClassExistenceResource) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. should we extract the check of ClassExistenceResource being in vendors into a private method instead of this early check of any other type ? It might reduce the risk of mistakes when wanting to optimize other Resource implementations in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. let's see in the future :) | ||
| $this->resources[(string) $resource]= $resource; | ||
| return $this; | ||
| } | ||
| $class = $resource->getResource(); | ||
| if (!(new ClassExistenceResource($class, false))->isFresh(1)) { | ||
| if (!$this->inVendors((new \ReflectionClass($class))->getFileName())) { | ||
| $this->resources[$class] = $resource; | ||
| } | ||
| return $this; | ||
| } | ||
| $inVendor = true; | ||
| foreach (spl_autoload_functions() as $autoloader) { | ||
| if (!\is_array($autoloader)) { | ||
| $inVendor = false; | ||
| break; | ||
| } | ||
| if ($autoloader[0] instanceof DebugClassLoader) { | ||
| $autoloader = $autoloader[0]->getClassLoader(); | ||
| } | ||
| if (!\is_array($autoloader) || !$autoloader[0] instanceof ClassLoader) { | ||
| $inVendor = false; | ||
| break; | ||
| } | ||
| foreach ($autoloader[0]->getPrefixesPsr4() as $prefix => $dirs) { | ||
| if (!str_starts_with($class, $prefix)) { | ||
| continue; | ||
| } | ||
| foreach ($dirs as $dir) { | ||
| if (!$dir = realpath($dir)) { | ||
| continue; | ||
| } | ||
| if (!$inVendor = $this->inVendors($dir)) { | ||
| break 3; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| if (!$inVendor) { | ||
| $this->resources[$class] = $resource; | ||
| } | ||
| return $this; | ||
| } | ||
Uh oh!
There was an error while loading.Please reload this page.