PHPStan\Reflection\ClassReflection::hasProperty PHP Method

hasProperty() public method

public hasProperty ( string $propertyName ) : boolean
$propertyName string
return boolean
    public function hasProperty(string $propertyName) : bool
    {
        foreach ($this->propertiesClassReflectionExtensions as $extension) {
            if ($extension->hasProperty($this, $propertyName)) {
                return true;
            }
        }
        return false;
    }

Usage Example

コード例 #1
0
 public function hasMethod(ClassReflection $classReflection, string $methodName) : bool
 {
     $traitNames = $this->getTraitNames($classReflection->getNativeReflection());
     if (!$classReflection->isSubclassOf(Object::class) && !in_array(\Nette\SmartObject::class, $traitNames, true)) {
         return false;
     }
     if (substr($methodName, 0, 2) !== 'on' || strlen($methodName) <= 2) {
         return false;
     }
     return $classReflection->hasProperty($methodName) && $classReflection->getProperty($methodName)->isPublic();
 }