PHPUnit嘲笑和类型提示方法 [英] PHPUnit mockery and typehinted methods

查看:92
本文介绍了PHPUnit嘲笑和类型提示方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人使用php7方法类型提示来尝试phpunit吗?我遇到了一个带有打字提示方法的模拟类问题

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

因为我的代码中有类似public function getSettings() : string {/**code here*/}的方法.认为嘲弄尚不知道如何使用它.也许有人有一个解决方案,如何告诉模拟类该方法应返回偶数类型?

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?

推荐答案

所以我自己找到了解决方案.问题与嘲笑供应商软件包0.9.4或更高版本有关.只需在composer.json中将"0.9.*"更改为"dev-master".这个问题将在下一个嘲笑的pckage版本中解决.

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.

这篇关于PHPUnit嘲笑和类型提示方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆