forked from open-telemetry/opentelemetry-php-instrumentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpand_params_extra.phpt
32 lines (31 loc) · 916 Bytes
/
expand_params_extra.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--TEST--
Check if pre hook can expand params of function with extra parameters not provided by call site
--DESCRIPTION--
Extra parameters for user functions are parameters that were provided at call site but were not present in the function
declaration. The extension only supports modifying existing ones, not adding new ones. Test that a warning is logged if
adding new ones is attempted and that it does not crash.
--EXTENSIONS--
opentelemetry
--FILE--
<?php
OpenTelemetry\Instrumentation\hook(
null,
'helloWorld',
pre: function($instance, array $params) {
return [$params[0], 'b', 'c', 'd'];
},
post: fn() => null
);
function helloWorld($a, $b) {
var_dump(func_get_args());
}
helloWorld('a');
?>
--EXPECTF--
Warning: helloWorld(): OpenTelemetry: pre hook invalid argument index 2, class=null function=helloWorld in %s
array(2) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
}