public function processNode(Node $node, Scope $scope) : array
{
if ($scope->getClass() === null || !$this->broker->hasClass($scope->getClass())) {
return [];
}
$classReflection = $this->broker->getClass($scope->getClass());
$errors = [];
foreach ($node->props as $property) {
if ($property->default === null) {
continue;
}
if ($property->default instanceof Node\Expr\ConstFetch && (string) $property->default->name === 'null') {
continue;
}
$propertyReflection = $classReflection->getProperty($property->name);
$propertyType = $propertyReflection->getType();
$defaultValueType = $scope->getType($property->default);
if ($propertyType->accepts($defaultValueType)) {
continue;
}
$errors[] = sprintf('%s %s::$%s (%s) does not accept default value of type %s.', $node->isStatic() ? 'Static property' : 'Property', $scope->getClass(), $property->name, $propertyType->describe(), $defaultValueType->describe());
}
return $errors;
}