Bug #67848 [Com]: Problem at create new instance of class
| From: | cmbecker69 at gmx dot de | Date: | Mon, 02 Mar 2015 19:05:06 +0000 |
| Subject: | Bug #67848 [Com]: Problem at create new instance of class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191053@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67848&edit=1
ID: 67848
Comment by: cmbecker69 at gmx dot de
Reported by: eduardbader at gmail dot com
Summary: Problem at create new instance of class
Status: Open
Type: Bug
Package: Class/Object related
Operating System: debian 7.5 (wheezy)
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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>
Previous Comments:
------------------------------------------------------------------------
[2014-08-15 14:19:28] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67848&edit=1