// - Static method call
// - Static property access
// - Use of class constant
+// - typehints
//
// TODO: Possibly support these:
//
-// - typehints
// - instanceof
// - catch
// - String literal in ReflectionClass().
continue;
}
$need[] = array(
- 'type' => 'class',
+ 'type' => 'class/interface',
'symbol' => $name,
);
}
+// This is "function (X $x)".
+$parameters = $root->selectDescendantsOfType('n_DECLARATION_PARAMETER');
+foreach ($parameters as $parameter) {
+ $hint = $parameter->getChildByIndex(0);
+ if ($hint->getTypeName() != 'n_CLASS_NAME') {
+ continue;
+ }
+ $need[] = array(
+ 'type' => 'class/interface',
+ 'symbol' => $hint,
+ );
+}
+
// -( Interfaces )------------------------------------------------------------
}
$type = $spec['type'];
- if (!$show_all) {
- if (!empty($externals[$type][$name])) {
- // Ignore symbols declared as externals.
- continue;
+ foreach (explode('/', $type) as $libtype) {
+ if (!$show_all) {
+ if (!empty($externals[$libtype][$name])) {
+ // Ignore symbols declared as externals.
+ continue 2;
+ }
+ if (!empty($builtins[$libtype][$name])) {
+ // Ignore symbols declared as builtins.
+ continue 2;
+ }
}
- if (!empty($builtins[$type][$name])) {
- // Ignore symbols declared as builtins.
- continue;
+ if (!empty($declared_symbols[$libtype][$name])) {
+ // We declare this symbol, so don't treat it as a requirement.
+ continue 2;
}
}
if (!empty($required_symbols[$type][$name])) {
// isn't terribly informative.
continue;
}
- if (!empty($declared_symbols[$type][$name])) {
- // We declare this symbol, so don't treat it as a requirement.
- continue;
- }
$required_symbols[$type][$name] = $spec['symbol']->getOffset();
}
}
}
+ $types = array('class', 'function', 'interface', 'class/interface');
foreach ($symbols as $library => $map) {
// Check for unknown symbols: uses of classes, functions or interfaces
// which are not defined anywhere. We reference the list of all symbols
// we built up earlier.
foreach ($map as $file => $spec) {
$need = idx($spec, 'need', array());
- foreach (array('class', 'function', 'interface') as $type) {
- $libtype = ($type == 'interface') ? 'class' : $type;
+ foreach ($types as $type) {
+ $libtype = $type;
+ if ($type == 'interface' || $type == 'class/interface') {
+ $libtype = 'class';
+ }
foreach (idx($need, $type, array()) as $symbol => $offset) {
if (!empty($all_symbols[$libtype][$symbol])) {
// Symbol is defined somewhere.