Skip to content

Commit

Permalink
PHP 8.1 | PassedParameters::getParameters(): document test with named…
Browse files Browse the repository at this point in the history
… params after argument unpacking

Prior to PHP 8.1, using named arguments after a variadic argument in a function call was a compile error.
As of PHP 8.1, this is now fully supported.

The tests already contained a code sample covering this. The documentation for the test case has now been adjusted.

Refs:
* https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.core.named-arg-after-unpack
  • Loading branch information
jrfnl committed Oct 15, 2022
1 parent ebcd67c commit 190a5e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Tests/Utils/PassedParameters/GetParametersNamedTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ test(param: 1, param: 2);
// Error Exception, but not the concern of PHPCSUtils. Should still be handled.
array_fill(start_index: 0, ...[100, 50]);

/* testCompileErrorIncorrectOrderWithVariadic */
// Not the concern of PHPCSUtils. Should still be handled.
/* testPHP81NamedParamAfterVariadic */
// Prior to PHP 8.1, this was a compile error, but this is now supported.
test(...$values, param: $value);

/* testParseErrorNoValue */
Expand Down
5 changes: 3 additions & 2 deletions Tests/Utils/PassedParameters/GetParametersNamedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,9 @@ public function dataGetParameters()
],
],
],
'named-args-compile-error-incorrect-order-variadic' => [
'testMarker' => '/* testCompileErrorIncorrectOrderWithVariadic */',
// Prior to PHP 8.1, this was a compile error, but this is now supported.
'named-args-after-variadic' => [
'testMarker' => '/* testPHP81NamedParamAfterVariadic */',
'targetType' => \T_STRING,
'expected' => [
1 => [
Expand Down

0 comments on commit 190a5e5

Please sign in to comment.