/** * @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); }
/** * @return array */ public function getElements() { foreach ($this->elementStorage->getElements() as $type => $elementList) { foreach ($elementList as $element) { $this->processElement($element); } } $this->sortElements(); return $this->elements; }
/** * @return Template */ public function loadTemplateWithElementNamespaceOrPackage(Template $template, ElementReflectionInterface $element) { if ($namespaces = $this->elementStorage->getNamespaces()) { $name = $element->getPseudoNamespaceName(); $template = $this->loadTemplateWithNamespace($template, $name, $namespaces[$name]); } elseif ($packages = $this->elementStorage->getPackages()) { $name = $element->getPseudoPackageName(); $template = $this->loadTemplateWithNamespace($template, $name, $packages[$name]); } return $template; }
/** * @param string $namespace * @param bool $skipLast * @return string */ public function namespaceLinks($namespace, $skipLast = true) { if (!$this->elementStorage->getNamespaces()) { return $namespace; } $links = []; $parent = ''; foreach (explode('\\', $namespace) as $part) { $parent = ltrim($parent . '\\' . $part, '\\'); $links[] = $skipLast || $parent !== $namespace ? $this->linkBuilder->build($this->namespaceUrl($parent), $part) : $part; } return implode('\\', $links); }
/** * @return array */ private function getParameters() { if ($this->parameters === NULL) { $parameters = ['annotationGroups' => $this->configuration->getOption(CO::ANNOTATION_GROUPS), 'namespace' => NULL, 'package' => NULL, 'class' => NULL, 'constant' => NULL, 'function' => NULL, 'namespaces' => array_keys($this->elementStorage->getNamespaces()), 'packages' => array_keys($this->elementStorage->getPackages()), 'classes' => array_filter($this->elementStorage->getClasses(), $this->getMainFilter()), 'interfaces' => array_filter($this->elementStorage->getInterfaces(), $this->getMainFilter()), 'traits' => array_filter($this->elementStorage->getTraits(), $this->getMainFilter()), 'exceptions' => array_filter($this->elementStorage->getExceptions(), $this->getMainFilter()), 'constants' => array_filter($this->elementStorage->getConstants(), $this->getMainFilter()), 'functions' => array_filter($this->elementStorage->getFunctions(), $this->getMainFilter()), 'elements' => $this->autocompleteElements->getElements()]; if ($this->configuration->getOption(CO::DOWNLOAD)) { $parameters['archive'] = basename($this->configuration->getZipFileName()); } $this->parameters = $parameters; } return $this->parameters; }
/** * @return int */ public function getStepCount() { $tokenizedFilter = function (ReflectionClass $class) { return $class->isTokenized(); }; $count = count(array_filter($this->elementStorage->getClasses(), $tokenizedFilter)) + count(array_filter($this->elementStorage->getInterfaces(), $tokenizedFilter)) + count(array_filter($this->elementStorage->getTraits(), $tokenizedFilter)) + count(array_filter($this->elementStorage->getExceptions(), $tokenizedFilter)) + count($this->elementStorage->getConstants()) + count($this->elementStorage->getFunctions()); return $count; }
/** * @return int */ public function getStepCount() { return count($this->elementStorage->getFunctions()); }
/** * @return bool */ public function isAllowed() { return (bool) $this->elementStorage->getNamespaces(); }
/** * @return bool */ public function isAllowed() { return (bool) $this->elementStorage->getPackages(); }