Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Routing] Fixes fatal errors with object resources in AnnotationDirectoryLoader::supports #11232

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -66,12 +66,16 @@ public function load($path, $type = null)
*/
public function supports($resource, $type = null)
{
if (!is_string($resource)) {
return false;
}

try {
$path = $this->locator->locate($resource);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileLocatorInterface allows mixed https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/FileLocatorInterface.php#L22 . But the actual implementation https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/FileLocator.php#L44 doesn't actually work with any parameter. So this issue is there and not really in this class here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well so the question is if FileLocator(Interface) shouldn't allow mixed in which case this change is relevant or if it should and appropriate string conversion and or exceptions would've to be implemented there.
In both cases moving is_string upfront removes some overhead or it could be removed of course.

} catch (\Exception $e) {
return false;
}

return is_string($resource) && is_dir($path) && (!$type || 'annotation' === $type);
return is_dir($path) && (!$type || 'annotation' === $type);
}
}