Skip to content

Commit

Permalink
Update tooling and dependency versions (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Jan 9, 2025
1 parent faf0bb4 commit 2d36530
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'

- uses: ramsey/composer-install@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'

- uses: ramsey/composer-install@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'

- uses: ramsey/composer-install@v3
with:
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"require": {
"php": ">=7.4",
"ext-json": "*",
"nikic/php-parser": "^4.19",
"nikic/php-parser": "^4.19 || ^5.0",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"symfony/deprecation-contracts": "^2 || ^3",
"symfony/finder": "^5.0 || ^6.0 || ^7.0",
Expand All @@ -61,10 +61,10 @@
"composer/package-versions-deprecated": "^1.11",
"doctrine/annotations": "^2.0",
"friendsofphp/php-cs-fixer": "^3.62.0",
"phpstan/phpstan": "^1.6",
"phpstan/phpstan": "^1.6 || ^2.0",
"phpunit/phpunit": "^9.0",
"rector/rector": "^1.0",
"vimeo/psalm": "^4.30"
"rector/rector": "^1.0 || ^2.0",
"vimeo/psalm": "^4.30 || ^5.0"
},
"conflict": {
"symfony/process": ">=6, <6.4.14"
Expand Down 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
135 changes: 108 additions & 27 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,106 +1,187 @@
parameters:
ignoreErrors:
-
message: "#^Property OpenApi\\\\Annotations\\\\AbstractAnnotation\\:\\:\\$x \\(array\\<string, mixed\\>\\) does not accept string\\.$#"
message: '#^Property OpenApi\\Annotations\\AbstractAnnotation\:\:\$x \(array\<string, mixed\>\) does not accept string\.$#'
identifier: assign.propertyType
count: 1
path: Examples/processors/schema-query-parameter/SchemaQueryParameter.php

-
message: "#^Result of && is always true\\.$#"
message: '#^Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist\.$#'
identifier: attribute.notFound
count: 1
path: Examples/processors/sort-components/SortComponents.php
path: Examples/using-links-php81/User.php

-
message: "#^Attribute class JetBrains\\\\PhpStorm\\\\ArrayShape does not exist\\.$#"
message: '#^Call to function method_exists\(\) with ReflectionProperty and ''isPromoted'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: Examples/using-links-php81/User.php
path: src/Analysers/AttributeAnnotationFactory.php

-
message: '#^Call to function method_exists\(\) with ReflectionClass\<object\> and ''isEnum'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: src/Analysers/ReflectionAnalyser.php

-
message: "#^Call to function array_key_exists\\(\\) with string and array\\{\\} will always evaluate to false\\.$#"
message: '#^Access to an undefined property OpenApi\\Annotations\\AbstractAnnotation\:\:\$description\.$#'
identifier: property.notFound
count: 1
path: src/Analysers/TokenScanner.php
path: src/Annotations/AbstractAnnotation.php

-
message: "#^Access to an undefined property OpenApi\\\\Annotations\\\\AbstractAnnotation\\:\\:\\$description\\.$#"
message: '#^Access to an undefined property OpenApi\\Annotations\\AbstractAnnotation\:\:\$summary\.$#'
identifier: property.notFound
count: 1
path: src/Annotations/AbstractAnnotation.php

-
message: "#^Access to an undefined property OpenApi\\\\Annotations\\\\AbstractAnnotation\\:\\:\\$summary\\.$#"
message: '#^Call to function property_exists\(\) with OpenApi\\Annotations\\AbstractAnnotation and ''_context'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: src/Annotations/AbstractAnnotation.php

-
message: "#^Variable \\$name might not be defined\\.$#"
message: '#^Variable \$name might not be defined\.$#'
identifier: variable.undefined
count: 2
path: src/Annotations/Components.php

-
message: "#^Variable \\$type might not be defined\\.$#"
message: '#^Variable \$type might not be defined\.$#'
identifier: variable.undefined
count: 1
path: src/Annotations/Components.php

-
message: "#^Property OpenApi\\\\Annotations\\\\Flow\\:\\:\\$scopes \\(array\\) does not accept stdClass\\.$#"
message: '#^Property OpenApi\\Annotations\\Flow\:\:\$scopes \(array\) does not accept stdClass\.$#'
identifier: assign.propertyType
count: 1
path: src/Annotations/Flow.php

-
message: "#^Access to an undefined property object\\:\\:\\$enum\\.$#"
message: '#^Method OpenApi\\Processors\\AugmentParameters\:\:extractVarTypeAndDescription\(\) should return array\<string, string\|null\> but returns array\<int\|string, string\|null\>\.$#'
identifier: return.type
count: 1
path: src/Annotations/Schema.php
path: src/Processors/AugmentParameters.php

-
message: "#^Call to function is_array\\(\\) with bool\\|OpenApi\\\\Annotations\\\\AdditionalProperties will always evaluate to false\\.$#"
message: '#^Strict comparison using \!\=\= between false and string will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: src/Processors/AugmentSchemas.php
path: src/Processors/AugmentParameters.php

-
message: "#^Property OpenApi\\\\Annotations\\\\Schema\\:\\:\\$properties \\(array\\<OpenApi\\\\Annotations\\\\Property\\>\\) does not accept string\\.$#"
message: '#^Method OpenApi\\Processors\\AugmentProperties\:\:extractVarTypeAndDescription\(\) should return array\<string, string\|null\> but returns array\<int\|string, string\|null\>\.$#'
identifier: return.type
count: 1
path: src/Processors/AugmentSchemas.php
path: src/Processors/AugmentProperties.php

-
message: "#^Result of && is always false\\.$#"
message: '#^Strict comparison using \!\=\= between false and string will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: src/Processors/AugmentProperties.php

-
message: '#^Property OpenApi\\Annotations\\Schema\:\:\$properties \(array\<OpenApi\\Annotations\\Property\>\) does not accept string\.$#'
identifier: assign.propertyType
count: 1
path: src/Processors/AugmentSchemas.php

-
message: "#^Parameter \\#1 \\$annotation of method OpenApi\\\\Processors\\\\DocBlockDescriptions\\:\\:description\\(\\) expects OpenApi\\\\Annotations\\\\Operation\\|OpenApi\\\\Annotations\\\\Parameter\\|OpenApi\\\\Annotations\\\\Schema, OpenApi\\\\Annotations\\\\AbstractAnnotation given\\.$#"
message: '#^Method OpenApi\\Processors\\DocBlockDescriptions\:\:extractVarTypeAndDescription\(\) should return array\<string, string\|null\> but returns array\<int\|string, string\|null\>\.$#'
identifier: return.type
count: 1
path: src/Processors/DocBlockDescriptions.php

-
message: '#^Parameter \#1 \$annotation of method OpenApi\\Processors\\DocBlockDescriptions\:\:description\(\) expects OpenApi\\Annotations\\Operation\|OpenApi\\Annotations\\Parameter\|OpenApi\\Annotations\\Schema, OpenApi\\Annotations\\AbstractAnnotation given\.$#'
identifier: argument.type
count: 1
path: src/Processors/DocBlockDescriptions.php

-
message: '#^Parameter \#1 \$annotation of method OpenApi\\Processors\\DocBlockDescriptions\:\:summaryAndDescription\(\) expects OpenApi\\Annotations\\Operation\|OpenApi\\Annotations\\Parameter\|OpenApi\\Annotations\\Schema, OpenApi\\Annotations\\AbstractAnnotation given\.$#'
identifier: argument.type
count: 1
path: src/Processors/DocBlockDescriptions.php

-
message: "#^Parameter \\#1 \\$annotation of method OpenApi\\\\Processors\\\\DocBlockDescriptions\\:\\:summaryAndDescription\\(\\) expects OpenApi\\\\Annotations\\\\Operation\\|OpenApi\\\\Annotations\\\\Parameter\\|OpenApi\\\\Annotations\\\\Schema, OpenApi\\\\Annotations\\\\AbstractAnnotation given\\.$#"
message: '#^Strict comparison using \!\=\= between false and string will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: src/Processors/DocBlockDescriptions.php

-
message: "#^Property OpenApi\\\\Annotations\\\\Schema\\:\\:\\$examples \\(array\\<OpenApi\\\\Annotations\\\\Examples\\>\\) does not accept string\\.$#"
message: '#^Property OpenApi\\Annotations\\Schema\:\:\$examples \(array\<OpenApi\\Annotations\\Examples\>\) does not accept string\.$#'
identifier: assign.propertyType
count: 1
path: src/Processors/MergeJsonContent.php

-
message: "#^Property OpenApi\\\\Annotations\\\\Schema\\:\\:\\$examples \\(array\\<OpenApi\\\\Annotations\\\\Examples\\>\\) does not accept string\\.$#"
message: '#^Property OpenApi\\Annotations\\Schema\:\:\$examples \(array\<OpenApi\\Annotations\\Examples\>\) does not accept string\.$#'
identifier: assign.propertyType
count: 1
path: src/Processors/MergeXmlContent.php

-
message: "#^Parameter \\#1 \\$callback of function spl_autoload_register expects \\(callable\\(string\\)\\: void\\)\\|null, array\\{Composer\\\\Autoload\\\\ClassLoader, 'findFile'\\} given\\.$#"
message: '#^Parameter \#1 \$callback of function spl_autoload_register expects \(callable\(string\)\: void\)\|null, array\{Composer\\Autoload\\ClassLoader, ''findFile''\} given\.$#'
identifier: argument.type
count: 1
path: tests/Analysers/ComposerAutoloaderScannerTest.php

-
message: "#^Access to an undefined property OpenApi\\\\Analysers\\\\AnnotationFactoryInterface\\:\\:\\$reflectors\\.$#"
message: '#^Access to an undefined property OpenApi\\Analysers\\AnnotationFactoryInterface\:\:\$reflectors\.$#'
identifier: property.notFound
count: 2
path: tests/Analysers/ReflectionAnalyserTest.php

-
message: "#^Access to an undefined property Reflector\\:\\:\\$name\\.$#"
message: '#^Access to an undefined property Reflector\:\:\$name\.$#'
identifier: property.notFound
count: 1
path: tests/Analysers/ReflectionAnalyserTest.php

-
message: "#^Call to an undefined method ReflectionType\\:\\:getName\\(\\)\\.$#"
message: '#^Call to an undefined method ReflectionType\:\:getName\(\)\.$#'
identifier: method.notFound
count: 1
path: tests/Annotations/AttributesSyncTest.php

-
message: '#^Method OpenApi\\Tests\\Processors\\AugmentParametersTest\:\:extractVarTypeAndDescription\(\) should return array\<string, string\|null\> but returns array\<int\|string, string\|null\>\.$#'
identifier: return.type
count: 1
path: tests/Processors/AugmentParametersTest.php

-
message: '#^Strict comparison using \!\=\= between false and string will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: tests/Processors/AugmentParametersTest.php

-
message: '#^Method OpenApi\\Tests\\Processors\\AugmentRefsTest\:\:extractVarTypeAndDescription\(\) should return array\<string, string\|null\> but returns array\<int\|string, string\|null\>\.$#'
identifier: return.type
count: 1
path: tests/Processors/AugmentRefsTest.php

-
message: '#^Strict comparison using \!\=\= between false and string will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: tests/Processors/AugmentRefsTest.php

-
message: '#^Method OpenApi\\Tests\\Processors\\DocBlockDescriptionsTest\:\:extractVarTypeAndDescription\(\) should return array\<string, string\|null\> but returns array\<int\|string, string\|null\>\.$#'
identifier: return.type
count: 1
path: tests/Processors/DocBlockDescriptionsTest.php

-
message: '#^Strict comparison using \!\=\= between false and string will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: tests/Processors/DocBlockDescriptionsTest.php
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ parameters:
processTimeout: 300.0
excludePaths:
- 'tests/Fixtures/*'
treatPhpDocTypesAsCertain: false
ignoreErrors:
- '#does not accept default value of type #'
## Examples
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
2 changes: 0 additions & 2 deletions src/Analysers/AttributeAnnotationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ public function build(\Reflector $reflector, Context $context): array
Generator::$context = null;
}

$annotations = array_values(array_filter($annotations, fn ($a) => $a instanceof OA\AbstractAnnotation));

// merge backwards into parents...
$isParent = function (OA\AbstractAnnotation $annotation, OA\AbstractAnnotation $possibleParent): bool {
// regular annotation hierarchy
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
2 changes: 1 addition & 1 deletion src/Processors/Concerns/DocblockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function extractDescription(?string $docblock): string
/**
* Extract property type and description from a `@var` dockblock line.
*
* @return array<string, string> extracted `type` and `description`; values default to `null`
* @return array<string, ?string> extracted `type` and `description`; values default to `null`
*/
public function extractVarTypeAndDescription(?string $docblock): array
{
Expand Down
1 change: 0 additions & 1 deletion src/Processors/MergeIntoOpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function __invoke(Analysis $analysis)
} elseif (
$annotation instanceof OA\AbstractAnnotation
&& in_array(OA\OpenApi::class, $annotation::$_parents)
&& property_exists($annotation, '_context')
&& false === $annotation->_context->is('nested')) {
// A top level annotation.
$merge[] = $annotation;
Expand Down
2 changes: 1 addition & 1 deletion tests/Analysers/DocBlockParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DocBlockParserTest extends OpenApiTestCase
public function testParseContents(): void
{
$annotations = $this->annotationsFromDocBlockParser('@OA\Parameter(description="This is my parameter")', self::SWG_ALIAS);
$this->assertIsArray($annotations);
$this->assertNotEmpty($annotations);
$parameter = $annotations[0];
$this->assertInstanceOf('OpenApi\Annotations\Parameter', $parameter);
$this->assertSame('This is my parameter', $parameter->description);
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
Loading

0 comments on commit 2d36530

Please sign in to comment.