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

Breadcrumb

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

function EntityFieldsViaMagicReflectionExtension::getProperty

File

vendor/mglaman/phpstan-drupal/src/Reflection/EntityFieldsViaMagicReflectionExtension.php, line 54

Class

EntityFieldsViaMagicReflectionExtension
Allows field access via magic methods

Namespace

mglaman\PHPStanDrupal\Reflection

Code

public function getProperty(ClassReflection $classReflection, string $propertyName) : PropertyReflection {
    if ($classReflection->implementsInterface('Drupal\\Core\\Entity\\EntityInterface')) {
        return new EntityFieldReflection($classReflection, $propertyName);
    }
    if (self::classObjectIsSuperOfInterface($classReflection->getName(), self::getFieldItemListInterfaceObject())
        ->yes()) {
        return new FieldItemListPropertyReflection($classReflection, $propertyName);
    }
    throw new LogicException($classReflection->getName() . "::{$propertyName} should be handled earlier.");
}
RSS feed
Powered by Drupal