php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54708 Fatal error by defined class with inheritance and wrong order and including
Submitted: 2011-05-11 12:30 UTC Modified: 2021-12-02 18:24 UTC
Votes:7
Avg. Score:3.7 ± 1.3
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:0 (0.0%)
From: interrobang at noicq dot org Assigned: cmb (profile)
Status: Wont fix Package: Class/Object related
PHP Version: Irrelevant OS: Debian Squeeze
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: interrobang at noicq dot org
New email:
PHP Version: OS:

 

 [2011-05-11 12:30 UTC] interrobang at noicq dot org
Description:
------------
Script "test.php" produces Fatal error in relation of writing order of classes.

If that missing class defined in same file, at the same place like require_once() (by replacing), no error will appear :O

Test script:
---------------
class file: test.class.php
<?php
class formularEssentials{}
?>

main file: test.php
<?php
require_once 'test.class.php'; //contain "formularEssentials"
class formularBeta extends formularAlpha{}
class formularAlpha extends formularEssentials{}
?>


Expected result:
----------------
nothing, blank screen. No "Fatal error" should be displayed.

Actual result:
--------------
Fatal error: Class 'formularAlpha' not found in test.php

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-09 21:37 UTC] pov at fingerprint dot fr
Other weird comportment with probably the same origin :

<?php // test.php
require 'test2.php';
?>

<?php // test2.php
if (true) {
class SimpleFoo {
}
}
?>

Expected result : no error
Actual result : "Cannot redeclare class SimpleFoo"
 [2017-01-02 14:35 UTC] nikic@php.net
-Type: Bug +Type: Feature/Change Request
 [2017-01-02 14:35 UTC] nikic@php.net
There are a number of variations on this. Here it's an unknown parent class, the two bugs I've just marked as duplicates us an interface. The same happens for used traits.
 [2021-12-02 18:24 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-12-02 18:24 UTC] cmb@php.net
From <https://www.npopov.com/2021/10/20/Early-binding-in-PHP.html>:

| After reading this blog post, you’ll probably appreciate why bug
| reports related to early binding go right on the “won’t fix” pile.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 22:01:26 2025 UTC