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

processNode() public method

public processNode ( PhpParser\Node $node, Scope $scope ) : array
$node PhpParser\Node
$scope PHPStan\Analyser\Scope
return array
    public function processNode(Node $node, Scope $scope) : array
    {
        if (!$node->var instanceof Node\Expr\PropertyFetch && !$node->var instanceof Node\Expr\StaticPropertyFetch) {
            return [];
        }
        $propertyType = $scope->getType($node->var);
        $assignedValueType = $scope->getType($node->expr);
        if (!$propertyType->accepts($assignedValueType)) {
            $propertyDescription = $this->describeProperty($node->var, $scope);
            if ($propertyDescription === null) {
                return [];
            }
            return [sprintf('%s (%s) does not accept %s.', $propertyDescription, $propertyType->describe(), $assignedValueType->describe())];
        }
        return [];
    }