Skip to content

assertInternalType() #34

Open
Open
@josephzidell

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

ondrejmirtes

ondrejmirtes commented on Dec 25, 2018

@ondrejmirtes
Member
josephzidell

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)
josephzidell

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.

ondrejmirtes

ondrejmirtes commented on Dec 25, 2018

@ondrejmirtes
Member
josephzidell

josephzidell commented on Dec 26, 2018

@josephzidell
Author

OK, will give it a whirl

ondrejmirtes

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

      Participants

      @ondrejmirtes@josephzidell

      Issue actions

        assertInternalType() · Issue #34 · phpstan/phpstan-phpunit