Does not look like an error, but rather phpstorm suggesting a fix. Perhaps the indent is wrong. Hover to see the message
Phpstorm marks PHP as error
Hi devs, I have a problem with Phpstorm, it marks all my PHP codes as errors. I use Inertia js with Laravel.
Bellow is a screenshot. https://ibb.co/FHgSbMG
The code is correct. I tried to change PHP version, but didn't work.
@Sinnbeck I did what you said, I imported some classes and the code become like this. https://ibb.co/8bSwB2X
@hamzaelmaghari looks perfect I think?
@Sinnbeck Yes, thanks ... the problem was PHPDoc.
@hamzaelmaghari ah ok. Wrong return type I assume. Personally I set the return on the method directly :)
@Sinnbeck How can I do it in my situation? What I'm doing here is I'm following InertiJs installation proccess.
@hamzaelmaghari post the code and I will show you :)
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
use Inertia\Inertia;
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
/**
* Prepare exception for rendering.
*
* @param \Throwable $e
* @return \Throwable
*/
public function render($request, Throwable $e)
{
$response = parent::render($request, $e);
if (!app()->environment('local') && in_array($response->status(), [500, 503, 404, 403])) {
return Inertia::render('Error', ['status' => $response->status()])
->toResponse($request)
->setStatusCode($response->status());
} else if ($response->status() === 419) {
return back()->with([
'message' => 'The page expired, please try again.',
]);
}
return $response;
}
//
}
````
@hamzaelmaghari ok. Instead of @return you can add it to the right of the method.
Here I set it to expect that the code returns an instance of the Response class
public function render($request, Throwable $e) : Response
@Sinnbeck Ok I did it, unfortunately the underlines didn't hide ... I think will keep the mothod without comment.
This makes the file clean
@hamzaelmaghari ok cool :)
Please or to participate in this conversation.