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

Breadcrumb

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

function ConfigEntityConfigExportRule::doProcessNode

Overrides DeprecatedAnnotationsRuleBase::doProcessNode

File

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

Class

ConfigEntityConfigExportRule

Namespace

mglaman\PHPStanDrupal\Rules\Deprecations

Code

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 [];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal