|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-02-13 20:45 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 05:00:01 2025 UTC |
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?