Skip to content

Commit

Permalink
Bump tooling deps and allow nikic/php-parser ^5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann committed Jan 9, 2025
1 parent 13e8b18 commit be5f54c
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 36 deletions.
8 changes: 4 additions & 4 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
139 changes: 113 additions & 26 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,106 +1,193 @@
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: '#^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\\.$#"
message: '#^Access to an undefined property OpenApi\\Annotations\\AbstractAnnotation\:\:\$description\.$#'
identifier: property.notFound
count: 1
path: src/Annotations/AbstractAnnotation.php

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

-
message: "#^Variable \\$name might not be defined\\.$#"
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\.$#'
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
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
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
1 change: 0 additions & 1 deletion tests/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public function testDeserializeAllOfProperty(): void
$allOfItem = current($schemaObject->allOf);
$this->assertIsObject($allOfItem);
$this->assertInstanceOf(OA\Schema::class, $allOfItem);
$this->assertTrue(property_exists($allOfItem, 'ref'));
$this->assertNotSame($allOfItem->ref, Generator::UNDEFINED);
$this->assertSame('#/components/schemas/SomeSchema', $allOfItem->ref);
}
Expand Down

0 comments on commit be5f54c

Please sign in to comment.