Skip to content

Add a custom expression resolver for type specification #44

Closed

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?

Activity

  1. ondrejmirtes commented on Mar 27, 2019

    @ondrejmirtes
    Member
  2. nesk commented on Mar 28, 2019

    @nesk
    Author

    Great, thank you! 🙂

  3. github-actions commented on May 1, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  4. locked as resolved and limited conversation to collaborators on May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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