Skip to content

Commit a4ff214

Browse files
authored
Drop support for PHP 7.4 and 8.0, introduce support for PHP 8.4, fix semconv deprecations (#315)
* Fixed a bit of warnings and deprecations * Dropped support for PHP 7.4 and 8.0. Introduced support for PHP 8.4 * Set revision psalm to 6.4.0, more suppressions * Curl instrumentation fix * updated packages generating deprecated warnings
1 parent 2a4b89b commit a4ff214

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"minimum-stability": "dev",
1010
"prefer-stable": true,
1111
"require": {
12-
"php": "^8.0",
12+
"php": "^8.1",
1313
"ext-opentelemetry": "*",
1414
"ext-reflection": "*",
1515
"open-telemetry/api": "^1.0",
@@ -27,10 +27,10 @@
2727
"phpstan/phpstan-mockery": "^1.1.0",
2828
"phpstan/phpstan": "^1.1",
2929
"phpstan/phpstan-phpunit": "^1.0",
30-
"psalm/plugin-phpunit": "^0.18.4",
30+
"psalm/plugin-phpunit": "^0.19.2",
3131
"open-telemetry/sdk": "^1.0",
3232
"phpunit/phpunit": "^9.5",
33-
"vimeo/psalm": "^5.0"
33+
"vimeo/psalm": "6.4.0"
3434
},
3535
"autoload": {
3636
"psr-4": {

src/CallableFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public static function format($callable): string
2222
if ($callable instanceof Closure || (is_string($callable) && function_exists($callable))) {
2323
$reflection = new ReflectionFunction($callable);
2424
$name = $reflection->getShortName();
25-
if ($name === '{closure}') {
26-
return $name;
25+
if ((PHP_VERSION_ID < 80400 && $name === '{closure}') || (PHP_VERSION_ID >= 80400 && str_contains($name, '{closure:'))) {
26+
return '{closure}';
2727
}
2828
$class = $reflection->getClosureScopeClass()?->getName() ?? '';
2929
if ($reflection->getClosureScopeClass()?->isAnonymous()) {

src/PsrResponsePropagationSetter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static function instance(): self
2121
return $instance ??= new self();
2222
}
2323

24+
/** @psalm-suppress PossiblyUnusedMethod */
2425
public function keys($carrier): array
2526
{
2627
assert($carrier instanceof ResponseInterface);

src/SlimInstrumentation.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Slim\Routing\RouteContext;
2323
use Throwable;
2424

25+
/** @psalm-suppress UnusedClass */
2526
class SlimInstrumentation
2627
{
2728
public const NAME = 'slim';
@@ -39,8 +40,10 @@ public static function register(): void
3940
* requires extension >= 1.0.2beta2
4041
* @see https://github.com/open-telemetry/opentelemetry-php-instrumentation/pull/136
4142
*/
42-
self::$supportsResponsePropagation = version_compare(phpversion('opentelemetry'), '1.0.2beta2') >= 0;
43+
$otelVersion = phpversion('opentelemetry');
44+
self::$supportsResponsePropagation = $otelVersion !== false && version_compare($otelVersion, '1.0.2beta2') >= 0;
4345

46+
/** @psalm-suppress UnusedFunctionCall */
4447
hook(
4548
App::class,
4649
'handle',
@@ -122,6 +125,7 @@ public static function register(): void
122125
* If routing fails (eg 404/not found), then the root span name will not be updated.
123126
*
124127
* @psalm-suppress ArgumentTypeCoercion
128+
* @psalm-suppress UnusedFunctionCall
125129
*/
126130
hook(
127131
RoutingMiddleware::class,
@@ -148,6 +152,7 @@ public static function register(): void
148152
* Create a span for Slim route's action/controller/callable
149153
*
150154
* @psalm-suppress ArgumentTypeCoercion
155+
* @psalm-suppress UnusedFunctionCall
151156
*/
152157
hook(
153158
InvocationStrategyInterface::class,

tests/Integration/SlimInstrumentationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ public function performRouting(ServerRequestInterface $request): ServerRequestIn
136136

137137
public function test_response_propagation(): void
138138
{
139-
if (version_compare(phpversion('opentelemetry'), '1.0.2beta2') < 0) {
139+
$otelVersion = phpversion('opentelemetry');
140+
if ($otelVersion == false || version_compare($otelVersion, '1.0.2beta2') < 0) {
140141
$this->markTestSkipped('response propagation requires opentelemetry extension >= 1.0.2beta2');
141142
}
142143
$request = (new ServerRequest('GET', 'https://example.com/foo'));

tests/Unit/CallableFormatterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ class TestClass
8383
public function __invoke()
8484
{
8585
}
86+
/** @psalm-suppress PossiblyUnusedMethod */
8687
public function method()
8788
{
8889
}
90+
/** @psalm-suppress PossiblyUnusedMethod */
8991
public static function staticMethod()
9092
{
9193
}

0 commit comments

Comments
 (0)