Skip to content

Iterable return types should return empty array by default#4678

Merged
sebastianbergmann merged 1 commit intosebastianbergmann:8.5from
Slamdunk:iterable_empty_return
May 20, 2021
Merged

Iterable return types should return empty array by default#4678
sebastianbergmann merged 1 commit intosebastianbergmann:8.5from
Slamdunk:iterable_empty_return

Conversation

@Slamdunk
Copy link
Copy Markdown
Contributor

Without this fix, mocked method with traversable|Generator|iterable return types return an array with one null element:

https://3v4l.org/mR8kdU

1) ./tests/end-to-end/mock-objects/generator/return_type_declarations_generator_empty_by_default.phpt
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
-array(0) {
+array(1) {
+  [0]=>
+  NULL
 }
-array(0) {
+array(1) {
+  [0]=>
+  NULL
 }
-array(0) {
+array(1) {
+  [0]=>
+  NULL
 }

@sebastianbergmann sebastianbergmann added feature/test-doubles Test Stubs and Mock Objects type/bug Something is broken labels May 20, 2021
@sebastianbergmann sebastianbergmann merged commit 73e9d2b into sebastianbergmann:8.5 May 20, 2021
@Slamdunk Slamdunk deleted the iterable_empty_return branch May 20, 2021 14:16
williamdes added a commit to phpmyadmin/phpmyadmin that referenced this pull request May 29, 2023
This did happen to me in Ubuntu while packaging,  until now I did not understand it correctly.
It's a phpunit bug for sure, patched in 8.5.16.
Most probably due to sebastianbergmann/phpunit#4678

```
1) PhpMyAdmin\Tests\TableTest::testDuplicateInfo
Invalid argument supplied for foreach()

libraries/classes/Table.php:944
test/classes/TableTest.php:955
phpvfscomposer://vendor/phpunit/phpunit/phpunit:60
```

Signed-off-by: William Desportes <williamdes@wdes.fr>
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature/test-doubles Test Stubs and Mock Objects type/bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants