PHPUnit mockery and typehinted methods

匆匆过客 提交于 2019-12-11 23:53:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!