In my code, the parser tends to analyze interfaces as classes. Here is a minimal example:
$source = "<?php interface Foo { public function bar(); }\n";
$reader = new PGPReader($source);
$reader->buildGrammar();
drush_print("Interfaces");
$interfaces = $reader->getInterfaces();
var_dump(array_map(function ($x) { return $x->data->name; }, $interfaces));
drush_print('Classes');
$classes = $reader->getClasses();
var_dump(array_map(function ($x) { return $x->data->name; }, $classes));
Foo is returned as part of the classes, not the interfaces. Am I misusing the API, or is it a bug ?
Comments
Comment #1
fgmNote that, when adding this:
The type of the class is actually T_INTERFACE, not T_CLASS.
Comment #2
solotandem commentedInterfaces and classes are parsed using the same routine. Both are added to the list of classes. The list of interfaces is not populated. I would not classify this as a bug, but rather the current implementation. Given that the interfaces list exists, I should probably use it.
Comment #3
solotandem commentedPlease try this patch and let me know. Thanks.
Comment #4
solotandem commentedImplemented in 7.x-2.x branch.
Consider back port to 1.x.