diff --git a/composer.json b/composer.json index 45329ab1..17e28b7c 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require-dev": { "phpunit/phpunit": "^9.0", "symfony/yaml": "^5.0|^6.0|^7.0", - "vimeo/psalm": "^5.0" + "vimeo/psalm": "^5.0|^6.0" }, "autoload": { "psr-4": { diff --git a/psalm.xml b/psalm.xml index 3e4e3d08..415e0fe3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -12,4 +12,11 @@ + + + + + + + diff --git a/src/Generator/MarkupAbstract.php b/src/Generator/MarkupAbstract.php index deecc5fa..31027a07 100644 --- a/src/Generator/MarkupAbstract.php +++ b/src/Generator/MarkupAbstract.php @@ -30,7 +30,6 @@ abstract class MarkupAbstract extends CodeGeneratorAbstract { protected int $heading; - protected string $prefix; public function __construct(?Config $config = null) { @@ -39,6 +38,5 @@ public function __construct(?Config $config = null) $heading = (int) $config?->get('heading'); $this->heading = $heading >= 1 && $heading <= 6 ? $heading : 1; - $this->prefix = $config?->get('prefix') ?? 'psx_model_'; } } diff --git a/src/Generator/Normalizer/NormalizerAbstract.php b/src/Generator/Normalizer/NormalizerAbstract.php index 09e0f982..d13d8302 100644 --- a/src/Generator/Normalizer/NormalizerAbstract.php +++ b/src/Generator/Normalizer/NormalizerAbstract.php @@ -168,7 +168,7 @@ protected function sanitizeName(string $name): string return $name; } - return preg_replace('/[^a-zA-Z_]/', '_', $name); + return (string) preg_replace('/[^a-zA-Z_]/', '_', $name); } private function case(string $name, int $style): string diff --git a/src/Generator/Php.php b/src/Generator/Php.php index 324c91b5..892b14a1 100644 --- a/src/Generator/Php.php +++ b/src/Generator/Php.php @@ -383,7 +383,7 @@ private function prettyPrint($class, array $uses): string } } - private function buildToRecord(\PhpParser\Builder\Class_ $class, array $properties, bool $hasParent): void + private function buildToRecord(Class_ $class, array $properties, bool $hasParent): void { $stmts = []; if ($hasParent) { @@ -400,10 +400,10 @@ private function buildToRecord(\PhpParser\Builder\Class_ $class, array $properti foreach ($properties as $name => $property) { /** @var Code\Property $property */ - $stmts[] = new Node\Expr\MethodCall(new Node\Expr\Variable('record'), new Node\Identifier('put'), [ + $stmts[] = new Node\Stmt\Expression(new Node\Expr\MethodCall(new Node\Expr\Variable('record'), new Node\Identifier('put'), [ new Node\Arg(new Node\Scalar\String_($property->getName()->getRaw())), new Node\Arg(new Node\Expr\PropertyFetch(new Node\Expr\Variable('this'), $name)), - ]); + ])); } $stmts[] = new Node\Stmt\Return_(new Node\Expr\Variable('record')); diff --git a/src/Generator/Swift.php b/src/Generator/Swift.php index 7f0177a4..e302a427 100644 --- a/src/Generator/Swift.php +++ b/src/Generator/Swift.php @@ -78,7 +78,6 @@ protected function writeStruct(Code\Name $name, array $properties, ?string $exte /** @var Code\Property $property */ $keys[$property->getName()->getProperty()] = $property->getName()->getRaw(); - /** @var Code\Property $property */ $code.= $this->indent . 'var ' . $property->getName()->getProperty() . ': ' . $property->getType() . "\n"; } diff --git a/src/Inspector/ChangelogGenerator.php b/src/Inspector/ChangelogGenerator.php index 3c8d2203..a284ef8e 100644 --- a/src/Inspector/ChangelogGenerator.php +++ b/src/Inspector/ChangelogGenerator.php @@ -69,7 +69,7 @@ public function generateDefinitionType(DefinitionTypeAbstract $leftType, Definit yield from $this->generateDefinition($leftType, $rightType, $typeName, $propertyName); if ($leftType instanceof StructDefinitionType && $rightType instanceof StructDefinitionType) { - yield from $this->generateStruct($leftType, $rightType, $typeName, $propertyName); + yield from $this->generateStruct($leftType, $rightType, $typeName); } elseif ($leftType instanceof MapDefinitionType && $rightType instanceof MapDefinitionType) { yield from $this->generateMap($leftType, $rightType, $typeName, $propertyName); } elseif ($leftType instanceof ArrayDefinitionType && $rightType instanceof ArrayDefinitionType) { @@ -88,7 +88,7 @@ private function generateDefinition(DefinitionTypeAbstract $leftType, Definition } } - private function generateStruct(StructDefinitionType $leftType, StructDefinitionType $rightType, string $typeName, ?string $propertyName = null): \Generator + private function generateStruct(StructDefinitionType $leftType, StructDefinitionType $rightType, string $typeName): \Generator { $left = $leftType->getProperties() ?? []; $right = $rightType->getProperties() ?? []; diff --git a/src/Parser/Documentor.php b/src/Parser/Documentor.php index 254e4ae2..604b65f0 100644 --- a/src/Parser/Documentor.php +++ b/src/Parser/Documentor.php @@ -43,7 +43,6 @@ */ class Documentor extends Popo { - private ContextFactory $contextFactory; private TypeResolver $typeResolver; private Popo\Resolver\Documentor $documentor; @@ -51,7 +50,6 @@ public function __construct() { parent::__construct(); - $this->contextFactory = new ContextFactory(); $this->typeResolver = new TypeResolver(); $this->documentor = new Popo\Resolver\Documentor(); }