ID: 47383
Comment by: info at netmosfera dot it
Reported By: info at netmosfera dot it
Status: Open
Bug Type: Class/Object related
Operating System: irrelevant
PHP Version: 5.3.0beta1
New Comment:
better explanation:
class a
{
function a(File $x){echo get_class($x);}
}
class b extends a
{
function a(ImageFile $x){echo get_class($x);}
}
this obviously works!
now, if mixed means "accepts everything"
class a
{
function a(Mixed $x){echo get_class($x);}
}
i should be able to override it:
class b extends a
{
function a(File $x){echo get_class($x);}
}
no?
Previous Comments:
------------------------------------------------------------------------
[2009-02-13 20:45:43] info at netmosfera dot it
Description:
------------
hello
i think that non-type-hinted arguments (mixed values):
class a
{
function test([mixed] $argument){}
}
should allow type hinting in child classes
class b extends a
{
function test(ImageFile $argument){}
}
Reproduce code:
---------------
"mixed" is a general type... means "everything"
but if i want to build an ArrayObject object with one-only type
i cannot do this
[internal]
class ArrayObject implements ArrayAccess
{
function offsetSet($o, [mixed] $value)
{}
}
class ImageList extends ArrayObject
{
function offsetSet($o, Image $imageObject) // fatal error!
{}
}
Actual result:
--------------
Fatal error: Declaration of ImageList::offsetSet() must be compatible
with that of ArrayAccess::offsetSet() in xx on line 8
thank you
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47383&edit=1