#30741 [Opn]: Interfaces must appear before use
| From: | vrana@php.net | Date: | Wed, 10 Nov 2004 08:42:56 +0000 |
| Subject: | #30741 [Opn]: Interfaces must appear before use | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969364974@lists.php.net to get a copy of this message | ||
ID: 30741
Updated by: vrana@php.net
Reported By: chris at experiencetours dot com dot au
Status: Open
Bug Type: Documentation problem
Operating System: Linux
PHP Version: 5.0.2
New Comment:
It is written at
http://www.php.net/manual/en/migration5.incompatible.php
:
"In some cases classes must be declared before used. It only happens
only if some of the new features of PHP 5 are used. Otherwise the
behaviour is the old."
Thus I think this bug can be marked as bogus.
Previous Comments:
------------------------------------------------------------------------
[2004-11-10 08:11:32] derick@php.net
This is expected behavior, but should be mentioned in PHP 5's migration
guide (http://de.php.net/manual/en/migration5.oop.php)
------------------------------------------------------------------------
[2004-11-10 01:43:26] chris at experiencetours dot com dot au
Description:
------------
I am not sure if this is a bug or a documentation issue, but if an
instance of a class is created before the Interface definition, the
class will be undefined. Although this is not directly covered in the
manual, it is inconsistent with functions, which can be reference
before they are defined.
./configure --with-apache=/usr/local/src/apache/apache_1.3.31
--with-libxml-dir=/usr/local/libxml2 --enable-calendar
--with-openssl=/usr --wi
th-pear --with-zlib --enable-ftp --with-bz2 --with-ldap --with-pdflib
--without-mysql --with-pgsql --with-pspell
Reproduce code:
---------------
$concreteType = new ConcreteType();
echo $concreteType->getText();
$c2 = new ContreteType2();
echo $c2->getText();
interface IType
{
public function getText();
}
abstract class AbstractType implements IType
{
}
class ConcreteType extends AbstractType
{
public function getText()
{
return "Hello World!!!";
}
}
class ConcreteType2 implements IType
{
public function getText()
{
return "Hello World!!!";
}
}
Expected result:
----------------
"Hello World!!!""Hello World!!!"
Actual result:
--------------
Fatal error: Class 'ConcreteType' not found in
/usr/local/apache/htdocs/bookallot/test.php on line 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30741&edit=1