function collectUseDeclarations(Source $s, $begin) { $result = ['class' => [], 'function' => [], 'const' => []]; # only tokens that are siblings bracket-wise are considered, # so trait-use instances are not an issue foreach ($s->siblings(T_USE, $begin) as $keyword) { # skip if closure-use $next = $s->skip(Source::junk(), $keyword); if ($s->is(Generic\LEFT_ROUND, $next)) { continue; } parseUseDeclaration($s, $next, $result); } return $result; }