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

assertInternalType() #34

Open
josephzidell opened this issue Dec 25, 2018 · 6 comments · May be fixed by #65
Open

assertInternalType() #34

josephzidell opened this issue Dec 25, 2018 · 6 comments · May be fixed by #65

Comments

@josephzidell
Copy link

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

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Dec 25, 2018 via email

@josephzidell
Copy link
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
Copy link
Author

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

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Dec 25, 2018 via email

@josephzidell
Copy link
Author

OK, will give it a whirl

@ondrejmirtes ondrejmirtes transferred this issue from phpstan/phpstan Dec 27, 2018
@ondrejmirtes
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants