PhpStorm warning method 'withJson' not found (Slim Framework)

In PhpStorm I get a warning message "warning method" with Json "not found" in \ Psr \ Http \ Message \ ResponseInterface "on line te:

return $response->withJson($toReturn, 200);

      

Code:

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;


$app->get('/bedrijven', function (Request $request, Response $response) {
    require_once(CLASSES_PATH . "/class_bedrijven.php");
    $Bedrijven = new Bedrijven();

    $toReturn = $Bedrijven->get_bedrijven();
    return $response->withJson($toReturn, 200);
});

      

I already updated slim framework with composer to latest 3.8.1 and added Slim as a plugin in PhpStorm. The vendor directory is set to Sources and Exclusion.

The only answer I can find is to disable the warning messages in PhpStorm in Editor -> Inspections -> PHP -> Undefined -> Undefined.

Is there a better solution?

+3


source to share


1 answer


The method is withJson

not defined in \Psr\Http\Message\ResponseInterface

, but in Slim\Http\Response

(which implements the first), this means that this method is related to the Slim platform. You can try this:



use \Psr\Http\Message\ServerRequestInterface as Request;
use \Slim\Http\Response as Response;

      

+6


source







All Articles