diff --git a/src/OutputGenerator/Go/GoGeneratorOptions.php b/src/OutputGenerator/Go/GoGeneratorOptions.php index ee6aea9..418a80b 100644 --- a/src/OutputGenerator/Go/GoGeneratorOptions.php +++ b/src/OutputGenerator/Go/GoGeneratorOptions.php @@ -6,5 +6,7 @@ class GoGeneratorOptions { - public function __construct() {} + public function __construct() + { + } } diff --git a/src/OutputGenerator/Go/GoOutputGenerator.php b/src/OutputGenerator/Go/GoOutputGenerator.php index 8def742..e6860a9 100644 --- a/src/OutputGenerator/Go/GoOutputGenerator.php +++ b/src/OutputGenerator/Go/GoOutputGenerator.php @@ -19,10 +19,8 @@ use Riverwaysoft\PhpConverter\OutputWriter\OutputWriterInterface; use function sprintf; -class GoOutputGenerator - implements OutputGeneratorInterface +class GoOutputGenerator implements OutputGeneratorInterface { - /** @var PropertyNameGeneratorInterface[] */ private array $propertyNameGenerators; @@ -126,7 +124,7 @@ private function convertToGoType(DtoType $dto, DtoList $dtoList): string ); } throw new Exception( - 'Unknown expression type '. + 'Unknown expression type ' . $dto->getExpressionType()->jsonSerialize() ); } @@ -145,7 +143,7 @@ private function getPropertyNameGenerator( } throw new Exception( - 'Property name generator not found for type '.$dto->getName() + 'Property name generator not found for type ' . $dto->getName() ); } @@ -168,7 +166,7 @@ private function convertEnumToTypeScriptEnumProperties( if (array_key_exists($constName, $this->usedConstantsStore)) { throw new Exception( - 'Please rename constant '.$constName + 'Please rename constant ' . $constName ); } $this->usedConstantsStore[] = $constName; diff --git a/src/OutputGenerator/Go/GoTypeResolver.php b/src/OutputGenerator/Go/GoTypeResolver.php index 67e23be..656bc59 100644 --- a/src/OutputGenerator/Go/GoTypeResolver.php +++ b/src/OutputGenerator/Go/GoTypeResolver.php @@ -19,7 +19,10 @@ class GoTypeResolver { /** @param UnknownTypeResolverInterface[] $unknownTypeResolvers */ - public function __construct(private array $unknownTypeResolvers = []) {} + public function __construct( + private array $unknownTypeResolvers = [] + ) { + } public function getTypeFromPhp( PhpTypeInterface $type, @@ -27,7 +30,7 @@ public function getTypeFromPhp( DtoList $dtoList ): string { if ($type instanceof PhpUnionType) { - $fn = fn(PhpTypeInterface $type) => $this->getTypeFromPhp( + $fn = fn (PhpTypeInterface $type) => $this->getTypeFromPhp( $type, $dto, $dtoList @@ -85,14 +88,14 @@ public function getTypeFromPhp( $type->hasGenerics() && ( $dtoList->hasDtoWithType($type->getName()) || !empty( - $type->getContext()[PhpUnknownType::GENERIC_IGNORE_NO_RESOLVER] + $type->getContext()[PhpUnknownType::GENERIC_IGNORE_NO_RESOLVER] ) ) ) { $result = $type->getName(); $generics = array_map( - fn(PhpTypeInterface $innerGeneric) => $this->getTypeFromPhp( + fn (PhpTypeInterface $innerGeneric) => $this->getTypeFromPhp( $innerGeneric, $dto, $dtoList, diff --git a/tests/OutputGenerator/GoGeneratorTest.php b/tests/OutputGenerator/GoGeneratorTest.php index a8d66e4..210568c 100644 --- a/tests/OutputGenerator/GoGeneratorTest.php +++ b/tests/OutputGenerator/GoGeneratorTest.php @@ -11,7 +11,6 @@ use Riverwaysoft\PhpConverter\Ast\DtoVisitor; use Riverwaysoft\PhpConverter\CodeProvider\FileSystemCodeProvider; use Riverwaysoft\PhpConverter\Filter\PhpAttributeFilter; -use Riverwaysoft\PhpConverter\OutputGenerator\Go\GoGeneratorOptions; use Riverwaysoft\PhpConverter\OutputGenerator\Go\GoOutputGenerator; use Riverwaysoft\PhpConverter\OutputGenerator\Go\GoTypeResolver; use Riverwaysoft\PhpConverter\OutputGenerator\UnknownTypeResolver\ClassNameTypeResolver; @@ -19,8 +18,7 @@ use Riverwaysoft\PhpConverter\OutputWriter\SingleFileOutputWriter\SingleFileOutputWriter; use Spatie\Snapshots\MatchesSnapshots; -class GoGeneratorTest - extends TestCase +class GoGeneratorTest extends TestCase { use MatchesSnapshots; @@ -32,8 +30,8 @@ protected function getSnapshotDirectory(): string return ( dirname( (new ReflectionClass($this))->getFileName() - ). - DIRECTORY_SEPARATOR. + ) . + DIRECTORY_SEPARATOR . '__snapshots__' ); } @@ -41,10 +39,10 @@ protected function getSnapshotDirectory(): string return ( dirname( (new ReflectionClass($this))->getFileName() - ). - DIRECTORY_SEPARATOR. - '__snapshots__'. - DIRECTORY_SEPARATOR. + ) . + DIRECTORY_SEPARATOR . + '__snapshots__' . + DIRECTORY_SEPARATOR . $this->snapshotSubDirectory ); } @@ -189,7 +187,7 @@ public function testNormalizationDirectory(): void { $this->snapshotSubDirectory = 'GoGeneratorTest_testNormalizationDirectory'; $converter = new Converter([new DtoVisitor()]); - $fileProvider = FileSystemCodeProvider::phpFiles(__DIR__.'/Fixtures'); + $fileProvider = FileSystemCodeProvider::phpFiles(__DIR__ . '/Fixtures'); $result = $converter->convert($fileProvider->getListings()); $this->assertMatchesJsonSnapshot($result->dtoList->getList()); $results = (new GoOutputGenerator(