问题
does anyone already tried phpunit with php7 methods type hints? I got an issue mocking class with typoe hinted method's like
PHP Fatal error: Declaration of Mockery_0_Forms_Fields_TextField::getSettings() must be compatible with AbstractField::getSettings(): array in /home/n1ks2n/vagrant/$project-name/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php(16) : eval()'d code on line 25
Beacuse i have methods like public function getSettings() : string {/**code here*/}
in my code. Think that mockery doesn't yet know how to work with this. Maybe someone has a solution how to tell mocked class that this methods should return even type?
回答1:
So i found a solution myself. The problem is about mockery vendor package version 0.9.4 or above. Just need to change "0.9.*" to "dev-master" in composer.json. This problem will be solved in the next release of mockery pckage.
来源:https://stackoverflow.com/questions/34812102/phpunit-mockery-and-typehinted-methods