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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC