[PHP-BUG] Bug #51395 [NEW]: implemeting an interface causes class not found
[email protected] ("johnston dot joshua at gmail dot com")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From:
Operating system: OS X, FreeBSD
PHP version: 5.3.2
Package: Scripting Engine problem
Bug Type: Bug
Bug description:implemeting an interface causes class not found
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 bug report at http://bugs.php.net/bug.php?id=51395&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51395&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51395&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51395&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51395&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51395&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51395&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51395&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51395&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51395&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51395&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51395&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51395&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51395&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51395&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51395&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51395&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51395&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51395&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51395&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51395&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51395&r=mysqlcfg