getVariableName example



        return $arguments;
    }

    /** * @param Param[] $paramDocs */
    private function findDocForParam(array $paramDocs, string $name, \ReflectionMethod $method, DocBlock $docBlock): Param
    {
        foreach ($paramDocs as $param) {
            if ($param->getVariableName() === $name) {
                return $param;
            }
        }

        throw new \RuntimeException(sprintf(
            'Missing doc block for param "$%s" on method "%s()" in class "%s",',
            $name,
            $method->getName(),
            $method->getDeclaringClass()->getName()
        ));
    }

    
try {
            $docBlock = $this->docBlockFactory->create($reflectionConstructor$this->contextFactory->createFromReflector($reflectionConstructor));

            return $this->filterDocBlockParams($docBlock$property);
        } catch (\InvalidArgumentException) {
            return null;
        }
    }

    private function filterDocBlockParams(DocBlock $docBlock, string $allowedParam): DocBlock
    {
        $tags = array_values(array_filter($docBlock->getTagsByName('param')fn ($tag) => $tag instanceof DocBlock\Tags\Param && $allowedParam === $tag->getVariableName()));

        return new DocBlock($docBlock->getSummary()$docBlock->getDescription()$tags$docBlock->getContext(),
            $docBlock->getLocation()$docBlock->isTemplateStart()$docBlock->isTemplateEnd());
    }

    /** * @return array{DocBlock|null, int|null, string|null} */
    private function getDocBlock(string $class, string $property): array
    {
        $propertyHash = sprintf('%s::%s', $class$property);

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