Skip to content

Commit 42805f2

Browse files
authored
Fix invalid generated code (async-aws#607)
1 parent eada0ce commit 42805f2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/CodeGenerator/src/Command/GenerateCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,14 @@ private function getOperationNames(?string $inputOperationName, bool $returnAll,
283283

284284
private function fixCs(ClassName $clientClass, SymfonyStyle $io): void
285285
{
286-
$reflection = new \ReflectionClass($clientClass->getFqdn());
287-
$srcPath = \dirname($reflection->getFileName());
288-
$testPath = realpath($srcPath . '/../tests');
286+
$srcPath = \dirname((new \ReflectionClass($clientClass->getFqdn()))->getFileName());
287+
$testPath = \substr($srcPath, 0, \strrpos($srcPath, '/src/')) . '/tests';
288+
if (!\is_dir($srcPath)) {
289+
throw new \InvalidArgumentException(sprintf('The src dir "%s" does not exists', $srcPath));
290+
}
291+
if (!\is_dir($testPath)) {
292+
throw new \InvalidArgumentException(sprintf('The test dir "%s" does not exists', $testPath));
293+
}
289294

290295
// assert this
291296
$baseDir = \dirname($this->manifestFile);

0 commit comments

Comments
 (0)