You are here

protected function Generic::getProperty in Drupal 7 to 8/9 Module Upgrader 8

Returns the property used by a rewritable expression, or NULL if the property cannot be determined.

Parameters

\Pharborist\ExpressionNode $expr: The rewritable expression.

Return value

string|null

1 call to Generic::getProperty()
Generic::rewrite in src/Plugin/DMU/Rewriter/Generic.php
Parametrically rewrites the function containing the given parameter.

File

src/Plugin/DMU/Rewriter/Generic.php, line 156

Class

Generic
Plugin annotation @Rewriter( id = "_rewriter", deriver = "\Drupal\drupalmoduleupgrader\Plugin\DMU\Rewriter\GenericDeriver" )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Rewriter

Code

protected function getProperty(ExpressionNode $expr) {
  if ($expr instanceof ObjectPropertyNode) {
    return $expr
      ->getPropertyName();
  }
  elseif ($expr instanceof ArrayLookupNode) {
    $key = $expr
      ->getKey(0);
    if ($key instanceof StringNode) {
      return $key
        ->toValue();
    }
  }
}