PHPStan\Analyser\Scope::canAccessProperty PHP Method

canAccessProperty() public method

public canAccessProperty ( PHPStan\Reflection\PropertyReflection $propertyReflection ) : boolean
$propertyReflection PHPStan\Reflection\PropertyReflection
return boolean
    public function canAccessProperty(PropertyReflection $propertyReflection) : bool
    {
        return $this->canAccessClassMember($propertyReflection);
    }

Usage Example

Example #1
0
 public function getProperty(string $propertyName, Scope $scope = null) : PropertyReflection
 {
     if (!isset($this->properties[$propertyName])) {
         $privateProperty = null;
         $publicProperty = null;
         foreach ($this->propertiesClassReflectionExtensions as $extension) {
             if ($extension->hasProperty($this, $propertyName)) {
                 $property = $extension->getProperty($this, $propertyName);
                 if ($scope !== null && $scope->canAccessProperty($property)) {
                     return $this->properties[$propertyName] = $property;
                 }
                 $this->properties[$propertyName] = $property;
             }
         }
     }
     if (!isset($this->properties[$propertyName])) {
         throw new \PHPStan\Reflection\MissingPropertyFromReflectionException($this->getName(), $propertyName);
     }
     return $this->properties[$propertyName];
 }