From 0672ddb611cbb6a6d753aa6389b3b7781b01fd81 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Sun, 14 Oct 2018 10:16:12 +0200 Subject: [PATCH] Fixed a bug where classes without a Handler annotation where also mapped --- src/Mapper.php | 2 +- tests/MapperTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mapper.php b/src/Mapper.php index 48c1bb3..7b92f2f 100644 --- a/src/Mapper.php +++ b/src/Mapper.php @@ -22,7 +22,7 @@ public static function map(string $path, ?Reader $reader = null): iterable foreach (listClassesInDirectory($path) as $class) { $handler = self::getHandlerByCommand($class, $reader); - if ($handler !== null && !class_exists($handler)) { + if ($handler === null || !class_exists($handler)) { continue; } diff --git a/tests/MapperTest.php b/tests/MapperTest.php index 1d60e36..7e6ceff 100644 --- a/tests/MapperTest.php +++ b/tests/MapperTest.php @@ -14,7 +14,7 @@ final class MapperTest extends TestCase { public function testMapInstantiated() { - $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'test-app' . DIRECTORY_SEPARATOR . 'Commands' . DIRECTORY_SEPARATOR; + $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'test-app' . DIRECTORY_SEPARATOR; $map = iterator_to_array(Mapper::mapInstantiated($path)); self::assertSame(1, count($map)); @@ -24,7 +24,7 @@ public function testMapInstantiated() public function testMap() { - $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'test-app' . DIRECTORY_SEPARATOR . 'Commands' . DIRECTORY_SEPARATOR; + $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'test-app' . DIRECTORY_SEPARATOR; $map = iterator_to_array(Mapper::map($path)); self::assertSame(