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
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: 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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 06:01:29 2024 UTC