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

Breadcrumb

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

function EntityFieldMethodsViaMagicReflectionExtension::hasMethod

File

vendor/mglaman/phpstan-drupal/src/Reflection/EntityFieldMethodsViaMagicReflectionExtension.php, line 17

Class

EntityFieldMethodsViaMagicReflectionExtension
Allows some common methods on fields.

Namespace

mglaman\PHPStanDrupal\Reflection

Code

public function hasMethod(ClassReflection $classReflection, string $methodName) : bool {
    if ($classReflection->hasNativeMethod($methodName) || array_key_exists($methodName, $classReflection->getMethodTags())) {
        // Let other parts of PHPStan handle this.
        return false;
    }
    $interfaceObject = new ObjectType('Drupal\\Core\\Field\\FieldItemListInterface');
    $objectType = new ObjectType($classReflection->getName());
    if (!$interfaceObject->isSuperTypeOf($objectType)
        ->yes()) {
        return false;
    }
    if ($methodName === 'referencedEntities') {
        return true;
    }
    return false;
}
RSS feed
Powered by Drupal