Skip to content

Commit 044f0e3

Browse files
authored
Merge pull request #166 from ToshY/bug/165
[generator] fixed reflection instance without constructor
2 parents ba095fa + 06893fe commit 044f0e3

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

generator/Generator/MapGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static function scanExistingModelEndpointClasses(string $directory): arr
115115
continue;
116116
}
117117

118-
$newInstance = $reflectionClass->newInstance();
118+
$newInstance = $reflectionClass->newInstanceWithoutConstructor();
119119
$path = OpenApiModelUtils::normalizePath($newInstance->getPath());
120120
$method = $newInstance->getMethod();
121121
if ($method instanceof Method === false) {

generator/Generator/ModelGenerator.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use ReflectionClass;
2525
use ReflectionException;
2626
use RuntimeException;
27-
use Throwable;
2827
use ToshY\BunnyNet\Attributes\BodyProperty;
2928
use ToshY\BunnyNet\Attributes\HeaderProperty;
3029
use ToshY\BunnyNet\Attributes\PathProperty;
@@ -985,19 +984,15 @@ private function scanExistingEndpoints(): array
985984
continue;
986985
}
987986

988-
try {
989-
$reflectionClass = new ReflectionClass($endpointClass);
990-
/** @var ModelInterface $instance */
991-
$instance = $reflectionClass->newInstance();
992-
993-
$existingEndpoints[$endpointClass] = [
994-
'headers' => $instance->getHeaders(),
995-
'path' => $instance->getPath(),
996-
'method' => $instance->getMethod(),
997-
];
998-
} catch (Throwable) {
999-
continue;
1000-
}
987+
$reflectionClass = new ReflectionClass($endpointClass);
988+
/** @var ModelInterface $instance */
989+
$instance = $reflectionClass->newInstanceWithoutConstructor();
990+
991+
$existingEndpoints[$endpointClass] = [
992+
'headers' => $instance->getHeaders(),
993+
'path' => $instance->getPath(),
994+
'method' => $instance->getMethod(),
995+
];
1001996
}
1002997
}
1003998

0 commit comments

Comments
 (0)