PHPStan\Rules\Classes\TypesAssignedToPropertiesRule::describeProperty PHP Method

describeProperty() private method

private describeProperty ( PhpParser\Node\Expr\PropertyFetch | PhpParser\Node\Expr\StaticPropertyFetch $propertyFetch, Scope $scope ) : string | null
$propertyFetch PhpParser\Node\Expr\PropertyFetch | PhpParser\Node\Expr\StaticPropertyFetch
$scope PHPStan\Analyser\Scope
return string | null
    private function describeProperty($propertyFetch, Scope $scope)
    {
        if ($propertyFetch instanceof Node\Expr\PropertyFetch) {
            if (!is_string($propertyFetch->name)) {
                return null;
            }
            $propertyHolderType = $scope->getType($propertyFetch->var);
            if ($propertyHolderType->getClass() === null) {
                return null;
            }
            return sprintf('Property %s::$%s', $propertyHolderType->getClass(), $propertyFetch->name);
        } elseif ($propertyFetch instanceof Node\Expr\StaticPropertyFetch) {
            if (!$propertyFetch->class instanceof Node\Name || !is_string($propertyFetch->name)) {
                return null;
            }
            return sprintf('Static property %s::$%s', $scope->resolveName($propertyFetch->class), $propertyFetch->name);
        }
        return null;
    }