Skip to content

Commit

Permalink
phpstan fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Oct 25, 2024
1 parent 3efc9a8 commit de2984a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ parameters:
message: "#^Property Nelmio\\\\ApiDocBundle\\\\Render\\\\Html\\\\HtmlOpenApiRenderer\\:\\:\\$twig has unknown class Twig_Environment as its type\\.$#"
count: 1
path: src/Render/Html/HtmlOpenApiRenderer.php

-
message: "#^Call to function is_callable\\(\\) with array\\{string, mixed\\} will always evaluate to false\\.$#"
count: 1
path: src/RouteDescriber/FosRestDescriber.php
5 changes: 3 additions & 2 deletions src/RouteDescriber/FosRestDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private function getEnum($requirements, \ReflectionMethod $reflectionMethod): ?a
return $choices();
}

return $requirements->choices;
return null;
}

private function getContentSchemaForType(OA\RequestBody $requestBody, string $type): OA\Schema
Expand Down Expand Up @@ -237,10 +237,11 @@ private function describeCommonSchemaFromAnnotation(OA\Schema $schema, AbstractS
*/
private function getAttributesAsAnnotation(\ReflectionMethod $reflection, string $className): array
{
$annotations = [];
foreach ($reflection->getAttributes($className, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
$annotations[] = $attribute->newInstance();
}

return $annotations ?? [];
return $annotations;
}
}
5 changes: 4 additions & 1 deletion tests/RouteDescriber/FosRestDescriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FosRestDescriberTest extends TestCase
public function testQueryParamWithChoiceConstraintIsAddedAsEnum(): void
{
$class = new class {
#[QueryParam(requirements: new Choice(['foo', 'bar']))]
#[QueryParam(requirements: new Choice(choices: ['foo', 'bar']))]
public function getAction(): void
{
}
Expand All @@ -50,6 +50,9 @@ public function getAction(): void
{
}

/**
* @return string[]
*/
public static function getChoices(): array
{
return ['foo', 'bar'];
Expand Down

0 comments on commit de2984a

Please sign in to comment.