Skip to content

Commit a0a97d7

Browse files
committed
bug symfony#11232 [Routing] Fixes fatal errors with object resources in AnnotationDirectoryLoader::supports (Tischoi)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes symfony#11232). Discussion ---------- [Routing] Fixes fatal errors with object resources in AnnotationDirectoryLoader::supports | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Fixes fatal errors that occur in the supports method with objects that aren't string convertible / don't implement ArrayAccess. This is mostly a problem because some locators try to access a specific character in the resource name. Since the resource is checked if it's a string either way, it's the most simple solution to just move that check a bit ahead. Commits ------- 5e80585 Update AnnotationDirectoryLoader.php
2 parents ff4b815 + 5e80585 commit a0a97d7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ public function load($path, $type = null)
6666
*/
6767
public function supports($resource, $type = null)
6868
{
69+
if (!is_string($resource)) {
70+
return false;
71+
}
72+
6973
try {
7074
$path = $this->locator->locate($resource);
7175
} catch (\Exception $e) {
7276
return false;
7377
}
7478

75-
return is_string($resource) && is_dir($path) && (!$type || 'annotation' === $type);
79+
return is_dir($path) && (!$type || 'annotation' === $type);
7680
}
7781
}

0 commit comments

Comments
 (0)