|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72401 Function argument compatibility for static member functions
Submitted: 2016-06-14 10:54 UTC Modified: 2016-06-14 11:59 UTC
From: martijn dot otto at copernica dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 7.0.7 OS:
Private report: No CVE-ID: None
 [2016-06-14 10:54 UTC] martijn dot otto at copernica dot com
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:
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-14 11:59 UTC]
-Status: Open +Status: Not a bug
 [2016-06-14 11:59 UTC]
Static methods can be called using instances so LSP rules still apply.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 23:01:30 2024 UTC