Phpstorm有检查:Invocation parameter types are not compatible with declared
.
我很惊讶php允许使用基类型作为子类型.
interface Base
{
public function getId();
}
interface Child extends Base
{
}
interface SecondChildType extends Base
{
}
class ChildImpl implements Child
{
public function getId()
{
return 1;
}
}
class SecondChildTypeImpl implements SecondChildType
{
public function getId()
{
return 2;
}
}
class BaseService
{
public function process(Base $base)
{
$childService = new ChildService($base);
return $childService->process($base); //Invocation parameter types are not compatible with declared
}
} …
Run Code Online (Sandbox Code Playgroud) 当运行代码时,我得到了很多错误:DeepCopy\DeepCopy :: recursiveCopy.
这是一个让我迷惑的问题!
这是代码:
public function testGetComplexItemNeeds() {
$this->specify('[getComplexItemNeeds] : ', function($expected) {
$actual = \common\services\ConfigService::getComplexItemNeeds('300001');
expect('getComplexItemNeeds', $actual)->equals($expected);
}, ['examples' => [
[0 => [
'gold' => 1,
'list' => [
300018 => 1,
],
]
],
]]);
}
Run Code Online (Sandbox Code Playgroud)
php_error.log:
PHP 195. DeepCopy\DeepCopy :: copyArray($ array = array('0000000025e4802e0000000050ab4f11'=> class tests\codeception\frontend\UnitTester {protected $ scenario = class Codeception\Scenario {...}; protected $ friends = array(. ..)},'0000000025e480490000000050ab4f11'=>类Codeception\Scenario {protected $ test = class tests\codeception\frontend\service\ConfigServiceTest {...}; protected $ steps = array(...);
xdebug:我用xdebug跟踪发现的问题,当函数 …