diff --git a/ChangeLog-11.3.md b/ChangeLog-11.3.md index 59682c7c826..03c5094cd26 100644 --- a/ChangeLog-11.3.md +++ b/ChangeLog-11.3.md @@ -9,6 +9,7 @@ All notable changes of the PHPUnit 11.3 release series are documented in this fi * [#4584](https://github.com/sebastianbergmann/phpunit/issues/4584): `assertJsonStringEqualsJsonString()` considers objects with sequential numeric keys equal to arrays * [#4625](https://github.com/sebastianbergmann/phpunit/issues/4625): Generator yielding keys that are neither integer or string leads to hard-to-understand error message when used as data provider * [#4674](https://github.com/sebastianbergmann/phpunit/issues/4674): JSON assertions should treat objects as unordered +* [#5891](https://github.com/sebastianbergmann/phpunit/issues/5891): `Callback` constraint does not handle variadic arguments correctly when used for mock object expectations * [#5929](https://github.com/sebastianbergmann/phpunit/issues/5929): TestDox output containing `$` at the beginning gets truncated when used with a data provider * [#5943](https://github.com/sebastianbergmann/phpunit/issues/5943): Tests configured to be in group(s) using the XML configuration file are also added to the `default` group diff --git a/src/Framework/Constraint/Callback.php b/src/Framework/Constraint/Callback.php index a3acef033d5..22d2d5099ef 100644 --- a/src/Framework/Constraint/Callback.php +++ b/src/Framework/Constraint/Callback.php @@ -9,6 +9,8 @@ */ namespace PHPUnit\Framework\Constraint; +use ReflectionFunction; + /** * @template CallbackInput of mixed * @@ -37,6 +39,17 @@ public function toString(): string return 'is accepted by specified callback'; } + public function isVariadic(): bool + { + foreach ((new ReflectionFunction($this->callback))->getParameters() as $parameter) { + if ($parameter->isVariadic()) { + return true; + } + } + + return false; + } + /** * Evaluates the constraint for parameter $value. Returns true if the * constraint is met, false otherwise. @@ -45,6 +58,10 @@ public function toString(): string */ protected function matches(mixed $other): bool { + if ($this->isVariadic()) { + return ($this->callback)(...$other); + } + return ($this->callback)($other); } } diff --git a/src/Framework/MockObject/Generator/MockMethod.php b/src/Framework/MockObject/Generator/MockMethod.php index 9ce363824a7..0514500b9dd 100644 --- a/src/Framework/MockObject/Generator/MockMethod.php +++ b/src/Framework/MockObject/Generator/MockMethod.php @@ -17,6 +17,7 @@ use function preg_match; use function preg_replace; use function sprintf; +use function str_contains; use function strlen; use function strpos; use function substr; @@ -211,13 +212,21 @@ public function generateCode(): string $template = $this->loadTemplate($templateFile); + $argumentsCount = 0; + + if (str_contains($this->argumentsForCall, '...')) { + $argumentsCount = null; + } elseif (!empty($this->argumentsForCall)) { + $argumentsCount = substr_count($this->argumentsForCall, ',') + 1; + } + $template->setVar( [ 'arguments_decl' => $this->argumentsForDeclaration, 'arguments_call' => $this->argumentsForCall, 'return_declaration' => !empty($this->returnType->asString()) ? (': ' . $this->returnType->asString()) : '', 'return_type' => $this->returnType->asString(), - 'arguments_count' => !empty($this->argumentsForCall) ? substr_count($this->argumentsForCall, ',') + 1 : 0, + 'arguments_count' => $argumentsCount, 'class_name' => $this->className, 'method_name' => $this->methodName, 'modifier' => $this->modifier, diff --git a/src/Framework/MockObject/Generator/templates/doubled_method.tpl b/src/Framework/MockObject/Generator/templates/doubled_method.tpl index 8ecd412c213..1b1b663feff 100644 --- a/src/Framework/MockObject/Generator/templates/doubled_method.tpl +++ b/src/Framework/MockObject/Generator/templates/doubled_method.tpl @@ -17,7 +17,7 @@ $__phpunit_arguments = [{arguments_call}]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > {arguments_count}) { + if ({arguments_count} !== null && $__phpunit_count > {arguments_count}) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/src/Framework/MockObject/Runtime/Rule/Parameters.php b/src/Framework/MockObject/Runtime/Rule/Parameters.php index 0b980fe8c77..ee6aa1c7351 100644 --- a/src/Framework/MockObject/Runtime/Rule/Parameters.php +++ b/src/Framework/MockObject/Runtime/Rule/Parameters.php @@ -12,6 +12,7 @@ use function count; use function sprintf; use Exception; +use PHPUnit\Framework\Constraint\Callback; use PHPUnit\Framework\Constraint\Constraint; use PHPUnit\Framework\Constraint\IsAnything; use PHPUnit\Framework\Constraint\IsEqual; @@ -110,8 +111,13 @@ private function doVerify(): bool } foreach ($this->parameters as $i => $parameter) { + if ($parameter instanceof Callback && $parameter->isVariadic()) { + $other = $this->invocation->parameters(); + } else { + $other = $this->invocation->parameters()[$i]; + } $parameter->evaluate( - $this->invocation->parameters()[$i], + $other, sprintf( 'Parameter %s for invocation %s does not match expected ' . 'value.', diff --git a/tests/end-to-end/mock-objects/generator/232.phpt b/tests/end-to-end/mock-objects/generator/232.phpt index d59ae530146..e875d5298b7 100644 --- a/tests/end-to-end/mock-objects/generator/232.phpt +++ b/tests/end-to-end/mock-objects/generator/232.phpt @@ -82,7 +82,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt b/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt index 24dfee4fb52..7a11767d630 100644 --- a/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt +++ b/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt @@ -67,7 +67,7 @@ class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework $__phpunit_arguments = [$i, $j, $v, $z]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 4) { + if (4 !== null && $__phpunit_count > 4) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 4; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/3967.phpt b/tests/end-to-end/mock-objects/generator/3967.phpt index 2ba1339231e..89e13dc72c8 100644 --- a/tests/end-to-end/mock-objects/generator/3967.phpt +++ b/tests/end-to-end/mock-objects/generator/3967.phpt @@ -55,7 +55,7 @@ class MockBaz extends Exception implements Baz, PHPUnit\Framework\MockObject\Moc $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/397.phpt b/tests/end-to-end/mock-objects/generator/397.phpt index a4c2619700d..17d07b18ba9 100644 --- a/tests/end-to-end/mock-objects/generator/397.phpt +++ b/tests/end-to-end/mock-objects/generator/397.phpt @@ -53,7 +53,7 @@ class MockC extends C implements PHPUnit\Framework\MockObject\MockObjectInternal $__phpunit_arguments = [$other]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/4139.phpt b/tests/end-to-end/mock-objects/generator/4139.phpt index 04caf588fba..4d01e3d1c93 100644 --- a/tests/end-to-end/mock-objects/generator/4139.phpt +++ b/tests/end-to-end/mock-objects/generator/4139.phpt @@ -42,7 +42,7 @@ class %s implements PHPUnit\Framework\MockObject\MockObjectInternal, InterfaceWi $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/abstract_class.phpt b/tests/end-to-end/mock-objects/generator/abstract_class.phpt index a1856f71419..f984809f35b 100644 --- a/tests/end-to-end/mock-objects/generator/abstract_class.phpt +++ b/tests/end-to-end/mock-objects/generator/abstract_class.phpt @@ -57,7 +57,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { @@ -94,7 +94,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { @@ -131,7 +131,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/class.phpt b/tests/end-to-end/mock-objects/generator/class.phpt index b855d4ef5ec..4b387312dc7 100644 --- a/tests/end-to-end/mock-objects/generator/class.phpt +++ b/tests/end-to-end/mock-objects/generator/class.phpt @@ -57,7 +57,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { @@ -94,7 +94,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt b/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt index 0a4b6e22de4..ed277512b86 100644 --- a/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt @@ -53,7 +53,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/class_partial.phpt b/tests/end-to-end/mock-objects/generator/class_partial.phpt index 9608e262356..1d98d31a7cd 100644 --- a/tests/end-to-end/mock-objects/generator/class_partial.phpt +++ b/tests/end-to-end/mock-objects/generator/class_partial.phpt @@ -57,7 +57,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt b/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt index d6b0d09986c..b56f4929588 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt @@ -59,7 +59,7 @@ class MockFoo extends ClassWithDeprecatedMethod implements PHPUnit\Framework\Moc $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt index 99fad68c024..70aa4a42f47 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt @@ -52,7 +52,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt index d689aee8a68..ad7bce6ae64 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt @@ -53,7 +53,7 @@ class MockFoo extends ClassWithMethodWithNullableTypehintedVariadicArguments imp $__phpunit_arguments = [$a]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt index ef939db74c1..4e4d8e3b9e8 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt @@ -53,7 +53,7 @@ class MockFoo extends ClassWithMethodWithTypehintedVariadicArguments implements $__phpunit_arguments = [$a]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt index a5ad0eeee73..077cdc3ba8e 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt @@ -53,7 +53,7 @@ class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit\Fr $__phpunit_arguments = [$a]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt b/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt index 7ddfc743644..6980cdf3a68 100644 --- a/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt +++ b/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt @@ -53,7 +53,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/interface.phpt b/tests/end-to-end/mock-objects/generator/interface.phpt index d6e78304899..e495955594e 100644 --- a/tests/end-to-end/mock-objects/generator/interface.phpt +++ b/tests/end-to-end/mock-objects/generator/interface.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt b/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt index bf75e92a725..6c9ef95428c 100644 --- a/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt +++ b/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt @@ -58,7 +58,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { @@ -95,7 +95,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class.phpt index 80b3f742388..f976c2c2e8c 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class.phpt @@ -59,7 +59,7 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { @@ -96,7 +96,7 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt index 5849422422c..25a11df238f 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt @@ -59,7 +59,7 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt b/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt index 3df7ddab0df..954c8badf65 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt @@ -53,7 +53,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, NS\Foo $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/nullable_types.phpt b/tests/end-to-end/mock-objects/generator/nullable_types.phpt index d831a0d2c67..be1d240d85d 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_types.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_types.phpt @@ -53,7 +53,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$x]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt b/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt index bc181a61911..678c0aa8c0e 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt @@ -53,7 +53,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$baz, $other]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 2) { + if (2 !== null && $__phpunit_count > 2) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 2; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt b/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt index a92cb119eac..a5fbb196402 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt @@ -53,7 +53,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt b/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt index 35ba79bdc27..2e662a2b9d3 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt @@ -61,7 +61,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/parameter_false.phpt b/tests/end-to-end/mock-objects/generator/parameter_false.phpt index 9f76d1dff26..12977e3fe6f 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_false.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_false.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt b/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt index aff259a262d..c26458cffbc 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt @@ -61,7 +61,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/parameter_null.phpt b/tests/end-to-end/mock-objects/generator/parameter_null.phpt index 553b12517e1..30dd0b1c698 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_null.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_null.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/parameter_true.phpt b/tests/end-to-end/mock-objects/generator/parameter_true.phpt index 07f1ae0ab8f..7dd44d5f61f 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_true.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_true.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/parameter_union.phpt b/tests/end-to-end/mock-objects/generator/parameter_union.phpt index f716a1b9eb2..2a1d75a5847 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_union.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_union.phpt @@ -53,7 +53,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$baz, $other]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 2) { + if (2 !== null && $__phpunit_count > 2) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 2; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt index e57b53afe96..1c2729060e6 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt index 9610d24e23b..5734f26c9de 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt @@ -61,7 +61,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt index 033cfbcc56c..d27ae2954df 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt index d8cdfbeed45..b3535650a09 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt @@ -58,7 +58,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt index d530707cd2f..c602a9f00e9 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_intersection.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_intersection.phpt index cd3afcad7ba..30963713c94 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_intersection.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_intersection.phpt @@ -61,7 +61,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt index 165958536bf..af8e1547818 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt index 9d248560b2d..4ce391ad6dc 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt index 72c0305dbc0..8c15f67b0a9 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt index 00a866b83fb..263d278b80e 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt @@ -54,7 +54,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt index 2b66496867e..6d6de9565a3 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt @@ -58,7 +58,7 @@ class MockBar extends Bar implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt index ac6a40dafee..8a2c961e7c3 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt index 0df54517b8f..29d31f457e9 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt @@ -61,7 +61,7 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { @@ -98,7 +98,7 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { @@ -135,7 +135,7 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt index 1e26dca6cfe..13deb66946c 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt index 461fcfd8110..74f1256626d 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt @@ -53,7 +53,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt index faa46e75cdf..3886cc01c00 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt @@ -51,7 +51,7 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt b/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt index 154640d91b1..67539df61f7 100644 --- a/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt +++ b/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt @@ -53,7 +53,7 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/clone_method_arguments.phpt b/tests/end-to-end/mock-objects/mock-method/clone_method_arguments.phpt index 50ab1870d1e..e5636f6f4d9 100644 --- a/tests/end-to-end/mock-objects/mock-method/clone_method_arguments.phpt +++ b/tests/end-to-end/mock-objects/mock-method/clone_method_arguments.phpt @@ -39,7 +39,7 @@ print $code; $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/deprecated_with_description.phpt b/tests/end-to-end/mock-objects/mock-method/deprecated_with_description.phpt index 6ccdc32901b..f7d0354de0f 100644 --- a/tests/end-to-end/mock-objects/mock-method/deprecated_with_description.phpt +++ b/tests/end-to-end/mock-objects/mock-method/deprecated_with_description.phpt @@ -44,7 +44,7 @@ public function bar() $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/deprecated_without_description.phpt b/tests/end-to-end/mock-objects/mock-method/deprecated_without_description.phpt index e2a387ecfe0..1f36d5525ab 100644 --- a/tests/end-to-end/mock-objects/mock-method/deprecated_without_description.phpt +++ b/tests/end-to-end/mock-objects/mock-method/deprecated_without_description.phpt @@ -44,7 +44,7 @@ public function bar() $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/private_method.phpt b/tests/end-to-end/mock-objects/mock-method/private_method.phpt index f844e12da35..4b5cacfd7b0 100644 --- a/tests/end-to-end/mock-objects/mock-method/private_method.phpt +++ b/tests/end-to-end/mock-objects/mock-method/private_method.phpt @@ -39,7 +39,7 @@ private function bar() $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/protected_method.phpt b/tests/end-to-end/mock-objects/mock-method/protected_method.phpt index f8f6d82999e..40a93252247 100644 --- a/tests/end-to-end/mock-objects/mock-method/protected_method.phpt +++ b/tests/end-to-end/mock-objects/mock-method/protected_method.phpt @@ -39,7 +39,7 @@ protected function bar() $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/return_by_reference.phpt b/tests/end-to-end/mock-objects/mock-method/return_by_reference.phpt index 51156da0c97..531d7be25eb 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_by_reference.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_by_reference.phpt @@ -39,7 +39,7 @@ public function &bar() $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/return_by_reference_with_return_type.phpt b/tests/end-to-end/mock-objects/mock-method/return_by_reference_with_return_type.phpt index 3baa0687d02..637cb2debe8 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_by_reference_with_return_type.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_by_reference_with_return_type.phpt @@ -39,7 +39,7 @@ public function &bar(): string $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/return_type.phpt b/tests/end-to-end/mock-objects/mock-method/return_type.phpt index 9d44056ae7b..0ae04dc0dc9 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_type.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_type.phpt @@ -39,7 +39,7 @@ public function bar(): string $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/return_type_parent.phpt b/tests/end-to-end/mock-objects/mock-method/return_type_parent.phpt index 7fd0b2734a6..5d896a32476 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_type_parent.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_type_parent.phpt @@ -43,7 +43,7 @@ public function bar(): Baz $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/return_type_self.phpt b/tests/end-to-end/mock-objects/mock-method/return_type_self.phpt index 7ccd57a45ac..f2faa58ea8d 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_type_self.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_type_self.phpt @@ -39,7 +39,7 @@ public function bar(): Foo $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument.phpt index 76b527ea4e4..3d2c6d84044 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument.phpt @@ -39,7 +39,7 @@ private function bar($arg) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_default.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_default.phpt index aaac640b99c..3cb44b0d3f0 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_default.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_default.phpt @@ -39,7 +39,7 @@ private function bar($arg = false) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_default_constant.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_default_constant.phpt index e7d79d5330d..25a91c71c54 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_default_constant.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_default_constant.phpt @@ -44,7 +44,7 @@ private function bar($a = 1, $b = 2, $c = 3, $d = 4) $__phpunit_arguments = [$a, $b, $c, $d]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 4) { + if (4 !== null && $__phpunit_count > 4) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 4; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_default_new_expression.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_default_new_expression.phpt index 94ef6dcfd99..57448e2cbe9 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_default_new_expression.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_default_new_expression.phpt @@ -46,7 +46,7 @@ public function method(Foo $foo = new \Foo(1, 2, 3)) $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_default_null.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_default_null.phpt index 07fe364b31a..9c9489898db 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_default_null.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_default_null.phpt @@ -39,7 +39,7 @@ private function bar($arg = NULL) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_nullable.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_nullable.phpt index 6a7b2d35a7e..ca05df39b60 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_nullable.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_nullable.phpt @@ -39,7 +39,7 @@ private function bar(?string $arg) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_reference.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_reference.phpt index 149dc6adfea..31ec140b15a 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_reference.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_reference.phpt @@ -39,7 +39,7 @@ private function bar(&$arg) $__phpunit_arguments = [&$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_array.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_array.phpt index 08f5391e64c..228cfb4e77a 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_array.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_array.phpt @@ -39,7 +39,7 @@ private function bar(array $arg) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_callable.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_callable.phpt index d94e276f681..c45de6724c1 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_callable.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_callable.phpt @@ -39,7 +39,7 @@ private function bar(callable $arg) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_class.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_class.phpt index 54375f6806b..77318e54853 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_class.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_class.phpt @@ -39,7 +39,7 @@ private function bar(Exception $arg) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_scalar.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_scalar.phpt index a59f3871d18..4084f3c9c1e 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_scalar.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_scalar.phpt @@ -39,7 +39,7 @@ private function bar(string $arg) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_self.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_self.phpt index 4d7d5293807..b9571f2382a 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_self.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_self.phpt @@ -39,7 +39,7 @@ private function bar(Foo $arg) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_unkown_class.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_unkown_class.phpt index a0549f5ef08..980c4d85aa6 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_unkown_class.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_unkown_class.phpt @@ -39,7 +39,7 @@ private function bar(UnknownClass $arg) $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 1) { + if (1 !== null && $__phpunit_count > 1) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 1; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_variadic.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_variadic.phpt index 3c2a792c356..5f2c4169cc5 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_variadic.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_variadic.phpt @@ -39,7 +39,7 @@ private function bar(string ...$args) $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_variadic.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_variadic.phpt index e4ce178d801..2c0e391e78d 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_variadic.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_variadic.phpt @@ -39,7 +39,7 @@ private function bar(...$args) $__phpunit_arguments = []; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 0) { + if (0 !== null && $__phpunit_count > 0) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/mock-objects/mock-method/with_arguments.phpt b/tests/end-to-end/mock-objects/mock-method/with_arguments.phpt index 7cdbfa7adb7..70f029a734d 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_arguments.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_arguments.phpt @@ -39,7 +39,7 @@ private function bar($arg1, $arg2) $__phpunit_arguments = [$arg1, $arg2]; $__phpunit_count = func_num_args(); - if ($__phpunit_count > 2) { + if (2 !== null && $__phpunit_count > 2) { $__phpunit_arguments_tmp = func_get_args(); for ($__phpunit_i = 2; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { diff --git a/tests/end-to-end/regression/5891.phpt b/tests/end-to-end/regression/5891.phpt new file mode 100644 index 00000000000..934ea0944ae --- /dev/null +++ b/tests/end-to-end/regression/5891.phpt @@ -0,0 +1,20 @@ +--TEST-- +https://github.com/sebastianbergmann/phpunit/issues/5891 +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +.. 2 / 2 (100%) + +Time: %s, Memory: %s MB + +OK (2 tests, 2 assertions) diff --git a/tests/end-to-end/regression/5891/Issue5891Test.php b/tests/end-to-end/regression/5891/Issue5891Test.php new file mode 100644 index 00000000000..d22c5ed846d --- /dev/null +++ b/tests/end-to-end/regression/5891/Issue5891Test.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\Issue5891; + +use PHPUnit\Framework\TestCase; + +final class Issue5891Test extends TestCase +{ + public function testVariadicParam(): void + { + $mock = $this->createMock(ArgumentList::class); + $mock + ->method('foo') + ->with($this->callback(static function (...$items): bool + { + self::assertSame([1, 2, 3], $items); + + return true; + })); + + $mock->foo(1, 2, 3); + } + + public function testTwoParametersAndVariadicParam(): void + { + $mock = $this->createMock(TwoParametersAndArgumentList::class); + $mock + ->method('foo') + ->with($this->callback(static function (...$items): bool + { + self::assertSame(['1st', '2nd', '3rd', '4th'], $items); + + return true; + })); + + $mock->foo('1st', '2nd', '3rd', '4th'); + } +} + +interface ArgumentList +{ + public function foo(int ...$items): void; +} + +interface TwoParametersAndArgumentList +{ + public function foo(string $first, string $second, string ...$rest): void; +}