Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

count(): Recursion detected warning triggered #61

Closed
sebastianbergmann opened this issue Jun 18, 2024 · 2 comments
Closed

count(): Recursion detected warning triggered #61

sebastianbergmann opened this issue Jun 18, 2024 · 2 comments
Labels

Comments

@sebastianbergmann
Copy link
Owner

@staabm I just tagged 6.1.0 with your most recent changes. However, one test from PHPUnit's test suite fails now because a PHP warning is triggered:

1) /usr/local/src/phpunit/tests/end-to-end/regression/5614.phpt
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
-PHPUnit %s by Sebastian Bergmann and contributors.
+Warning: count(): Recursion detected in /usr/local/src/phpunit/vendor/sebastian/exporter/src/Exporter.php on line 79
+PHPUnit 11.2.2-15-g3458dc7617 by Sebastian Bergmann and contributors.
 
-Runtime: %s
+Runtime:       PHP 8.3.8
 
+
+Warning: count(): Recursion detected in /usr/local/src/phpunit/vendor/sebastian/exporter/src/Exporter.php on line 79
 .                                                                   1 / 1 (100%)
 
-Time: %s, Memory: %s MB
+Time: 00:00.002, Memory: 8.00 MB
 
 OK (1 test, 1 assertion)

This is the test code in question:

final class Issue5614Test extends TestCase
{
    public static function provideRecursiveArray(): iterable
    {
        $array    = [];
        $array[0] = &$array;

        yield [$array];
    }

    #[DataProvider('provideRecursiveArray')]
    public function testRecursiveArray(array $array): void
    {
        $this->assertTrue(true);
    }
}

Would suppressing the warning (@count($data, COUNT_RECURSIVE) instead of count($data, COUNT_RECURSIVE)) be the right thing to do here?

@staabm
Copy link
Contributor

staabm commented Jun 18, 2024

Would suppressing the warning (@count($data, COUNT_RECURSIVE) instead of count($data, COUNT_RECURSIVE)) be the right thing to do here?

I think you are right, this should work

@sebastianbergmann
Copy link
Owner Author

Released as 6.1.1, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants