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

Const array throws "Array to string conversion" in ConstantsPass #1084

Closed
MPC-khajiit opened this issue Jul 16, 2020 · 1 comment
Closed

Comments

@MPC-khajiit
Copy link
Contributor

Hello,

There is limitation due to passing constans through constantsMap. When you'll try to pass an array to constans map it will throw exception. sprintf will try to convert array to string.

ex.

\Mockery::getConfiguration()->setConstantsMap([
    'ClassWithConstants' => [
        'DEFAULTS' => [
            'foo' => 10, 
            'bar' => 20
        ]
    ]
]);

$mock = \Mockery::mock('overload:ClassWithConstants');

will throw

ErrorException : Array to string conversion
vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ConstantsPass.php:24
vendor/mockery/mockery/library/Mockery/Generator/StringManipulationGenerator.php:79
vendor/mockery/mockery/library/Mockery/Generator/CachingGenerator.php:40
vendor/mockery/mockery/library/Mockery/Container.php:215
vendor/mockery/mockery/library/Mockery.php:117
@GrahamCampbell
Copy link
Contributor

Don't worry about the PHP 8 test failures. They are due to a very recent change (after my PHP 8 fixes went in), and there is a bug in PHPUnit which won't be released until August with PHPUnit 9.3, so until then, the PHP 8.0 tests will fail. I think that's fine. We can just wait it out. I don't think any mockery releases are planned in the time between now and then.

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

No branches or pull requests

2 participants