warnings - PHP: why is "Strict standards: Declaration of x should be compatible with y" applied to static methods? -
the php warning, "strict standards: declaration of x should compatible y" warns if write code like:
class { function foo($x) { .. } } class b extends { function foo() { .. } } this sensible, because object reference "$a" think a, may @ runtime turn out b, dynamically dispatched method call $a->foo(3) may end calling b::foo() wrong number of arguments.
my question is: why same warning applied static methods, not dynamically dispatched?
class x { static function bar($x) { .. } } class y extends x { static function bar() { .. } } in example, function y::bar() not override x::bar(), there no reason trigger warning, php still does. why?
just in java, can call static methods on instance too. there still room confusion.
Comments
Post a Comment