Skip to content

Conversation

@amulet1
Copy link
Collaborator

@amulet1 amulet1 commented Dec 28, 2025

There is a possibility that some named parameters for init() would be omitted when passed to addVariable()/addHidden()/insertVariableBefore().

Suppose we have this:

function init(...$params) {
   $parm1 = $params[0];
   $parm2 = $params[1];
   ...
}

Calling addVariable() with $params = [ 'parm1' => 'abc', 'parm2' => 123 ] results in init(...$params) called with $params = [ 0 => 'abc', 1 => 123 ], which is correct.

But if parm1 is omitted, i.e. $params = [ 'parm2' => 123 ], then init(...$params) would be called with $params = [ 1 => 123 ]. However PHP converts this internally to $params = [ 0 => 123 ], which results in the wrong parameter assignment - parm1 (not parm2) gets assigned 123.

This PR addresses handling of omitted parameters (we do not seem to have cases like that though) by making sure indexes for such parameters exist.

With this PR the params in the previous example becomes [ 0 => null, 1 => 123 ], which fixes the issue.

@amulet1 amulet1 requested a review from TDannhauer December 28, 2025 15:43
@amulet1 amulet1 self-assigned this Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants