php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: martijn dot otto at copernica dot com
New email:
PHP Version: OS:

 

 [2016-06-14 10:54 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-14 11:59 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-06-14 11:59 UTC] requinix@php.net
Static methods can be called using instances so LSP rules still apply.
https://3v4l.org/FPEUj
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Aug 09 17:01:23 2020 UTC