Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 3f7c093

Browse files
authored
Fix variable argument parsing. func_get_arg is 0-indexed (#34)
1 parent dc443e4 commit 3f7c093

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/Trace/Integrations/Mysql.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function load()
5757
if (func_num_args() > 2) {
5858
return [
5959
'labels' => [
60-
'name' => func_get_arg(3)
60+
'name' => func_get_arg(2)
6161
]
6262
];
6363
} else {
@@ -99,7 +99,7 @@ public static function load()
9999
if (func_num_args() > 1) {
100100
return [
101101
'labels' => [
102-
'name' => func_get_arg(2)
102+
'name' => func_get_arg(1)
103103
]
104104
];
105105
} else {

src/Trace/Integrations/Postgres.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public static function load()
4141
// resource pg_query([resource $connection], string $query)
4242
opencensus_trace_function('pg_query', function () {
4343
$query = func_num_args() > 1
44-
? func_get_arg(2)
45-
: func_get_arg(1);
44+
? func_get_arg(1)
45+
: func_get_arg(0);
4646
return [
4747
'labels' => ['query' => $query]
4848
];
@@ -51,8 +51,8 @@ public static function load()
5151
// resource pg_query_params([resource $connection], $string $query, array $params)
5252
opencensus_trace_function('pg_query_params', function () {
5353
$query = func_num_args() > 2
54-
? func_get_arg(2)
55-
: func_get_arg(1);
54+
? func_get_arg(1)
55+
: func_get_arg(0);
5656
return [
5757
'labels' => ['query' => $query]
5858
];
@@ -61,8 +61,8 @@ public static function load()
6161
// resource pg_execute([resource $connection], string $stmtname, array $params)
6262
opencensus_trace_function('pg_execute', function () {
6363
$statementName = func_num_args() > 2
64-
? func_get_arg(2)
65-
: func_get_arg(1);
64+
? func_get_arg(1)
65+
: func_get_arg(0);
6666
return [
6767
'labels' => ['statement' => $statementName]
6868
];

src/Trace/Integrations/Wordpress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function load()
3737
$nameClosure = function () {
3838
if (func_num_args() > 0) {
3939
return [
40-
'labels' => ['name' => func_get_arg(1)]
40+
'labels' => ['name' => func_get_arg(0)]
4141
];
4242
}
4343
return [];

0 commit comments

Comments
 (0)