Skip to content

Commit

Permalink
update psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Jan 29, 2025
1 parent 347d353 commit cdde77d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
7 changes: 7 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UnusedClass errorLevel="suppress" />
<PossiblyUnusedMethod errorLevel="suppress" />
<UnusedForeachValue errorLevel="suppress" />
<PossiblyUnusedReturnValue errorLevel="suppress" />
<UnusedVariable errorLevel="suppress" />
</issueHandlers>
</psalm>
2 changes: 0 additions & 2 deletions src/Generator/MarkupAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
abstract class MarkupAbstract extends CodeGeneratorAbstract
{
protected int $heading;
protected string $prefix;

public function __construct(?Config $config = null)
{
Expand All @@ -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_';
}
}
2 changes: 1 addition & 1 deletion src/Generator/Normalizer/NormalizerAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Generator/Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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'));
Expand Down
1 change: 0 additions & 1 deletion src/Generator/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
4 changes: 2 additions & 2 deletions src/Inspector/ChangelogGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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() ?? [];
Expand Down
2 changes: 0 additions & 2 deletions src/Parser/Documentor.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@
*/
class Documentor extends Popo
{
private ContextFactory $contextFactory;
private TypeResolver $typeResolver;
private Popo\Resolver\Documentor $documentor;

public function __construct()
{
parent::__construct();

$this->contextFactory = new ContextFactory();
$this->typeResolver = new TypeResolver();
$this->documentor = new Popo\Resolver\Documentor();
}
Expand Down

0 comments on commit cdde77d

Please sign in to comment.