php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69589 calling abstract child static function from parent constructor generates error
Submitted: 2015-05-07 01:59 UTC Modified: 2015-05-07 02:48 UTC
From: guvenc at objexa dot com Assigned: requinix (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.6Git-2015-05-07 (Git) OS: ubuntu
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: guvenc at objexa dot com
New email:
PHP Version: OS:

 

 [2015-05-07 01:59 UTC] guvenc at objexa dot com
Description:
------------
calling a child classes static function from parent constructor generates error

Test script:
---------------
class A{
  public function __construct(){
    static::someFunc();
  }
 
  abstract protected static function someFunc;

}

Class B extens A{
  public function __construct(){
    parent::__construct();
  }
  protected static function someFunc(){

  }
}

$obj = new B();

Expected result:
----------------
I expect it to keep executing with no errors.

Actual result:
--------------
ErrorException with message 'Static function A::someFunc() should not be abstract'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-07 02:48 UTC] requinix@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: requinix
 [2015-05-07 02:48 UTC] requinix@php.net
If you have an ErrorException then it's because you have error handling code that creates and throws exceptions. PHP isn't doing it. The error message is from a mere E_STRICT.

...which has been removed in PHP 7.
https://wiki.php.net/rfc/reclassify_e_strict#abstract_static_methods
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 09:05:45 2022 UTC