Skip to content

Commit

Permalink
fix 2 tests for PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
andypost committed Sep 5, 2024
1 parent 0b76126 commit 51dde44
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/tests/post_hook_returns_cloned_modified_object.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ opentelemetry
class Foo
{
public ?string $a = null;
public function __construct(string $a = null)
public function __construct(string|null $a = null)
{
$this->a = $a;
}
Expand Down
2 changes: 1 addition & 1 deletion ext/tests/span_attribute/function_params_non_simple.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Check if function non-simple types can be passed as function params
--SKIPIF--
<?php if (PHP_VERSION_ID < 80100) die('skip requires PHP >= 8.1'); ?>
<?php if (PHP_VERSION_ID < 80100 | PHP_VERSION_ID >= 80400) die('skip requires PHP >= 8.1 but < 8.4'); ?>
--EXTENSIONS--
opentelemetry
--INI--
Expand Down
61 changes: 61 additions & 0 deletions ext/tests/span_attribute/function_params_non_simple_84.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
--TEST--
Check if function non-simple types can be passed as function params
--SKIPIF--
<?php if (PHP_VERSION_ID < 80400) die('skip requires PHP >= 8.4O'); ?>
--EXTENSIONS--
opentelemetry
--INI--
opentelemetry.attr_hooks_enabled = On
--FILE--
<?php
namespace OpenTelemetry\API\Instrumentation;

include dirname(__DIR__) . '/mocks/WithSpan.php';
include dirname(__DIR__) . '/mocks/SpanAttribute.php';
include dirname(__DIR__) . '/mocks/WithSpanHandlerDumpAttributes.php';
use OpenTelemetry\API\Instrumentation\WithSpan;
use OpenTelemetry\API\Instrumentation\SpanAttribute;

#[WithSpan]
function foo(
#[SpanAttribute] array $one,
#[SpanAttribute] object $two,
#[SpanAttribute] callable $three,
#[SpanAttribute] $four,
): void
{
var_dump('foo');
}

foo(
['foo' => 'bar'],
new \stdClass(),
function(){return 'fn';},
null,
);
?>
--EXPECTF--
string(3) "pre"
array(4) {
["one"]=>
array(1) {
["foo"]=>
string(3) "bar"
}
["two"]=>
object(stdClass)#1 (0) {
}
["three"]=>
object(Closure)#2 (3) {
["name"]=>
string(%s) "{closure:/%s/tests/span_attribute/function_params_non_simple_84.php:24}"
["file"]=>
string(%s) "/%s/tests/span_attribute/function_params_non_simple_84.php"
["line"]=>
int(24)
}
["four"]=>
NULL
}
string(3) "foo"
string(4) "post"

0 comments on commit 51dde44

Please sign in to comment.