Bug #72401 [Opn->Nab]: Function argument compatibility for static member functions

From: Date: Tue, 14 Jun 2016 11:59:26 +0000
Subject: Bug #72401 [Opn->Nab]: Function argument compatibility for static member functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201599@lists.php.net to get a copy of this message
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)

« previous php.bugs (#201599) next »