Skip to content

Commit

Permalink
[Routing] AnnotationDirectoryLoader::load() may return null
Browse files Browse the repository at this point in the history
Closes #45259
  • Loading branch information
mhujer committed Jan 31, 2022
1 parent b1debdf commit a738b15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Loader/AnnotationDirectoryLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
/**
* @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed
*/
public function load(mixed $path, string $type = null): RouteCollection
public function load(mixed $path, string $type = null): ?RouteCollection
{
if (!is_dir($dir = $this->locator->locate($path))) {
return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection();
Expand Down
8 changes: 8 additions & 0 deletions Tests/Loader/AnnotationDirectoryLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ public function testLoadFileIfLocatedResourceIsFile()
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
}

public function testLoadAbstractClass()
{
$this->reader->expects($this->never())->method('getClassAnnotation');
$this->reader->expects($this->never())->method('getMethodAnnotations');

$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/AbstractClass.php');
}

private function expectAnnotationsToBeReadFrom(array $classes)
{
$this->reader->expects($this->exactly(\count($classes)))
Expand Down

0 comments on commit a738b15

Please sign in to comment.