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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
27 + 33 = ?
Subscribe to this entry?

 
 [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 Aug 09 21:05:46 2022 UTC