Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ConfigEntityConfigExportRule.php

class ConfigEntityConfigExportRule

Hierarchy

  • class \mglaman\PHPStanDrupal\Rules\Deprecations\DeprecatedAnnotationsRuleBase implements \PHPStan\Rules\Rule
    • class \mglaman\PHPStanDrupal\Rules\Deprecations\ConfigEntityConfigExportRule extends \mglaman\PHPStanDrupal\Rules\Deprecations\DeprecatedAnnotationsRuleBase

Expanded class hierarchy of ConfigEntityConfigExportRule

File

vendor/mglaman/phpstan-drupal/src/Rules/Deprecations/ConfigEntityConfigExportRule.php, line 13

Namespace

mglaman\PHPStanDrupal\Rules\Deprecations
View source
final class ConfigEntityConfigExportRule extends DeprecatedAnnotationsRuleBase {
    protected function getExpectedInterface() : string {
        return 'Drupal\\Core\\Config\\Entity\\ConfigEntityInterface';
    }
    protected function doProcessNode(ClassReflection $reflection, Node\Stmt\Class_ $node, Scope $scope) : array {
        $phpDoc = $reflection->getResolvedPhpDoc();
        // Plugins should always be annotated, but maybe this class is missing its
        // annotation since it swaps an existing one.
        if ($phpDoc === null || !$this->isAnnotated($phpDoc)) {
            return [];
        }
        $hasMatch = preg_match('/config_export\\s?=\\s?{/', $phpDoc->getPhpDocString());
        if ($hasMatch === false) {
            throw new ShouldNotHappenException('Unexpected error when trying to run match on phpDoc string.');
        }
        if ($hasMatch === 0) {
            return [
                'Configuration entity must define a `config_export` key. See https://www.drupal.org/node/2481909',
            ];
        }
        return [];
    }
    private function isAnnotated(ResolvedPhpDocBlock $phpDoc) : bool {
        foreach ($phpDoc->getPhpDocNodes() as $docNode) {
            foreach ($docNode->children as $childNode) {
                if ($childNode instanceof PhpDocTagNode && $childNode->name === '@ConfigEntityType') {
                    return true;
                }
            }
        }
        return false;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ConfigEntityConfigExportRule::doProcessNode protected function Overrides DeprecatedAnnotationsRuleBase::doProcessNode
ConfigEntityConfigExportRule::getExpectedInterface protected function Overrides DeprecatedAnnotationsRuleBase::getExpectedInterface
ConfigEntityConfigExportRule::isAnnotated private function
DeprecatedAnnotationsRuleBase::$reflectionProvider protected property
DeprecatedAnnotationsRuleBase::getNodeType public function
DeprecatedAnnotationsRuleBase::processNode public function
DeprecatedAnnotationsRuleBase::__construct public function
RSS feed
Powered by Drupal