Skip to content

Commit

Permalink
Address PHP 8.2. warnings and static analysis (#1263)
Browse files Browse the repository at this point in the history
* Address PHP 8.2. warnings
* Supress UndefinedAttributeClass error for AllowDynamicProperties
  • Loading branch information
DerManoMann authored Jun 19, 2022
1 parent a989443 commit 9beaa98
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ parameters:
count: 1
path: src/Annotations/Schema.php

-
message: "#^Attribute class AllowDynamicProperties does not exist\\.$#"
count: 1
path: src/Context.php

-
message: "#^Ternary operator condition is always true\\.$#"
count: 1
Expand Down
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@
</projectFiles>

<issueHandlers>
<UndefinedAttributeClass>
<errorLevel type="suppress">
<referencedClass name="AllowDynamicProperties" />
<file name="src/Context.php" />
</errorLevel>
</UndefinedAttributeClass>
</issueHandlers>
</psalm>
4 changes: 3 additions & 1 deletion src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use OpenApi\Annotations\OpenApi;
use OpenApi\Loggers\DefaultLogger;
use Psr\Log\LoggerInterface;

/**
* Context.
Expand Down Expand Up @@ -44,10 +45,11 @@
* the serializer
* @property Annotations\AbstractAnnotation|null $nested
* @property Annotations\AbstractAnnotation[]|null $annotations
* @property \Psr\Log\LoggerInterface|null $logger Guaranteed to be set when using the `Generator`
* @property LoggerInterface|null $logger Guaranteed to be set when using the `Generator`
* @property array|null $scanned Details of file scanner when using ReflectionAnalyser
* @property string|null $version The OpenAPI version in use
*/
#[\AllowDynamicProperties]
class Context
{
/**
Expand Down
3 changes: 3 additions & 0 deletions tests/Annotations/AbstractAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function testVendorFields(): void
$this->assertSame(123, $output->$prefixedProperty);
}

/**
* @requires PHP < 8.2
*/
public function testInvalidField(): void
{
$this->assertOpenApiLogEntryContains('Unexpected field "doesnot" for @OA\Get(), expecting');
Expand Down

0 comments on commit 9beaa98

Please sign in to comment.