Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phpstan last version cannot assert that JWTAuthenticationFailureResponse extends from Response #1017

Closed
GErpeldinger opened this issue Apr 29, 2022 · 2 comments

Comments

@GErpeldinger
Copy link
Contributor

GErpeldinger commented Apr 29, 2022

Hello since last version of phpstan (1.6), i have an error with the class JWTAuthenticationFailureResponse.

I have the impression that phpstan cannot determine that JWTAuthenticationFailureResponse extends from JsonResponse and therefore from Response, can that be because of the compatibility layer?

Exemple in test:

        $this->client->request(
            method: Request::METHOD_POST,
            uri: '/api/login_check',
            server: ['CONTENT_TYPE' => 'application/json'],
            content: json_encode($credentials, JSON_THROW_ON_ERROR)
        );

        self::assertInstanceOf(JWTAuthenticationFailureResponse::class, $this->client->getResponse());
        self::assertSame('{"code":401,"message":"Invalid credentials."}', $this->client->getResponse()->getContent());
  80     Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with 'Lexik\\Bundle\\JWTAuthenticationBundle\\Response\\JWTAuthenticationFailureResponse' and Symfony\Component\HttpFoundation\Response will always evaluate to false.  

Exemple in code:

class Authenticator extends AbstractAuthenticator
{
   // ...

    public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response {
        return $this->failureHandler->onAuthenticationFailure($request, $exception);
    }
}
  88     Return type (Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationFailureResponse) of method App\Security\Handler\AuthenticationFailureHandler::onAuthenticationFailure() should be compatible with return type  
         (Symfony\Component\HttpFoundation\Response) of method Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface::onAuthenticationFailure() 

Thank for your work.

@GErpeldinger
Copy link
Contributor Author

GErpeldinger commented Apr 29, 2022

Update: I only have the problem when I activate the bleeding edge fonctionnalities to have the new phpstan option to reduce memory consumption, maybe this is an issue to report to their repository rather than here.

Maybe the "Fully static reflection engine"

Update: I have open a new issue on phpstan phpstan/phpstan#7157

@ondrejmirtes
Copy link

The problem isn't in eval - the problem is that Lexik\Bundle\JWTAuthenticationBundle\Response\JWTCompatAuthenticationFailureResponse isn't defined acording to PSR-4 rules configured in that package's composer.json. If you put it to a separate file with the right filename, it's going to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants