If you have code like this:
namespace Foo;
interface ConstraintViolationListInterface extends \Traversable, \Countable, \ArrayAccess
When we parse it out, and then convert the individual extend items to string with:
foreach ($statement->extends as $extend) {
$docblock['extends'][] = $extend->toString();
}
I am getting "Traversable" "Countable", "ArrayAccess", without the leading \, from the PHP parser [This is in api.parser.inc in _api_build_php_docblocks()].
Then I pass any extends I find through api_full_classname(). And when it gets something without a leading \, it (correctly) assumes it should be in the namespace of the overall file. So, instead of \Traversable being recognized as a PHP built-in interface in the root namespace, it is instead thinking it is \Foo\Traversable.
Note that I found another interface in the codebase that is working correctly -- but it has use statements at the top of its file, such as
use Traversable;
which means that "Traversable" without the \ means \Traversable for that file. The api_full_classname() function always takes into account the use statements, so it's working correctly for that interface.
We're unfortunately currently using an old version of the PHP parser. So... I'll probably have to postpone fixing this until I can upgrade to a newer version and see if it's still a problem there, and then if so, take it up with the PHP parser project. See
π
Test/update API module for new Parser code version
Closed: outdated
Active
2.0
Parser
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.