Address PHP 8.2. warnings and static analysis (#1263)

* Address PHP 8.2. warnings
* Supress UndefinedAttributeClass error for AllowDynamicProperties
This commit is contained in:
Martin Rademacher 2022-06-20 11:53:03 +12:00 committed by GitHub
parent a98944325d
commit 9beaa98db4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -18,5 +18,11 @@
</projectFiles>
<issueHandlers>
<UndefinedAttributeClass>
<errorLevel type="suppress">
<referencedClass name="AllowDynamicProperties" />
<file name="src/Context.php" />
</errorLevel>
</UndefinedAttributeClass>
</issueHandlers>
</psalm>

View File

@ -8,6 +8,7 @@ namespace OpenApi;
use OpenApi\Annotations\OpenApi;
use OpenApi\Loggers\DefaultLogger;
use Psr\Log\LoggerInterface;
/**
* Context.
@ -44,10 +45,11 @@ use OpenApi\Loggers\DefaultLogger;
* 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
{
/**

View File

@ -22,6 +22,9 @@ class AbstractAnnotationTest extends OpenApiTestCase
$this->assertSame(123, $output->$prefixedProperty);
}
/**
* @requires PHP < 8.2
*/
public function testInvalidField(): void
{
$this->assertOpenApiLogEntryContains('Unexpected field "doesnot" for @OA\Get(), expecting');