Skip to content

Commit

Permalink
Fix phpstan2 and psalm5 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann committed Jan 9, 2025
1 parent be5f54c commit 2109fda
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
],
"analyse": [
"export XDEBUG_MODE=off && phpstan analyse --memory-limit=2G",
"export XDEBUG_MODE=off && psalm"
"export XDEBUG_MODE=off && psalm --threads=1"
],
"spectral-examples": "for ff in `find Examples -name '*.yaml'`; do spectral lint $ff; done",
"spectral-scratch": "for ff in `find tests/Fixtures/Scratch -name '*.yaml'`; do spectral lint $ff; done",
Expand Down
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ parameters:
count: 1
path: src/Analysers/ReflectionAnalyser.php

-
message: '#^Call to function array_key_exists\(\) with string and array\{\} will always evaluate to false\.$#'
identifier: function.impossibleType
count: 1
path: src/Analysers/TokenScanner.php

-
message: '#^Access to an undefined property OpenApi\\Annotations\\AbstractAnnotation\:\:\$description\.$#'
identifier: property.notFound
Expand Down
8 changes: 1 addition & 7 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
<file src="src/Serializer.php">
<ReservedWord occurrences="1">
<code>Yaml::parse($contents)</code>
</ReservedWord>
</file>
</files>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0"/>
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="true"
findUnusedCode="false"
phpVersion="8.1"
>
<projectFiles>
Expand Down
1 change: 1 addition & 0 deletions src/Analysers/TokenScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function scanFile(string $filename): array

protected function collect_stmts(array $stmts, string $namespace): array
{
/** @var array $uses */
$uses = [];
$resolve = function (string $name) use ($namespace, &$uses) {
if (array_key_exists($name, $uses)) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Processors/AugmentSchemasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testAugmentSchemas(): void

$this->assertSame('Customer', $customer->schema, '@OA\Schema()->schema based on classname');
$this->assertIsArray($customer->properties);
$this->assertCount(10, $customer->properties, '@OA\Property()s are merged into the @OA\Schema of the class');
$this->assertCount(10, (array) $customer->properties, '@OA\Property()s are merged into the @OA\Schema of the class');
}

public function testAugmentSchemasForInterface(): void
Expand All @@ -51,6 +51,6 @@ public function testAugmentSchemasForInterface(): void
$analysis->process([new AugmentSchemas()]);

$this->assertIsArray($customer->properties);
$this->assertCount(9, $customer->properties, '@OA\Property()s are merged into the @OA\Schema of the class');
$this->assertCount(9, (array) $customer->properties, '@OA\Property()s are merged into the @OA\Schema of the class');
}
}
4 changes: 2 additions & 2 deletions tests/Processors/MergeJsonContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testJsonContent(): void
$analysis->process([new MergeJsonContent()]);

$this->assertIsArray($response->content);
$this->assertCount(1, $response->content);
$this->assertCount(1, (array) $response->content);
$this->assertCount(0, $response->_unmerged);
$json = json_decode(json_encode($response), true);
$this->assertSame('#/components/schemas/repository', $json['content']['application/json']['schema']['items']['$ref']);
Expand Down Expand Up @@ -75,7 +75,7 @@ public function testParameter(): void
$analysis->process([new MergeJsonContent()]);

$this->assertIsArray($parameter->content);
$this->assertCount(1, $parameter->content);
$this->assertCount(1, (array) $parameter->content);
$this->assertCount(0, $parameter->_unmerged);
$json = json_decode(json_encode($parameter), true);
$this->assertSame('query', $json['in']);
Expand Down
4 changes: 2 additions & 2 deletions tests/Processors/MergeXmlContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testXmlContent(): void
$analysis->process([new MergeXmlContent()]);

$this->assertIsArray($response->content);
$this->assertCount(1, $response->content);
$this->assertCount(1, (array) $response->content);
$this->assertCount(0, $response->_unmerged);
$json = json_decode(json_encode($response), true);
$this->assertSame('#/components/schemas/repository', $json['content']['application/xml']['schema']['items']['$ref']);
Expand Down Expand Up @@ -73,7 +73,7 @@ public function testParameter(): void
$analysis->process([new MergeXmlContent()]);

$this->assertIsArray($parameter->content);
$this->assertCount(1, $parameter->content);
$this->assertCount(1, (array) $parameter->content);
$this->assertCount(0, $parameter->_unmerged);
$json = json_decode(json_encode($parameter), true);
$this->assertSame('query', $json['in']);
Expand Down

0 comments on commit 2109fda

Please sign in to comment.