--level used: 5Hello!
I'm trying Larastan in a new and really small project, which is a much better experience than doing so in an old and messy one... 馃槄
When running the checks I get this error in a default Laravel file that has no modifications:
------ ------------------------------------------------------------------------------------------------------------------
Line Http/Middleware/Authenticate.php
------ ------------------------------------------------------------------------------------------------------------------
17 Method App\Http\Middleware\Authenticate::redirectTo() should return string|null but return statement is missing.
------ ------------------------------------------------------------------------------------------------------------------
It's a default Laravel file: app/Http/Middleware/Authenticate.php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
Is this something PHPStan/Larastan will eventually understand?
If that condition is false PHP implicitly returns null.
Write readable code! Be explicit! Add return null; to the end of that method.
Yep! Forgot to mention that's exactly the code change I made.
So it's just a matter of PHPStan wanting the explicit return statement?
So it's just a matter of PHPStan wanting the explicit return statement?
We humans 馃 also want explicit code 馃槂
Hahaha 鉂わ笍
Most helpful comment
Hahaha 鉂わ笍