getNativeReflection example

if (!$node->class instanceof Name) {
            return [];
        }

        if (!\in_array($node->class->toString(), self::ASSOCIATIONS_WITH_AUTOLOAD, true)) {
            return [];
        }

        $classReflection = $this->reflectionProvider
            ->getClass($node->class->toString())
            ->getNativeReflection();

        $construct = $classReflection->getMethod('__construct');

        $autoloadParamPosition = null;
        $propertyNameParamPosition = null;
        foreach ($construct->getParameters() as $param) {
            if ($param->name === 'autoload') {
                $autoloadParamPosition = $param->getPosition();
            }

            if ($param->name === 'propertyName') {
                

#[Package('core')] trait InTestClassTrait
{
    protected function isInTestClass(Scope $scope): bool
    {
        if (!$scope->isInClass()) {
            return false;
        }

        $definitionClassReflection = $scope->getClassReflection()->getNativeReflection();

        $className = $definitionClassReflection->getName();

        return str_contains(\strtolower($className), 'test') || \str_contains(\strtolower($className), 'tests');
    }
}


        if ($this->isMessageHandler($node)) {
            return ['MessageHandlers must be final, so they cannot be extended/overwritten.'];
        }

        return [];
    }

    private function isMessageHandler(InClassNode $node): bool
    {
        $class = $node->getClassReflection()->getNativeReflection();

        if ($class->isAbstract()) {
            // abstract base classes should not be final             return false;
        }

        return !empty($class->getAttributes(AsMessageHandler::class));
    }
}
$class = $node->getClassReflection();

        if ($class->getParentClass() === null) {
            return false;
        }

        return $class->getParentClass()->getName() === MigrationStep::class;
    }

    private function isMessageHandler(InClassNode $node): bool
    {
        $class = $node->getClassReflection()->getNativeReflection();

        if ($class->isAbstract()) {
            // abstract base classes should not be final             return false;
        }

        return !empty($class->getAttributes(AsMessageHandler::class));
    }

    private function isFinal(ClassReflection $class, string $doc): bool
    {
        
$doc = $node->getDocComment()?->getText() ?? '';
        if ($this->isInternal($doc)) {
            $errors[] = 'Decoration error: Concrete class is marked as @internal. Remove `getDecorated` (if not intended that these classes can be decorated) or remove @internal annotation';
        }

        if ($class->implementsInterface(EventSubscriberInterface::class)) {
            $errors[] = 'Decoration error: Decoration pattern is not compatible with event subscribers. Remove `getDecorated` (if not intended that these classes can be decorated) or extract EventSubscriberInterface into own class';
        }

        // loop all methods and ensure that all public function also inside the parent class         /** @var ReflectionMethod $method */
        foreach ($class->getNativeReflection()->getMethods() as $method) {
            if (!$this->isPublic($method)) {
                continue;
            }

            if ($method->getName() === '__construct') {
                continue;
            }

            if ($parent->hasMethod($method->getName())) {
                continue;
            }

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