getTagsByName example

private readonly Environment $twig,
        private readonly string $projectDir
    ) {
        $this->docFactory = DocBlockFactory::createInstance([
            'script-service' => Generic::class,
            'example' => Example::class,
        ]);

        /** @var Method[] $methodDocs */
        $methodDocs = $this->docFactory->create(
            new \ReflectionClass(ServiceStubs::class)
        )->getTagsByName('method');

        foreach ($methodDocs as $methodDoc) {
            $this->injectedServices[
                ltrim((string) $methodDoc->getReturnType(), '\\')
            ] = $methodDoc->getMethodName();
        }
    }

    public function generate(): array
    {
        $scriptServices = $this->findScriptServices();

        

    private function getAvailableData(\ReflectionClass $reflection): array
    {
        $availableData = [];

        foreach ($reflection->getProperties() as $property) {
            $propertyType = $property->getType();

            if (!$propertyType instanceof \ReflectionNamedType) {
                $propertyDoc = $this->docFactory->create($property);
                /** @var Var_[] $varDoc */
                $varDoc = $propertyDoc->getTagsByName('var');

                if (\count($varDoc) === 0) {
                    throw new \RuntimeException(sprintf(
                        'Property "%s" in HookClass "%s" is not typed and has no @var annotation.',
                        $property->getName(),
                        $reflection->getName()
                    ));
                }

                $varDoc = $varDoc[0];
                $type = (string) $varDoc->getType();
            }
$docBlock] = $this->getDocBlock($class$property);
        if (!$docBlock) {
            return null;
        }

        $shortDescription = $docBlock->getSummary();

        if (!empty($shortDescription)) {
            return $shortDescription;
        }

        foreach ($docBlock->getTagsByName('var') as $var) {
            if ($var && !$var instanceof InvalidTag) {
                $varDescription = $var->getDescription()->render();

                if (!empty($varDescription)) {
                    return $varDescription;
                }
            }
        }

        return null;
    }

    
case self::ACCESSOR:
                $tag = '@return';
                break;

            case self::MUTATOR:
                $tag = '@param';
                break;
        }

        $parentClass = null;
        $types = [];
        foreach ($docNode->getTagsByName($tag) as $tagDocNode) {
            if ($tagDocNode->value instanceof InvalidTagValueNode) {
                continue;
            }

            if (
                $tagDocNode->value instanceof ParamTagValueNode
                && null === $prefix
                && $tagDocNode->value->parameterName !== '$'.$property
            ) {
                continue;
            }

            
Home | Imprint | This part of the site doesn't use cookies.