Skip to content

Add a custom expression resolver for type specification #44

Closed
@nesk

Description

@nesk

I've create some assertion methods, including those:

assertResponseIsRedirect(Response $response, string $message = ''): void
assertRedirectResponseIsPermanent(RedirectResponse $response, string $message = ''): void

If I create a functional test making a request with Symfony, I want to check if the response is a redirect (with instanceof in my assertion method) and then I want to check if the redirection is permanent:

$response = $this->client->getResponse();
self::assertResponseIsRedirect($response);
self::assertRedirectResponseIsPermanent($response);

If I run PHPStan, I get the following error:

Parameter #1 $response of static method Path\To\TestCase::assertRedirectResponseIsPermanent() expects Symfony\Component\HttpFoundation\RedirectResponse, Symfony\Component\HttpFoundation\Response given.

Is there any way to add a custom expression resolver to AssertTypeSpecifyingExtensionHelper so I can get rid of this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions