Skip to content

Commit 1b96fdb

Browse files
committed
File::getMethodParameters(): fix incorrect $typeHintEndToken
Given the following code sample: ```php function foo( ?bool $a, $b ) {} ``` In the resulting array, the second parameter `$b` will have the 'type_hint_end_token' set to the stack pointer for the end of the type declaration for `$a`. Caused by the `$typeHintEndToken` not being reset for the next parameter. I've re-ordered the variable reset now to be the same as the order used for the initial variable declarations before the loop to make it more obvious. While not necessarily a bug, the `$currVar` variable was also not being reset. That's also been fixed now. I've not added a unit test as the existing tests do not check the token positions in the array.
1 parent 200eae5 commit 1b96fdb

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/Files/File.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,16 +1496,18 @@ public function getMethodParameters($stackPtr)
14961496
}
14971497

14981498
// Reset the vars, as we are about to process the next parameter.
1499-
$defaultStart = null;
1500-
$equalToken = null;
1501-
$paramStart = ($i + 1);
1502-
$passByReference = false;
1503-
$referenceToken = false;
1504-
$variableLength = false;
1505-
$variadicToken = false;
1506-
$typeHint = '';
1507-
$typeHintToken = false;
1508-
$nullableType = false;
1499+
$currVar = null;
1500+
$paramStart = ($i + 1);
1501+
$defaultStart = null;
1502+
$equalToken = null;
1503+
$passByReference = false;
1504+
$referenceToken = false;
1505+
$variableLength = false;
1506+
$variadicToken = false;
1507+
$typeHint = '';
1508+
$typeHintToken = false;
1509+
$typeHintEndToken = false;
1510+
$nullableType = false;
15091511

15101512
$paramCount++;
15111513
break;

0 commit comments

Comments
 (0)