php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72436 PHP 5.6.11-1ubuntu3.4
Submitted: 2016-06-16 21:20 UTC Modified: 2016-06-16 21:45 UTC
From: aydoganserdar at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.6.22 OS: Ubuntu 15.04
Private report: No CVE-ID: None
 [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;
	}		
}




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-16 21:26 UTC] aydoganserdar at gmail dot com
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;
	}		
}
 [2016-06-16 21:45 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-06-16 21:45 UTC] requinix@php.net
Your error message doesn't match up with your code, and your code has a syntax error.

PHP 5.6 does not have type hints for strings. Only PHP 7+.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 20:01:23 2019 UTC