Skip to content

Commit 107a5ea

Browse files
fixing CI complaints (#1666)
* fixing psalm complaints use rector (and psalm) to add Override attributes, and add symfony polyfill to provide Override in earlier php versions * fixing more psalm complaints * more fixes * adding stubs for deptrac there are some things in our code that deptrac doesn't understand or are missing for some php versions. stub them to quieten all those violation warnings * why not cache invalid :( * display tools versions * fix tools cache key * changing cache key * dont complain about unused psalm suppressions * suppress invalid attribute * quieten phpstan php8.5 complaints * revert previous commit...now other php versions complain about an unused ignore :( * revert typecasting in metrics aggregators * Update src/Contrib/Otlp/ProtobufSerializer.php Co-authored-by: Chris Lightfoot-Wild <[email protected]> * remove override stub and use the polyfill from deptrac --------- Co-authored-by: Chris Lightfoot-Wild <[email protected]>
1 parent 1c03717 commit 107a5ea

File tree

136 files changed

+378
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+378
-15
lines changed

Common/Adapter/HttpDiscovery/DependencyResolver.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,49 @@ public static function create(
4141
return new self($messageFactoryResolver, $psrClientResolver, $httpPlugClientResolver);
4242
}
4343

44+
#[\Override]
4445
public function resolveRequestFactory(): RequestFactoryInterface
4546
{
4647
return $this->messageFactoryResolver->resolveRequestFactory();
4748
}
4849

50+
#[\Override]
4951
public function resolveResponseFactory(): ResponseFactoryInterface
5052
{
5153
return $this->messageFactoryResolver->resolveResponseFactory();
5254
}
5355

56+
#[\Override]
5457
public function resolveServerRequestFactory(): ServerRequestFactoryInterface
5558
{
5659
return $this->messageFactoryResolver->resolveServerRequestFactory();
5760
}
5861

62+
#[\Override]
5963
public function resolveStreamFactory(): StreamFactoryInterface
6064
{
6165
return $this->messageFactoryResolver->resolveStreamFactory();
6266
}
6367

68+
#[\Override]
6469
public function resolveUploadedFileFactory(): UploadedFileFactoryInterface
6570
{
6671
return $this->messageFactoryResolver->resolveUploadedFileFactory();
6772
}
6873

74+
#[\Override]
6975
public function resolveUriFactory(): UriFactoryInterface
7076
{
7177
return $this->messageFactoryResolver->resolveUriFactory();
7278
}
7379

80+
#[\Override]
7481
public function resolveHttpPlugAsyncClient(): HttpAsyncClient
7582
{
7683
return $this->httpPlugClientResolver->resolveHttpPlugAsyncClient();
7784
}
7885

86+
#[\Override]
7987
public function resolvePsrClient(): ClientInterface
8088
{
8189
return $this->psrClientResolver->resolvePsrClient();

Common/Adapter/HttpDiscovery/HttpPlugClientResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static function create(?HttpAsyncClient $httpAsyncClient = null): self
1919
return new self($httpAsyncClient);
2020
}
2121

22+
#[\Override]
2223
public function resolveHttpPlugAsyncClient(): HttpAsyncClient
2324
{
2425
return $this->httpAsyncClient ??= HttpAsyncClientDiscovery::find();

Common/Adapter/HttpDiscovery/MessageFactoryResolver.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,37 @@ public static function create(
4343
);
4444
}
4545

46+
#[\Override]
4647
public function resolveRequestFactory(): RequestFactoryInterface
4748
{
4849
return $this->requestFactory ??= Psr17FactoryDiscovery::findRequestFactory();
4950
}
5051

52+
#[\Override]
5153
public function resolveResponseFactory(): ResponseFactoryInterface
5254
{
5355
return $this->responseFactory ??= Psr17FactoryDiscovery::findResponseFactory();
5456
}
5557

58+
#[\Override]
5659
public function resolveServerRequestFactory(): ServerRequestFactoryInterface
5760
{
5861
return $this->serverRequestFactory ??= Psr17FactoryDiscovery::findServerRequestFactory();
5962
}
6063

64+
#[\Override]
6165
public function resolveStreamFactory(): StreamFactoryInterface
6266
{
6367
return $this->streamFactory ??= Psr17FactoryDiscovery::findStreamFactory();
6468
}
6569

70+
#[\Override]
6671
public function resolveUploadedFileFactory(): UploadedFileFactoryInterface
6772
{
6873
return $this->uploadedFileFactory ??= Psr17FactoryDiscovery::findUploadedFileFactory();
6974
}
7075

76+
#[\Override]
7177
public function resolveUriFactory(): UriFactoryInterface
7278
{
7379
return $this->uriFactory ??= Psr17FactoryDiscovery::findUriFactory();

Common/Adapter/HttpDiscovery/PsrClientResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static function create(?ClientInterface $client = null): self
1919
return new self($client);
2020
}
2121

22+
#[\Override]
2223
public function resolvePsrClient(): ClientInterface
2324
{
2425
return $this->client ??= Psr18ClientDiscovery::find();

Common/Attribute/AttributeValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class AttributeValidator implements AttributeValidatorInterface
2121
* Validate whether a value is a primitive, or a homogeneous array of primitives (treating int/double as equivalent).
2222
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.21.0/specification/common/README.md#attribute
2323
*/
24+
#[\Override]
2425
public function validate($value): bool
2526
{
2627
if (is_array($value)) {
@@ -51,6 +52,7 @@ private function validateArray(array $value): bool
5152
return true;
5253
}
5354

55+
#[\Override]
5456
public function getInvalidMessage(): string
5557
{
5658
return 'attribute with non-primitive or non-homogeneous array of primitives dropped';

Common/Attribute/Attributes.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,46 @@ public static function factory(?int $attributeCountLimit = null, ?int $attribute
3333
return new AttributesFactory($attributeCountLimit, $attributeValueLengthLimit);
3434
}
3535

36+
#[\Override]
3637
public function has(string $name): bool
3738
{
3839
return array_key_exists($name, $this->attributes);
3940
}
4041

42+
#[\Override]
4143
public function get(string $name)
4244
{
4345
return $this->attributes[$name] ?? null;
4446
}
4547

4648
/** @psalm-mutation-free */
49+
#[\Override]
4750
public function count(): int
4851
{
4952
return \count($this->attributes);
5053
}
5154

55+
#[\Override]
5256
public function jsonSerialize(): mixed
5357
{
5458
return $this->attributes;
5559
}
5660

61+
#[\Override]
5762
public function getIterator(): Traversable
5863
{
5964
foreach ($this->attributes as $key => $value) {
6065
yield (string) $key => $value;
6166
}
6267
}
6368

69+
#[\Override]
6470
public function toArray(): array
6571
{
6672
return $this->attributes;
6773
}
6874

75+
#[\Override]
6976
public function getDroppedAttributesCount(): int
7077
{
7178
return $this->droppedAttributesCount;

Common/Attribute/AttributesBuilder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ public function __construct(private array $attributes, private ?int $attributeCo
2222
{
2323
}
2424

25+
#[\Override]
2526
public function build(): AttributesInterface
2627
{
2728
return new Attributes($this->attributes, $this->droppedAttributesCount);
2829
}
2930

31+
#[\Override]
3032
public function merge(AttributesInterface $old, AttributesInterface $updating): AttributesInterface
3133
{
3234
$new = $old->toArray();
@@ -42,6 +44,7 @@ public function merge(AttributesInterface $old, AttributesInterface $updating):
4244
return new Attributes($new, $dropped);
4345
}
4446

47+
#[\Override]
4548
public function offsetExists($offset): bool
4649
{
4750
return array_key_exists($offset, $this->attributes);
@@ -50,6 +53,7 @@ public function offsetExists($offset): bool
5053
/**
5154
* @phan-suppress PhanUndeclaredClassAttribute
5255
*/
56+
#[\Override]
5357
public function offsetGet($offset): mixed
5458
{
5559
return $this->attributes[$offset] ?? null;
@@ -58,6 +62,7 @@ public function offsetGet($offset): mixed
5862
/**
5963
* @phan-suppress PhanUndeclaredClassAttribute
6064
*/
65+
#[\Override]
6166
public function offsetSet($offset, $value): void
6267
{
6368
if ($offset === null) {
@@ -86,6 +91,7 @@ public function offsetSet($offset, $value): void
8691
/**
8792
* @phan-suppress PhanUndeclaredClassAttribute
8893
*/
94+
#[\Override]
8995
public function offsetUnset($offset): void
9096
{
9197
unset($this->attributes[$offset]);

Common/Attribute/AttributesFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function __construct(
1515
) {
1616
}
1717

18+
#[\Override]
1819
public function builder(iterable $attributes = [], ?AttributeValidatorInterface $attributeValidator = null): AttributesBuilderInterface
1920
{
2021
$builder = new AttributesBuilder(

Common/Attribute/LogRecordAttributeValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
class LogRecordAttributeValidator implements AttributeValidatorInterface
88
{
9+
#[\Override]
910
public function validate($value): bool
1011
{
1112
return true;
1213
}
1314

15+
#[\Override]
1416
public function getInvalidMessage(): string
1517
{
1618
//not required as this validator always returns true

Common/Configuration/EnvComponentLoaderRegistry.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function register(EnvComponentLoader $loader): EnvComponentLoaderRegistry
4141
return $this;
4242
}
4343

44+
#[\Override]
4445
public function load(string $type, string $name, EnvResolver $env, Context $context): mixed
4546
{
4647
if (!$loader = $this->loaders[$type][$name] ?? null) {

0 commit comments

Comments
 (0)