Skip to content

Commit a4df4cf

Browse files
authored
Drop PHP 7.4 support (#1244)
* drop php 7.4 support update composer.json minimums, and run rector over the code to update what it can. changed some static analysis config to fix some rector-induced failures. * adding union typehints * reformat constructor property promotions * updating/removing phpdoc * suppress protobuf extension complaint submitted a PR upstream to fix phan stubs * don't validate packages against 7.4 * remove php8 polyfill * fix readonly comments * apply trailing commas to multiline fixer upgrade php-cs-fixer, and apply a new rule for multiline comments * remove unreachable default match arms for protobuf serializer * adding more union types to vars * use weakmap directly * remove handling for not-supported WeakMap * spacing
1 parent 0530e5d commit a4df4cf

12 files changed

+24
-61
lines changed

Context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static function createKey(string $key): ContextKeyInterface
3939

4040
/**
4141
* @param ContextStorageInterface&ExecutionContextAwareInterface $storage
42+
* @todo update type-hint (php >= 8.1)
4243
*/
4344
public static function setStorage(ContextStorageInterface $storage): void
4445
{
@@ -47,6 +48,7 @@ public static function setStorage(ContextStorageInterface $storage): void
4748

4849
/**
4950
* @return ContextStorageInterface&ExecutionContextAwareInterface
51+
* @todo update return type-hint (php >= 8.1)
5052
*/
5153
public static function storage(): ContextStorageInterface
5254
{
@@ -55,11 +57,9 @@ public static function storage(): ContextStorageInterface
5557
}
5658

5759
/**
58-
* @param ContextInterface|false|null $context
59-
*
6060
* @internal OpenTelemetry
6161
*/
62-
public static function resolve($context, ?ContextStorageInterface $contextStorage = null): ContextInterface
62+
public static function resolve(ContextInterface|false|null $context, ?ContextStorageInterface $contextStorage = null): ContextInterface
6363
{
6464
return $context
6565
?? ($contextStorage ?? self::storage())->current()

ContextKey.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
*/
1010
final class ContextKey implements ContextKeyInterface
1111
{
12-
private ?string $name;
13-
14-
public function __construct(?string $name=null)
12+
public function __construct(private ?string $name = null)
1513
{
16-
$this->name = $name;
1714
}
1815

1916
public function name(): ?string

ContextStorageHead.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
*/
1010
final class ContextStorageHead
1111
{
12-
public ContextStorage $storage;
1312
public ?ContextStorageNode $node = null;
1413

15-
public function __construct(ContextStorage $storage)
14+
public function __construct(public ContextStorage $storage)
1615
{
17-
$this->storage = $storage;
1816
}
1917
}

ContextStorageNode.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@
1111
*/
1212
final class ContextStorageNode implements ScopeInterface, ContextStorageScopeInterface
1313
{
14-
public ContextInterface $context;
15-
public ContextStorageHead $head;
16-
private ?ContextStorageNode $previous;
1714
private array $localStorage = [];
1815

1916
public function __construct(
20-
ContextInterface $context,
21-
ContextStorageHead $head,
22-
?ContextStorageNode $previous = null
17+
public ContextInterface $context,
18+
public ContextStorageHead $head,
19+
private ?ContextStorageNode $previous = null,
2320
) {
24-
$this->context = $context;
25-
$this->head = $head;
26-
$this->previous = $previous;
2721
}
2822

2923
public function offsetExists($offset): bool
@@ -76,8 +70,8 @@ public function detach(): int
7670

7771
assert($this->head->node !== null);
7872
for ($n = $this->head->node, $depth = 1;
79-
$n->previous !== $this;
80-
$n = $n->previous, $depth++) {
73+
$n->previous !== $this;
74+
$n = $n->previous, $depth++) {
8175
assert($n->previous !== null);
8276
}
8377
$n->previous = $this->previous;

DebugScope.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@ final class DebugScope implements ScopeInterface
2424
{
2525
private static bool $shutdownHandlerInitialized = false;
2626
private static bool $finalShutdownPhase = false;
27-
28-
private ContextStorageScopeInterface $scope;
2927
private ?int $fiberId;
3028
private array $createdAt;
3129
private ?array $detachedAt = null;
3230

33-
public function __construct(ContextStorageScopeInterface $scope)
31+
public function __construct(private ContextStorageScopeInterface $scope)
3432
{
35-
$this->scope = $scope;
3633
$this->fiberId = self::currentFiberId();
3734
$this->createdAt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
3835

FiberBoundContextStorage.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@
2020
*/
2121
final class FiberBoundContextStorage implements ContextStorageInterface, ExecutionContextAwareInterface
2222
{
23-
/** @var ContextStorageInterface&ExecutionContextAwareInterface */
24-
private ContextStorageInterface $storage;
25-
2623
/**
2724
* @param ContextStorageInterface&ExecutionContextAwareInterface $storage
2825
*/
29-
public function __construct(ContextStorageInterface $storage)
26+
public function __construct(private ContextStorageInterface $storage)
3027
{
31-
$this->storage = $storage;
3228
}
3329

3430
public function fork($id): void

FiberBoundContextStorageScope.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
*/
1919
final class FiberBoundContextStorageScope implements ScopeInterface, ContextStorageScopeInterface
2020
{
21-
private ContextStorageScopeInterface $scope;
22-
23-
public function __construct(ContextStorageScopeInterface $scope)
21+
public function __construct(private ContextStorageScopeInterface $scope)
2422
{
25-
$this->scope = $scope;
2623
}
2724

2825
public function offsetExists($offset): bool

Propagation/ArrayAccessGetterSetter.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66

77
use function array_key_first;
88
use ArrayAccess;
9-
use function get_class;
10-
use function gettype;
119
use InvalidArgumentException;
1210
use function is_array;
13-
use function is_object;
1411
use function is_string;
1512
use function sprintf;
1613
use function strcasecmp;
@@ -53,7 +50,7 @@ public function keys($carrier): array
5350
throw new InvalidArgumentException(
5451
sprintf(
5552
'Unsupported carrier type: %s.',
56-
is_object($carrier) ? get_class($carrier) : gettype($carrier),
53+
get_debug_type($carrier),
5754
)
5855
);
5956
}
@@ -75,7 +72,7 @@ public function get($carrier, string $key): ?string
7572
throw new InvalidArgumentException(
7673
sprintf(
7774
'Unsupported carrier type: %s. Unable to get value associated with key:%s',
78-
is_object($carrier) ? get_class($carrier) : gettype($carrier),
75+
get_debug_type($carrier),
7976
$key
8077
)
8178
);
@@ -100,7 +97,7 @@ public function set(&$carrier, string $key, string $value): void
10097
throw new InvalidArgumentException(
10198
sprintf(
10299
'Unsupported carrier type: %s. Unable to set value associated with key:%s',
103-
is_object($carrier) ? get_class($carrier) : gettype($carrier),
100+
get_debug_type($carrier),
104101
$key
105102
)
106103
);

Propagation/MultiTextMapPropagator.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ final class MultiTextMapPropagator implements TextMapPropagatorInterface
1515
{
1616
/**
1717
* @readonly
18-
*
19-
* @var list<TextMapPropagatorInterface>
20-
*/
21-
private array $propagators = [];
22-
23-
/**
24-
* @readonly
25-
*
2618
* @var list<string>
2719
*/
2820
private array $fields;
@@ -32,10 +24,11 @@ final class MultiTextMapPropagator implements TextMapPropagatorInterface
3224
*
3325
* @param list<TextMapPropagatorInterface> $propagators
3426
*/
35-
public function __construct(array $propagators)
36-
{
37-
$this->propagators = $propagators;
38-
$this->fields = $this->extractFields($propagators);
27+
public function __construct(
28+
/** @readonly */
29+
private array $propagators,
30+
) {
31+
$this->fields = $this->extractFields($this->propagators);
3932
}
4033

4134
public function fields(): array

Propagation/SanitizeCombinedHeadersPropagationGetter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ final class SanitizeCombinedHeadersPropagationGetter implements PropagationGette
1818
private const SERVER_CONCAT_HEADERS_REGEX = '/;(?=[^,=;]*=|$)/';
1919
private const TRAILING_LEADING_SEPARATOR_REGEX = '/^' . self::LIST_MEMBERS_SEPARATOR . '+|' . self::LIST_MEMBERS_SEPARATOR . '+$/';
2020

21-
private PropagationGetterInterface $getter;
22-
23-
public function __construct(PropagationGetterInterface $getter)
21+
public function __construct(private PropagationGetterInterface $getter)
2422
{
25-
$this->getter = $getter;
2623
}
2724

2825
public function keys($carrier): array

0 commit comments

Comments
 (0)