Skip to content

Commit

Permalink
classes that generate an error should not be part of the class map at…
Browse files Browse the repository at this point in the history
… all
  • Loading branch information
frederikbosch committed Sep 17, 2024
1 parent f43da38 commit 4f431fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/ClassScanner/ComposerMapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ private function convertToClassMap(ClassMap $classMap, array $composerMap): Clas

try {
$attributes = [...$this->reflector->yieldAttributes($class)];
$classMap->addClass(new ClassSpecification($class, $path, $attributes));
} catch (\Error) {
$attributes = [];
}

$classMap->addClass(new ClassSpecification($class, $path, $attributes));
}

return $classMap;
Expand Down
4 changes: 4 additions & 0 deletions tests/ClassScanner/ComposerMapGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Aura\Di\ClassScanner;

use Aura\Di\Fake\FakeAllAttributes;
use Aura\Di\Fake\FakeClassExtendsNonExistent;
use PHPUnit\Framework\TestCase;

class ComposerMapGeneratorTest extends TestCase
Expand Down Expand Up @@ -37,6 +39,8 @@ public function testAddingClass()
$newClassName = 'CacheTest\\NewFile' . $classSuffix;

$classMap = $generator->generate();
$this->assertTrue($classMap->hasClass(FakeAllAttributes::class));
$this->assertFalse($classMap->hasClass(FakeClassExtendsNonExistent::class));
$this->assertNotContains($newClassName, $classMap->getClasses());

$newFile = $this->createRandomClassFile($newClassName);
Expand Down
6 changes: 6 additions & 0 deletions tests/Fake/FakeClassExtendsNonExistent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
namespace Aura\Di\Fake;

class FakeClassExtendsNonExistent extends NonExistent
{
}

0 comments on commit 4f431fe

Please sign in to comment.