Skip to content

Commit 9beaa98

Browse files
authored
Address PHP 8.2. warnings and static analysis (zircote#1263)
* Address PHP 8.2. warnings * Supress UndefinedAttributeClass error for AllowDynamicProperties
1 parent a989443 commit 9beaa98

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

phpstan-baseline.neon

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ parameters:
4040
count: 1
4141
path: src/Annotations/Schema.php
4242

43+
-
44+
message: "#^Attribute class AllowDynamicProperties does not exist\\.$#"
45+
count: 1
46+
path: src/Context.php
47+
4348
-
4449
message: "#^Ternary operator condition is always true\\.$#"
4550
count: 1

psalm.xml

+6
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@
1818
</projectFiles>
1919

2020
<issueHandlers>
21+
<UndefinedAttributeClass>
22+
<errorLevel type="suppress">
23+
<referencedClass name="AllowDynamicProperties" />
24+
<file name="src/Context.php" />
25+
</errorLevel>
26+
</UndefinedAttributeClass>
2127
</issueHandlers>
2228
</psalm>

src/Context.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use OpenApi\Annotations\OpenApi;
1010
use OpenApi\Loggers\DefaultLogger;
11+
use Psr\Log\LoggerInterface;
1112

1213
/**
1314
* Context.
@@ -44,10 +45,11 @@
4445
* the serializer
4546
* @property Annotations\AbstractAnnotation|null $nested
4647
* @property Annotations\AbstractAnnotation[]|null $annotations
47-
* @property \Psr\Log\LoggerInterface|null $logger Guaranteed to be set when using the `Generator`
48+
* @property LoggerInterface|null $logger Guaranteed to be set when using the `Generator`
4849
* @property array|null $scanned Details of file scanner when using ReflectionAnalyser
4950
* @property string|null $version The OpenAPI version in use
5051
*/
52+
#[\AllowDynamicProperties]
5153
class Context
5254
{
5355
/**

tests/Annotations/AbstractAnnotationTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public function testVendorFields(): void
2222
$this->assertSame(123, $output->$prefixedProperty);
2323
}
2424

25+
/**
26+
* @requires PHP < 8.2
27+
*/
2528
public function testInvalidField(): void
2629
{
2730
$this->assertOpenApiLogEntryContains('Unexpected field "doesnot" for @OA\Get(), expecting');

0 commit comments

Comments
 (0)