#27440 [Bgs->Opn]: declare classes before usage
| From: | betz@php.net | Date: | Thu, 11 Mar 2004 11:27:19 +0000 |
| Subject: | #27440 [Bgs->Opn]: declare classes before usage | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-56289@lists.php.net to get a copy of this message | ||
ID: 27440
Updated by: betz@php.net
Reported By: holliwell at gmx dot net
-Status: Bogus
+Status: Open
Bug Type: Class/Object related
Operating System: linux 2.4.20 RH8
PHP Version: 5CVS-2004-02-29 (dev)
New Comment:
Reopen
Previous Comments:
------------------------------------------------------------------------
[2004-03-09 19:58:55] holliwell at gmx dot net
Iliaa, I did not get your point, sorry!
1.) In php5 its possible to do $c = new someclass , before
someclass is defined, _without_ throwing an error.
2.) Wich error are you talking about:
<qoute>
since at the time the error is generated
</qoute>
3.) be gentle ;-) and do not mark this bogus, at least a doc bug.
Or change README.PHP4-TO-PHP5-THIN-CHANGES to reflect
the current behaviour (which is not throwing an error in this
case.)
4.) AFAIK at some stage of php5 using a class before declaring
was throwing an fatal error. This was changed because of bc.
So why should it be not possible in E_STRICT mode to throw a
warning?
Kind regards
Friedhelm
------------------------------------------------------------------------
[2004-03-09 19:10:10] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
In this case raising E_STRICT is not possible since at the
time the error is generated the parser does not know if the
class will be declared at a later point. This is just one
of the PHP 5 <-> 4 incompatibilities that will need to be
documented.
------------------------------------------------------------------------
[2004-02-29 18:53:11] holliwell at gmx dot net
yup, so what about at least issue a warning with E_STRICT?
------------------------------------------------------------------------
[2004-02-29 18:42:36] derick@php.net
It is required if you use inheritance and interfaces, so I think it
should stay like this. declaring classes after using them is IMO not
really nice (and afaik it can hurt some performance), so I think we
should keep advising not to do this.
------------------------------------------------------------------------
[2004-02-29 18:35:22] holliwell at gmx dot net
Description:
------------
Hi,
README.PHP4-TO-PHP5-THIN-CHANGES states that classes must be declared
before used. That seems no longer to be true.
Reproduce code:
---------------
<?php
$test = new fubar();
$test->barfu();
class fubar {
function barfu()
{
echo 'fubar';
}
}
?>
Expected result:
----------------
Fatal error: Class 'fubar' not found in ....
Actual result:
--------------
fubar
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27440&edit=1