isInClass example

AbstractAppLifecycle::class,
        AbstractAppUrlChangeStrategy::class,
    ];

    public function getNodeType(): string
    {
        return InClassNode::class;
    }

    public function processNode(Node $node, Scope $scope): array
    {
        if ($this->isInTestClass($scope) || !$scope->isInClass()) {
            return [];
        }

        // any anonymous class can be skipped         if (\str_starts_with($scope->getClassReflection()->getName(), 'AnonymousClass')) {
            return [];
        }

        $class = $scope->getClassReflection();

        // some classes can be skipped because they are only for internal decorations (e.g. App stuff)

        return ClassMethod::class;
    }

    /** * @param ClassMethod $node * * @return array<array-key, RuleError|string> */
    public function processNode(Node $node, Scope $scope): array
    {
        if (!$scope->isInClass()) {
            // skip             return [];
        }

        $class = $scope->getClassReflection();

        if ($class->isInterface() || $this->isTestClass($class)) {
            return [];
        }

        if (!($node->isPublic() || $node->isProtected()) || $node->isAbstract() || $node->isMagic()) {
            
use PHPStan\Analyser\Scope;
use Shopware\Core\Framework\Log\Package;

/** * @internal */
#[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');
    }
}
return ClassMethod::class;
    }

    /** * @param ClassMethod $node * * @return array<array-key, RuleError|string> */
    public function processNode(Node $node, Scope $scope): array
    {
        // no class method         if (!$scope->isInClass()) {
            return [];
        }

        // already marked as internal         if ($this->hasInternalComment($node)) {
            return [];
        }

        $class = $scope->getClassReflection();
        // complete class is marked as internal         if ($class !== null && $class->isInternal()) {
            

        return New_::class;
    }

    /** * @param New_ $node * * @return array<array-key, RuleError|string> */
    public function processNode(Node $node, Scope $scope): array
    {
        if (!$scope->isInClass()) {
            return [];
        }

        if ($this->isInTestClass($scope)) {
            // if in a test namespace, don't care             return [];
        }

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

        
private ReflectionProvider $reflectionProvider
    ) {
    }

    public function getNodeType(): string
    {
        return Throw_::class;
    }

    public function processNode(Node $node, Scope $scope): array
    {
        if ($this->isInTestClass($scope) || !$scope->isInClass()) {
            return [];
        }

        if (!$node instanceof Throw_) {
            return [];
        }

        if ($node->expr instanceof Node\Expr\StaticCall) {
            return $this->validateDomainExceptionClass($node->expr, $scope);
        }

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