Skip to content

Commit 56026f8

Browse files
authored
drop php 8.0 support (#1256)
* bump php to 8.1, apply rector * readonly and typehints * suppress a dodgy readonly property conversion * remove some redundant readonly phpdocs * dont run workflows against 8.0 * more readonly and typehints * phpdoc reformat * typehints * remove php81 polyfill * revert a rector BC breaking change, and disable that rector for ParentBased
1 parent 8c79e06 commit 56026f8

9 files changed

+23
-49
lines changed

Context.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ final class Context implements ContextInterface
1616
{
1717
private const OTEL_PHP_DEBUG_SCOPES_DISABLED = 'OTEL_PHP_DEBUG_SCOPES_DISABLED';
1818

19-
/** @var ContextStorageInterface&ExecutionContextAwareInterface */
20-
private static ContextStorageInterface $storage;
19+
private static ContextStorageInterface&ExecutionContextAwareInterface $storage;
2120

2221
// Optimization for spans to avoid copying the context array.
2322
private static ContextKeyInterface $spanContextKey;
@@ -37,20 +36,12 @@ public static function createKey(string $key): ContextKeyInterface
3736
return new ContextKey($key);
3837
}
3938

40-
/**
41-
* @param ContextStorageInterface&ExecutionContextAwareInterface $storage
42-
* @todo update type-hint (php >= 8.1)
43-
*/
44-
public static function setStorage(ContextStorageInterface $storage): void
39+
public static function setStorage(ContextStorageInterface&ExecutionContextAwareInterface $storage): void
4540
{
4641
self::$storage = $storage;
4742
}
4843

49-
/**
50-
* @return ContextStorageInterface&ExecutionContextAwareInterface
51-
* @todo update return type-hint (php >= 8.1)
52-
*/
53-
public static function storage(): ContextStorageInterface
44+
public static function storage(): ContextStorageInterface&ExecutionContextAwareInterface
5445
{
5546
/** @psalm-suppress RedundantPropertyInitializationCheck */
5647
return self::$storage ??= new ContextStorage();

ContextKey.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
final class ContextKey implements ContextKeyInterface
1212
{
13-
public function __construct(private ?string $name = null)
13+
public function __construct(private readonly ?string $name = null)
1414
{
1515
}
1616

ContextStorage.php

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

22-
public function fork($id): void
22+
public function fork(int|string $id): void
2323
{
2424
$this->forks[$id] = clone $this->current;
2525
}
2626

27-
public function switch($id): void
27+
public function switch(int|string $id): void
2828
{
2929
$this->current = $this->forks[$id] ?? $this->main;
3030
}
3131

32-
public function destroy($id): void
32+
public function destroy(int|string $id): void
3333
{
3434
unset($this->forks[$id]);
3535
}

DebugScope.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ final class DebugScope implements ScopeInterface
2424
{
2525
private static bool $shutdownHandlerInitialized = false;
2626
private static bool $finalShutdownPhase = false;
27-
private ?int $fiberId;
28-
private array $createdAt;
27+
private readonly ?int $fiberId;
28+
private readonly array $createdAt;
2929
private ?array $detachedAt = null;
3030

31-
public function __construct(private ContextStorageScopeInterface $scope)
31+
public function __construct(private readonly ContextStorageScopeInterface $scope)
3232
{
3333
$this->fiberId = self::currentFiberId();
3434
$this->createdAt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
@@ -114,7 +114,7 @@ private static function formatBacktrace(array $trace): string
114114
$s .= strtr($trace[$i]['function'] ?? '{main}', ['\\' => '.']);
115115
$s .= '(';
116116
if (isset($trace[$i - 1]['file'])) {
117-
$s .= basename($trace[$i - 1]['file']);
117+
$s .= basename((string) $trace[$i - 1]['file']);
118118
if (isset($trace[$i - 1]['line'])) {
119119
$s .= ':';
120120
$s .= $trace[$i - 1]['line'];

ExecutionContextAwareInterface.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,9 @@
66

77
interface ExecutionContextAwareInterface
88
{
9-
/**
10-
* @param int|string $id
11-
*/
12-
public function fork($id): void;
9+
public function fork(int|string $id): void;
1310

14-
/**
15-
* @param int|string $id
16-
*/
17-
public function switch($id): void;
11+
public function switch(int|string $id): void;
1812

19-
/**
20-
* @param int|string $id
21-
*/
22-
public function destroy($id): void;
13+
public function destroy(int|string $id): void;
2314
}

FiberBoundContextStorage.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,21 @@
2020
*/
2121
final class FiberBoundContextStorage implements ContextStorageInterface, ExecutionContextAwareInterface
2222
{
23-
/**
24-
* @param ContextStorageInterface&ExecutionContextAwareInterface $storage
25-
*/
26-
public function __construct(private ContextStorageInterface $storage)
23+
public function __construct(private readonly ContextStorageInterface&ExecutionContextAwareInterface $storage)
2724
{
2825
}
2926

30-
public function fork($id): void
27+
public function fork(int|string $id): void
3128
{
3229
$this->storage->fork($id);
3330
}
3431

35-
public function switch($id): void
32+
public function switch(int|string $id): void
3633
{
3734
$this->storage->switch($id);
3835
}
3936

40-
public function destroy($id): void
37+
public function destroy(int|string $id): void
4138
{
4239
$this->storage->destroy($id);
4340
}

Propagation/MultiTextMapPropagator.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@
1313

1414
final class MultiTextMapPropagator implements TextMapPropagatorInterface
1515
{
16-
/**
17-
* @readonly
18-
* @var list<string>
19-
*/
20-
private array $fields;
16+
/** @var list<string> */
17+
private readonly array $fields;
2118

2219
/**
2320
* @no-named-arguments
2421
*
2522
* @param list<TextMapPropagatorInterface> $propagators
2623
*/
2724
public function __construct(
28-
/** @readonly */
29-
private array $propagators,
25+
private readonly array $propagators,
3026
) {
3127
$this->fields = $this->extractFields($this->propagators);
3228
}

Propagation/SanitizeCombinedHeadersPropagationGetter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ 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-
public function __construct(private PropagationGetterInterface $getter)
21+
public function __construct(private readonly PropagationGetterInterface $getter)
2222
{
2323
}
2424

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^8.0",
21-
"symfony/polyfill-php81": "^1.26",
20+
"php": "^8.1",
2221
"symfony/polyfill-php82": "^1.26"
2322
},
2423
"autoload": {

0 commit comments

Comments
 (0)