Skip to content

Commit 2a3aa61

Browse files
authored
chore: Fixed phpstan errors (#1911)
* Fixed phpstan errors * Fixed no_unused_import complaint * Reverted * Reverted * tried adding reportUnmatchedIgnoredErrors parameter * Tried to fix phpspec/prophecy to 1.22.* until PHP 8.1 is dropped * Reverted * Added phpstan error message suppression * Tried fixing array access psalm complaint * Reverted and add suppression * Added psalm suppression
1 parent 64e1d4d commit 2a3aa61

File tree

8 files changed

+23
-2
lines changed

8 files changed

+23
-2
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
"nyholm/psr7": "^1.4",
9999
"open-telemetry/dev-tools": "dev-main",
100100
"php-http/mock-client": "^1.5",
101-
"phpdocumentor/reflection-docblock": "^6.0",
102-
"phpspec/prophecy": "^1.22",
101+
"phpdocumentor/reflection-docblock": "^5.2",
102+
"phpspec/prophecy": "1.22.*",
103103
"phpspec/prophecy-phpunit": "^2",
104104
"phpstan/phpstan": "^1.10.13",
105105
"phpstan/phpstan-mockery": "^1.1",

phpstan.neon.dist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ parameters:
1212
excludePaths:
1313
- tests/TraceContext/W3CTestService
1414
- tests/Unit/Config/SDK/Configuration/ExampleSdk
15+
reportUnmatchedIgnoredErrors: false
1516
ignoreErrors:
1617
-
1718
message: "#Call to an undefined method .*#"
@@ -34,6 +35,12 @@ parameters:
3435
message: "#Call to an undefined method .*:expects.*#"
3536
paths:
3637
- tests
38+
-
39+
message: "#Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface::.*#"
40+
paths:
41+
- src/Config/SDK
42+
- tests/Unit/Config
43+
- tests/Integration/Config
3744
-
3845
message: "#Cannot call method .* on null#"
3946
paths:
@@ -62,3 +69,7 @@ parameters:
6269
message: "#^Caught class .* not found\\.#"
6370
paths:
6471
- src/Config/SDK/Configuration/Environment/Adapter/
72+
-
73+
message: "#^PHPDoc tag @extends contains generic type .* but class .* is not generic\\.#"
74+
paths:
75+
- src/Config/SDK/Configuration/Internal/NodeDefinition/

src/Config/SDK/Configuration/Internal/NodeDefinition/ArrayNodeDefinition.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Symfony\Component\Config\Definition\NodeInterface;
1111

1212
/**
13+
* @internal
1314
* @extends \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition<NodeParentInterface|null>
1415
*/
1516
class ArrayNodeDefinition extends \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition

src/SDK/Common/Exception/StackTraceFormatter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public static function format(Throwable $e): string
7070
* @psalm-param Frames $frames
7171
* @phan-suppress-next-line PhanTypeMismatchDeclaredParam
7272
* @psalm-param Frames|null $enclosing
73+
* @psalm-suppress InvalidArrayOffset
7374
*/
7475
private static function writeFrames(string &$s, array $frames, ?array $enclosing): void
7576
{

src/SDK/Common/Export/Http/PsrUtils.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ private static function parseRetryAfter(?ResponseInterface $response): int
6363
/**
6464
* @param list<string> $encodings
6565
* @param array<int, string>|null $appliedEncodings
66+
* @psalm-suppress PossiblyInvalidArrayOffset
6667
*/
6768
public static function encode(string $value, array $encodings, ?array &$appliedEncodings = null): string
6869
{

src/SDK/Metrics/Aggregation/ExplicitBucketHistogramAggregation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function initialize(): ExplicitBucketHistogramSummary
4040

4141
/**
4242
* @param ExplicitBucketHistogramSummary $summary
43+
* @psalm-suppress InvalidArrayOffset
4344
*/
4445
#[\Override]
4546
public function record($summary, $value, AttributesInterface $attributes, ContextInterface $context, int $timestamp): void

src/SDK/Metrics/Exemplar/HistogramBucketReservoir.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public function __construct(array $boundaries)
2525
$this->boundaries = $boundaries;
2626
}
2727

28+
/**
29+
* @psalm-suppress InvalidArrayOffset
30+
*/
2831
#[\Override]
2932
public function offer($index, $value, AttributesInterface $attributes, ContextInterface $context, int $timestamp): void
3033
{

tests/Integration/SDK/SpanBuilderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ public function test_add_link_invalid(): void
9696
$span->end();
9797
}
9898

99+
/**
100+
* @psalm-suppress InvalidArrayOffset
101+
*/
99102
public function test_add_link_dropping_links(): void
100103
{
101104
Logging::disable();

0 commit comments

Comments
 (0)