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: 2017-01-02 14:35 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:
Status: Open Package: Class/Object related
PHP Version: Irrelevant OS: Debian Squeeze
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 15:01:25 2019 UTC