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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC