Repository navigation
assertInternalType() #34
Copy link
Copy link
Open
Description
Activity
- What’s $this in that case?On Tue, 25 Dec 2018 at 16:55, Joseph Zidell ***@***.***> wrote: I'm using Codeception's wrapper <https://github.com/Codeception/Codeception/blob/2.5/src/Codeception/Util/Shared/Asserts.php#L448-L451> of PHPUnit's assertInternalType <https://github.com/sebastianbergmann/phpunit/blob/master/src/Framework/Assert.php#L1677>, 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 -- — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/phpstan/phpstan/issues/1734>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAGZuPhkbMaRNLFmTLgg0FuLiX_B_z9rks5u8kpsgaJpZM4ZhI_u> .-- Ondřej Mirtes
One of:
- instance of
\Codeception\Test\Unitthat directly extends\PHPUnit\Framework\TestCase(unit tests) - instance of
AcceptanceTesterthat uses a trait_generated\AcceptanceTesterActionswhich wraps the Codeception assert (acceptance tests)
- instance of
In the second case, there are a few layers of wrapper paper, all using the same method name and signature.
- In the first case, the installation of phpstan/phpstan-phpunit extension should be sufficient. Second case is not currently supported, but should be easy to add.On Tue, 25 Dec 2018 at 17:05, Joseph Zidell ***@***.***> wrote: In the second case, there are a few layers of wrapper paper, all using the same method name and signature. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/phpstan/phpstan/issues/1734#issuecomment-449860388>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAGZuJFNQd5RtlsqUUIpi7BhcuuZN-AXks5u8kzRgaJpZM4ZhI_u> .-- Ondřej Mirtes
OK, will give it a whirl
You need to make
$classa constructor parameter in these two classes:- https://github.com/phpstan/phpstan-phpunit/blob/master/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php
- https://github.com/phpstan/phpstan-phpunit/blob/master/src/Type/PHPUnit/Assert/AssertStaticMethodTypeSpecifyingExtension.php
Then you need to specify the class in those services here (as part of
argumentskey... 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.neonwith custom classes.
Metadata
Metadata
Assignees
Labels
No labels
I'm using Codeception's wrapper of PHPUnit's
assertInternalType, and thought phpstan would understand the type.Example code:
Actual result:
Expected result:
-- Nothing --