/** * @param \PhpParser\Node\Stmt\Return_ $node * @param \PHPStan\Analyser\Scope $scope * @return string[] */ public function processNode(Node $node, Scope $scope) : array { if ($scope->getFunction() === null) { return []; } if ($scope->isInAnonymousFunction()) { return []; } $method = $scope->getFunction(); if (!$method instanceof MethodReflection) { return []; } return $this->returnTypeCheck->checkReturnType($scope, $method->getReturnType(), $node->expr, sprintf('Method %s::%s() should return %%s but empty return statement found.', $method->getDeclaringClass()->getName(), $method->getName()), sprintf('Method %s::%s() with return type void returns %%s but should not return anything.', $method->getDeclaringClass()->getName(), $method->getName()), sprintf('Method %s::%s() should return %%s but returns %%s.', $method->getDeclaringClass()->getName(), $method->getName())); }