/**
* @param string $annotation
* @param callable $skipClassCallback
* @return array[]
*/
public function extractElementsByAnnotation($annotation, callable $skipClassCallback = NULL)
{
$elements = $this->elements->getEmptyList();
$elements[Elements::METHODS] = [];
$elements[Elements::PROPERTIES] = [];
foreach ($this->elementStorage->getElements() as $type => $elementList) {
$elementsForMain = $this->elementFilter->filterForMain($elementList);
$elements[$type] += $this->elementFilter->filterByAnnotation($elementsForMain, $annotation);
if ($type === Elements::CONSTANTS || $type === Elements::FUNCTIONS) {
continue;
}
foreach ($elementList as $class) {
/** @var ReflectionClass $class */
if (!$class->isMain()) {
continue;
}
if ($skipClassCallback && $skipClassCallback($class)) {
// in case when class is prior to it's elements
continue;
}
$elements[Elements::METHODS] = $this->extractByAnnotationAndMerge($class->getOwnMethods(), $annotation, $elements[Elements::METHODS]);
$elements[Elements::CONSTANTS] = $this->extractByAnnotationAndMerge($class->getOwnConstants(), $annotation, $elements[Elements::CONSTANTS]);
$elements[Elements::PROPERTIES] = $this->extractByAnnotationAndMerge($class->getOwnProperties(), $annotation, $elements[Elements::PROPERTIES]);
}
}
return $this->sortElements($elements);
}