php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67848 Problem at create new instance of class
Submitted: 2014-08-15 14:19 UTC Modified: 2015-03-02 20:46 UTC
From: eduardbader at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: Irrelevant OS: debian 7.5 (wheezy)
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: eduardbader at gmail dot com
New email:
PHP Version: OS:

 

 [2014-08-15 14:19 UTC] eduardbader at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.oop5.interfaces
---
Fatal error when class defined before parent class. The parent class should implement an interface.

Test script:
---------------
<?php

interface FooInterface {}
class DoesNotWorksOnTopOfFile extends Bar {}

class Bar implements FooInterface{}

class WorksOnBottom extends Bar {}


Expected result:
----------------
no errors expected

Actual result:
--------------
Class 'Bar' not found in /tmp/Bar.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-02 19:05 UTC] cmbecker69 at gmx dot de
This is not a bug.

It is well documented[1] that

| Unless autoloading is used, then classes must be defined before
| they are used. If a class extends another, then the parent class
| must be declared before the child class structure. This rule
| applies to classes that inherit other classes and interfaces.

[1] <http://php.net/manual/en/language.oop5.inheritance.php>
 [2015-03-02 20:46 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-03-02 20:46 UTC] requinix@php.net
That.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 11:01:28 2025 UTC