Skip to content

Commit

Permalink
Fix phpstan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann committed Jul 15, 2024
1 parent 2712c49 commit 731ea74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ public function __invoke(Analysis $analysis): void
*/
private function expandQueryArgs(Operation $operation, Schema $schema): void
{
if ($schema->properties === Generator::UNDEFINED || !$schema->properties) {
if (Generator::isDefault($schema->properties) || !$schema->properties) {
return;
}

$operation->parameters = $operation->parameters === Generator::UNDEFINED ? [] : $operation->parameters;
$operation->parameters = Generator::isDefault($operation->parameters) ? [] : $operation->parameters;

foreach ($schema->properties as $property) {
$isNullable = $property->nullable !== Generator::UNDEFINED ? $property->nullable : false;
$isNullable = Generator::isDefault($property->nullable) ? false : $property->nullable;
$schema = new Schema(
type: $property->format !== Generator::UNDEFINED ? $property->format : $property->type,
type: Generator::isDefault($property->format) ? $property->type : $property->format,
nullable: $isNullable
);
$schema->_context = $operation->_context; // inherit context from operation, required to pretend to be a parameter

$parameter = new Parameter(
name: $property->property,
description: $property->description !== Generator::UNDEFINED ? $property->description : null,
description: Generator::isDefault($property->description) ? null : $property->description,
in: 'query',
required: !$isNullable,
schema: $schema,
Expand Down
17 changes: 1 addition & 16 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
parameters:
ignoreErrors:
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: Examples/processors/schema-query-parameter-attributes/SchemaQueryParameter.php

-
message: "#^Property OpenApi\\\\Annotations\\\\AbstractAnnotation\\:\\:\\$x \\(array\\<string, mixed\\>\\) does not accept string\\.$#"
count: 1
path: Examples/processors/schema-query-parameter-attributes/SchemaQueryParameter.php

-
message: "#^Strict comparison using \\=\\=\\= between array\\<OpenApi\\\\Annotations\\\\Parameter\\> and '@OA\\\\\\\\Generator\\:…' will always evaluate to false\\.$#"
count: 1
path: Examples/processors/schema-query-parameter-attributes/SchemaQueryParameter.php

-
message: "#^Strict comparison using \\=\\=\\= between array\\<OpenApi\\\\Annotations\\\\Property\\> and '@OA\\\\\\\\Generator\\:…' will always evaluate to false\\.$#"
count: 1
path: Examples/processors/schema-query-parameter-attributes/SchemaQueryParameter.php
path: Examples/processors/schema-query-parameter/SchemaQueryParameter.php

-
message: "#^Result of && is always true\\.$#"
Expand Down

0 comments on commit 731ea74

Please sign in to comment.