Skip to content

Commit a738b15

Browse files
committed
[Routing] AnnotationDirectoryLoader::load() may return null
Closes #45259
1 parent b1debdf commit a738b15

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Loader/AnnotationDirectoryLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
2525
/**
2626
* @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed
2727
*/
28-
public function load(mixed $path, string $type = null): RouteCollection
28+
public function load(mixed $path, string $type = null): ?RouteCollection
2929
{
3030
if (!is_dir($dir = $this->locator->locate($path))) {
3131
return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection();

Tests/Loader/AnnotationDirectoryLoaderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public function testLoadFileIfLocatedResourceIsFile()
9999
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
100100
}
101101

102+
public function testLoadAbstractClass()
103+
{
104+
$this->reader->expects($this->never())->method('getClassAnnotation');
105+
$this->reader->expects($this->never())->method('getMethodAnnotations');
106+
107+
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/AbstractClass.php');
108+
}
109+
102110
private function expectAnnotationsToBeReadFrom(array $classes)
103111
{
104112
$this->reader->expects($this->exactly(\count($classes)))

0 commit comments

Comments
 (0)