Skip to content

Commit 0f2715e

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 1eb2b83 commit 0f2715e

12 files changed

+56
-0
lines changed

Context.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ private function __construct()
3131
self::$spanContextKey = ContextKeys::span();
3232
}
3333

34+
#[\Override]
3435
public static function createKey(string $key): ContextKeyInterface
3536
{
3637
return new ContextKey($key);
@@ -67,11 +68,13 @@ public static function getRoot(): ContextInterface
6768
return $empty ??= new self();
6869
}
6970

71+
#[\Override]
7072
public static function getCurrent(): ContextInterface
7173
{
7274
return self::storage()->current();
7375
}
7476

77+
#[\Override]
7578
public function activate(): ScopeInterface
7679
{
7780
$scope = self::storage()->attach($this);
@@ -89,11 +92,13 @@ private static function debugScopesDisabled(): bool
8992
);
9093
}
9194

95+
#[\Override]
9296
public function withContextValue(ImplicitContextKeyedInterface $value): ContextInterface
9397
{
9498
return $value->storeInContext($this);
9599
}
96100

101+
#[\Override]
97102
public function with(ContextKeyInterface $key, $value): self
98103
{
99104
if ($this->get($key) === $value) {
@@ -122,6 +127,7 @@ public function with(ContextKeyInterface $key, $value): self
122127
return $self;
123128
}
124129

130+
#[\Override]
125131
public function get(ContextKeyInterface $key)
126132
{
127133
if ($key === self::$spanContextKey) {

ContextStorage.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,45 @@ public function __construct()
1919
$this->current = $this->main = new ContextStorageHead($this);
2020
}
2121

22+
#[\Override]
2223
public function fork(int|string $id): void
2324
{
2425
$this->forks[$id] = clone $this->current;
2526
}
2627

28+
#[\Override]
2729
public function switch(int|string $id): void
2830
{
2931
$this->current = $this->forks[$id] ?? $this->main;
3032
}
3133

34+
#[\Override]
3235
public function destroy(int|string $id): void
3336
{
3437
unset($this->forks[$id]);
3538
}
3639

40+
#[\Override]
3741
public function head(): ContextStorageHead
3842
{
3943
return $this->current;
4044
}
4145

46+
#[\Override]
4247
public function scope(): ?ContextStorageScopeInterface
4348
{
4449
return ($this->current->node->head ?? null) === $this->current
4550
? $this->current->node
4651
: null;
4752
}
4853

54+
#[\Override]
4955
public function current(): ContextInterface
5056
{
5157
return $this->current->node->context ?? Context::getRoot();
5258
}
5359

60+
#[\Override]
5461
public function attach(ContextInterface $context): ContextStorageScopeInterface
5562
{
5663
return $this->current->node = new ContextStorageNode($context, $this->current, $this->current->node);

ContextStorageNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,37 @@ public function __construct(
2020
) {
2121
}
2222

23+
#[\Override]
2324
public function offsetExists(mixed $offset): bool
2425
{
2526
return isset($this->localStorage[$offset]);
2627
}
2728

29+
#[\Override]
2830
public function offsetGet(mixed $offset): mixed
2931
{
3032
return $this->localStorage[$offset];
3133
}
3234

35+
#[\Override]
3336
public function offsetSet(mixed $offset, mixed $value): void
3437
{
3538
$this->localStorage[$offset] = $value;
3639
}
3740

41+
#[\Override]
3842
public function offsetUnset(mixed $offset): void
3943
{
4044
unset($this->localStorage[$offset]);
4145
}
4246

47+
#[\Override]
4348
public function context(): ContextInterface
4449
{
4550
return $this->context;
4651
}
4752

53+
#[\Override]
4854
public function detach(): int
4955
{
5056
$flags = 0;

ContextStorageScopeInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ public function context(): ContextInterface;
2121
/**
2222
* @param string $offset
2323
*/
24+
#[\Override]
2425
public function offsetSet($offset, $value): void;
2526
}

DebugScope.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function __construct(private readonly ContextStorageScopeInterface $scope
3939
}
4040
}
4141

42+
#[\Override]
4243
public function detach(): int
4344
{
4445
$this->detachedAt ??= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);

FiberBoundContextStorage.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ public function __construct()
2626
$this->heads[$this] = new ContextStorageHead($this);
2727
}
2828

29+
#[\Override]
2930
public function head(): ?ContextStorageHead
3031
{
3132
return $this->heads[Fiber::getCurrent() ?? $this] ?? null;
3233
}
3334

35+
/**
36+
* @psalm-suppress PossiblyNullPropertyFetch
37+
*/
38+
#[\Override]
3439
public function scope(): ?ContextStorageScopeInterface
3540
{
3641
$head = $this->heads[Fiber::getCurrent() ?? $this] ?? null;
@@ -45,6 +50,7 @@ public function scope(): ?ContextStorageScopeInterface
4550
return $head->node;
4651
}
4752

53+
#[\Override]
4854
public function current(): ContextInterface
4955
{
5056
$head = $this->heads[Fiber::getCurrent() ?? $this] ?? null;
@@ -59,6 +65,10 @@ public function current(): ContextInterface
5965
return $head->node->context ?? Context::getRoot();
6066
}
6167

68+
/**
69+
* @psalm-suppress PossiblyNullArgument,PossiblyNullPropertyFetch
70+
*/
71+
#[\Override]
6272
public function attach(ContextInterface $context): ContextStorageScopeInterface
6373
{
6474
$head = $this->heads[Fiber::getCurrent() ?? $this] ??= new ContextStorageHead($this);

FiberBoundContextStorageExecutionAwareBC.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ public function __construct()
1717
$this->storage = new FiberBoundContextStorage();
1818
}
1919

20+
#[\Override]
2021
public function fork(int|string $id): void
2122
{
2223
$this->bcStorage()->fork($id);
2324
}
2425

26+
#[\Override]
2527
public function switch(int|string $id): void
2628
{
2729
$this->bcStorage()->switch($id);
2830
}
2931

32+
#[\Override]
3033
public function destroy(int|string $id): void
3134
{
3235
$this->bcStorage()->destroy($id);
@@ -51,20 +54,23 @@ private function bcStorage(): ContextStorage
5154
return $this->bc;
5255
}
5356

57+
#[\Override]
5458
public function scope(): ?ContextStorageScopeInterface
5559
{
5660
return $this->bc
5761
? $this->bc->scope()
5862
: $this->storage->scope();
5963
}
6064

65+
#[\Override]
6166
public function current(): ContextInterface
6267
{
6368
return $this->bc
6469
? $this->bc->current()
6570
: $this->storage->current();
6671
}
6772

73+
#[\Override]
6874
public function attach(ContextInterface $context): ContextStorageScopeInterface
6975
{
7076
return $this->bc

Propagation/ArrayAccessGetterSetter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static function getInstance(): self
3636
}
3737

3838
/** {@inheritdoc} */
39+
#[\Override]
3940
public function keys($carrier): array
4041
{
4142
if ($this->isSupportedCarrier($carrier)) {
@@ -56,6 +57,7 @@ public function keys($carrier): array
5657
}
5758

5859
/** {@inheritdoc} */
60+
#[\Override]
5961
public function get($carrier, string $key): ?string
6062
{
6163
if ($this->isSupportedCarrier($carrier)) {
@@ -79,6 +81,7 @@ public function get($carrier, string $key): ?string
7981
}
8082

8183
/** {@inheritdoc} */
84+
#[\Override]
8285
public function getAll($carrier, string $key): array
8386
{
8487
if ($this->isSupportedCarrier($carrier)) {
@@ -102,6 +105,7 @@ public function getAll($carrier, string $key): array
102105
}
103106

104107
/** {@inheritdoc} */
108+
#[\Override]
105109
public function set(&$carrier, string $key, string $value): void
106110
{
107111
if ($key === '') {

Propagation/MultiTextMapPropagator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ public function __construct(
2727
$this->fields = $this->extractFields($this->propagators);
2828
}
2929

30+
#[\Override]
3031
public function fields(): array
3132
{
3233
return $this->fields;
3334
}
3435

36+
#[\Override]
3537
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
3638
{
3739
foreach ($this->propagators as $propagator) {
3840
$propagator->inject($carrier, $setter, $context);
3941
}
4042
}
4143

44+
#[\Override]
4245
public function extract($carrier, ?PropagationGetterInterface $getter = null, ?ContextInterface $context = null): ContextInterface
4346
{
4447
$context ??= Context::getCurrent();

Propagation/NoopTextMapPropagator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ public static function getInstance(): self
2020
return self::$instance;
2121
}
2222

23+
#[\Override]
2324
public function fields(): array
2425
{
2526
return [];
2627
}
2728

29+
#[\Override]
2830
public function extract($carrier, ?PropagationGetterInterface $getter = null, ?ContextInterface $context = null): ContextInterface
2931
{
3032
return $context ?? Context::getCurrent();
3133
}
3234

35+
#[\Override]
3336
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
3437
{
3538
}

0 commit comments

Comments
 (0)