php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71733 double extends not autoload third class (if not correct order)
Submitted: 2016-03-07 16:53 UTC Modified: 2016-07-15 09:23 UTC
From: oskars dot petermanis at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: Irrelevant OS: any
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: oskars dot petermanis at gmail dot com
New email:
PHP Version: OS:

 

 [2016-03-07 16:53 UTC] oskars dot petermanis at gmail dot com
Description:
------------
First, please, see test script.

One problem is that it is harder to debug (as the error points to existing class in same file).
Second (and main in my case) that autoload for class C is not working.

The workaround is to switch "extends" lines and it will work as expected for both problems.

This bug makes our php code generator more complicated.

Test script:
---------------
<?php
class A extends B{}
class B extends C{}
$a = new A();

Expected result:
----------------
Fatal error: Class 'C' not found in /tmp/test.php on line 3

Actual result:
--------------
Fatal error: Class 'B' not found in /tmp/test.php on line 2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-27 12:31 UTC] krakjoe@php.net
-Package: Class/Object related +Package: Scripting Engine problem
 [2016-07-15 09:23 UTC] dmitry@php.net
-Status: Open +Status: Not a bug
 [2016-07-15 09:23 UTC] dmitry@php.net
This is not a bug. Class B has to be defined before A.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 03:00:02 2026 UTC