You are here

protected function FixerBase::usesTrait in Drupal 7 to 8/9 Module Upgrader 8

Returns if a node uses a specific trait anywhere in its lineage.

Parameters

\Pharborist\NodeInterface $node:

Return value

bool

1 call to FixerBase::usesTrait()
Notify::supportsDocComments in src/Plugin/DMU/Fixer/Notify.php
Returns if a node supports doc comments by importing DocCommentTrait anywhere in its lineage.

File

src/FixerBase.php, line 36

Class

FixerBase
Base class for fixers, containing a lot of helpful utilities.

Namespace

Drupal\drupalmoduleupgrader

Code

protected function usesTrait($trait, NodeInterface $node) {
  $hierarchy = class_parents($node);
  array_unshift($hierarchy, get_class($node));
  $traits = [];
  foreach ($hierarchy as $parent) {
    $this
      ->collectTraits($parent, $traits);
  }
  return in_array($trait, $traits);
}