|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-03-21 00:00 UTC] j dot verloop at gmail dot com
Description:
------------
PHP can't seem to find an interface when it's extended by another one and
implemented by a class located in a different namespace (when stored in 1 single
file).
Test script:
---------------
I do have 3 examples:
Example 1:
test.php
namespace A;
class B implements \A\B\C, \Countable {
public function count() {
return 1;
}
}
namespace A\B;
interface C {}
everything is OK!
-----------------
Example 2:
test.php
namespace A\B;
interface C extends \Countable {}
namespace A;
class B implements \A\B\C {
public function count() {
return 1;
}
}
everything is OK!
-----------------
Example 3:
test.php
namespace A;
class B implements \A\B\C {
public function count() {
return 1;
}
}
namespace A\B;
interface C extends \Countable {}
Fatal error
Expected result:
----------------
No fatal error ;)
Actual result:
--------------
Fatal error: Interface 'A\B\C' not found in...
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 15 09:00:01 2025 UTC |
Thanks for your reply! Btw, it´s not namespace related because I've found the same *problem* without using namespaces. You say it´s expected behaviour, so I suppose you´re right. But isn't it weird the problem doesn't occur in the *same* inheritance structure when we only use classes. // Only classes class A extends B {} class C {} class B extends C {} everything is OK! ----------------- // Classes and interfaces class D implements E {} interface F {} interface E extends F {} Fatal error: Interface 'E' not found in... ------------------------------------------ I've searched the documentation to clarify this issue as expected. Obviously, I haven't found it. I would appreciate it if you could point me in the right direction (documentation).