Bug #72401 [Opn->Nab]: Function argument compatibility for static member functions
Edit report at https://bugs.php.net/bug.php?id=72401&edit=1
ID: 72401
Updated by: requinix@php.net
Reported by: martijn dot otto at copernica dot com
Summary: Function argument compatibility for static member
functions
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
PHP Version: 7.0.7
Block user comment: N
Private report: N
New Comment:
Static methods can be called using instances so LSP rules still apply.
https://3v4l.org/FPEUj
Previous Comments:
------------------------------------------------------------------------
[2016-06-14 10:54:15] martijn dot otto at copernica dot com
Description:
------------
PHP incorrectly complains about static member functions not being compatible. This makes no sense as
they're static functions, they don't have a $this pointer, the function being called
cannot suddenly be a different function (as can be the case when overriding a non-static member
function).
Test script:
---------------
<?php
class A { public static function get($a) {} }
class B extends A { public static function get($a, $b) {} }
Expected result:
----------------
No warnings should be emitted
Actual result:
--------------
Warning: Declaration of B::get($a, $b) should be compatible with A::get($a) in php shell code on
line 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72401&edit=1
Thread (2 messages)