All,
Inside of a Laracasts Commander Handler any sort of return statement is frowned upon by PHP Storm. The warning is function declared void must not return a value.
Although it does work is it bad practice and therefore PHP Storm has an issue or is it just that PHP Storm cannot resolve back to request?
Example, this will work but PHP Storm will give me the above warning.
public function handle($command)
{
return $this->UserRepository->findUserbyUserId($command->userId);
}
Option 2 - Return based on condition:
public function handle($command)
{
$value = $this->UserRepository->findUserbyUserId($command->userId);
if (is_null($value))
{
return 'This failed' // and or a error, a constant but ensure something is returned
}
else
{
return $value;
}
Option 3 - only one return
public function handle($command)
{
$value = $this->UserRepository->findUserbyUserId($command->userId);
if (is_null($value))
{
$statusCode = 'This failed';
}
else
{
$statusCode = '$value;
}
return $statusCode;
or some sort of other option?
Thanks
Nolan