Skip to content

assertInternalType() #34

Description

@josephzidell

I'm using Codeception's wrapper of PHPUnit's assertInternalType, and thought phpstan would understand the type.

Example code:

$feedHandle = fopen('php://temp', 'rw+');
$this->assertInternalType('resource', $feedHandle);
fwrite($feedHandle, $feed);

Actual result:

Parameter #1 $fp of function fwrite expects resource, resource|false given.

Expected result:
-- Nothing --

Activity

  1. ondrejmirtes commented on Dec 25, 2018

    @ondrejmirtes
    Member
  2. josephzidell commented on Dec 25, 2018

    @josephzidell
    Author

    One of:

    • instance of \Codeception\Test\Unit that directly extends \PHPUnit\Framework\TestCase (unit tests)
    • instance of AcceptanceTester that uses a trait _generated\AcceptanceTesterActions which wraps the Codeception assert (acceptance tests)
  3. josephzidell commented on Dec 25, 2018

    @josephzidell
    Author

    In the second case, there are a few layers of wrapper paper, all using the same method name and signature.

  4. ondrejmirtes commented on Dec 25, 2018

    @ondrejmirtes
    Member
  5. josephzidell commented on Dec 26, 2018

    @josephzidell
    Author

    OK, will give it a whirl

  6. ondrejmirtes commented on Dec 27, 2018

    @ondrejmirtes
    Member

    You need to make $class a constructor parameter in these two classes:

    Then you need to specify the class in those services here (as part of arguments key... check PHPStan configs for how it's done):

    Once this change is merged, you will be able to register these services in your own phpstan.neon with custom classes.

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