|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-06-16 21:20 UTC] aydoganserdar at gmail dot com
Description:
------------
variable type error.
Error:
PHP Catchable fatal error: Argument 1 passed to app/aa::A() must be an instance of string, string given, called in A.php on line 10 and defined in A.php on line 17
System Info:
PHP 5.6.11-1ubuntu3.4 (cli)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
with Xdebug v2.3.3, Copyright (c) 2002-2015, by Derick Rethans
Test script:
---------------
Error scenario:
namespace app/aa
use string;
class A {
public function B()
{
$c = $this->getC('getC');
$d = $this->getC('getD');
}
private function getC(string $c)
{
return $c;
}
private function getD(string $d)
{
return $d;
}
}
Worked if delete function "getC":
class A {
public function B()
{
$c = $this->getC('getC');
$d = $this->getC('getD');
}
private function getC(string $c)
{
return $c;
}
private function getD(string $d)
{
return $d;
}
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
test script fixes Error scenario: namespace app/aa use string; class A { public function B() { $c = $this->getC('getC'); $d = $this->getD('getD'); } private function getC(string $c) { return $c; } private function getD(string $d) { return $d; } } Worked if delete function "getC": class A { public function B() { //$c = $this->getC('getC'); $d = $this->getD('getD'); } /* private function getC(string $c) { return $c; }*/ private function getD(string $d) { return $d; } }