Bug #61383 [Opn->Nab]: can't define type of var in class method
| From: | rasmus@php.net | Date: | Wed, 14 Mar 2012 06:56:02 +0000 |
| Subject: | Bug #61383 [Opn->Nab]: can't define type of var in class method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-168443@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61383&edit=1
ID: 61383
Updated by: rasmus@php.net
Reported by: keryax at ya dot ru
Summary: can't define type of var in class method
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: windows server 2003 R2
PHP Version: 5.4.0
Block user comment: N
Private report: N
New Comment:
PHP does not have scalar type hints.
public static function lol(integer $A)
That says that you want $A to be an instance of Class integer. That's completely
distinct from the scalar integer type.
Try this:
class integer { }
class omg{
public static function lol(integer $A){
return true;
}
}
echo omg::lol(new integer);
Previous Comments:
------------------------------------------------------------------------
[2012-03-14 06:45:28] keryax at ya dot ru
Description:
------------
I've got strange error:
Catchable fatal error: Argument 1 passed to omg::lol() must be an instance of integer, integer given
When I've replaced "integer" to "int", I've got:
Catchable fatal error: Argument 1 passed to omg::lol() must be an instance of int, integer given
Test script:
---------------
class omg{
public static function lol(integer $A){
return true;
}
}
echo omg::lol(123);
Expected result:
----------------
calling the method
--
captain obvious
Actual result:
--------------
Catchable fatal error
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61383&edit=1