Bug #51395 [Opn->Bgs]: implemeting an interface causes class not found
| From: | johannes@php.net | Date: | Thu, 25 Mar 2010 22:55:42 +0000 |
| Subject: | Bug #51395 [Opn->Bgs]: implemeting an interface causes class not found | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-149030@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51395&edit=1
ID: 51395
Updated by: johannes@php.net
Reported by: johnston dot joshua at gmail dot com
Summary: implemeting an interface causes class not found
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: OS X, FreeBSD
PHP Version: 5.3.2
New Comment:
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
This is a documented limitation of the object implementation and the way
we do object binding.
Previous Comments:
------------------------------------------------------------------------
[2010-03-25 23:12:27] johnston dot joshua at gmail dot com
Description:
------------
Normally you can declare classes in any order inside of a php file. When
one of your classes implements an interface, php will throw a fatal
error about class not found if the class is declared in the wrong
order.
If you remove the implements clause then order does not matter.
php bug http://bugs.php.net/bug.php?id=39758 also
shows this and the
reply from dmitry was:
PHP always declares classes those implement interfaces at run-time. So
in your example you cannot declare "Bar" because "Foo" is not declared
yet.
Your report may be categorised as "feature request", but it cannot be
fixed in 5.2.* anyway, because of binary compatibility.
Just because the internals handle things in a certain order does not
mean that php should exhibit contradicting behavior based on valid class
definitions.
Test script:
---------------
test.php
<?php
class One extends Two {}
interface Three {}
class Two implements Three {}
?>
test2.php
<?php
class One extends Two {}
interface Three {}
class Two {}
?>
Expected result:
----------------
test.php:
no output
test2.php:
no output
Actual result:
--------------
jjohnston:~$ php test.php
PHP Fatal error: Class 'Two' not found in /Users/jjohnston/test.php on
line 2
Fatal error: Class 'Two' not found in /Users/jjohnston/test.php on line
2
jjohnston:~$ php test2.php
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51395&edit=1