isMessageHandler example

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

        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()) {
            
return ['Classes in `' . $namespace . '` namespace must be flagged @internal to not be captured by the BC checker.'];
        }

        if ($this->isInNamespace($node, '\\Framework\\Demodata') && !\in_array($class, self::DEMO_DATA_EXCEPTIONS, true)) {
            return ['Classes in `Framework\\Demodata` namespace must be flagged @internal to not be captured by the BC checker.'];
        }

        if ($this->isMigrationStep($node)) {
            return ['Migrations must be flagged @internal to not be captured by the BC checker.'];
        }

        if ($this->isMessageHandler($node) && !\in_array($class, self::MESSAGE_HANDLER_EXCEPTIONS, true)) {
            return ['MessageHandlers must be flagged @internal to not be captured by the BC checker.'];
        }

        if ($this->isParentInternalAndAbstract($scope) && !$this->isFinal($node->getClassReflection()$doc)) {
            return ['Classes that extend an @internal abstract class must be flagged @internal or @final to not be captured by the BC checker.'];
        }

        return [];
    }

    private function isTestClass(InClassNode $node): bool
    {
Home | Imprint | This part of the site doesn't use cookies.