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
Mocked object being sorted raises PHP warning #161
Comments
The fact that usort forbids using any debug call or even instantiating exception makes it hardly usable with any other code (especially given that this code cannot know that it is called inside a usort callback, unless it uses one of the features triggering the issue). I suggest you to vote on https://bugs.php.net/bug.php?id=50688. I don't see how we could fix it in Prophecy actually (except by removing features from the library) |
Vote on the issue and use |
Apparently this was fixed with PHP 7 but not on older versions. I can confirm that |
Unfortunately no way to solve this before PHP7, because the mock objects itself tracks how many times each expectation was called and call as part of sort operation increases that counter hence the warning. I ended up sorting array of object by key, where key value is mocked method value obtained upfront. |
Related issue: #215 |
I fell back to plain old PHPUnit mock objects which do not track method calls. |
This bug occurs when calling a mocked function inside a usort function.
The warning is cause by CallCenter::makeCall() calling debug_backtrace() and changing the reference count (http://stackoverflow.com/questions/3235387/usort-array-was-modified-by-the-user-comparison-function)
PHP Version: 5.5.21
prophecy Versions: 1.3.1
The text was updated successfully, but these errors were encountered: