-
Notifications
You must be signed in to change notification settings - Fork 46
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
AssertArrayHasKey seems to be not supported #100
Comments
Yes, this should be easy enough. |
@ondrejmirtes I'm not sure it the implementation in commit 6aaff11 is complete. |
@micheh Do you have a false-positive that stems from the current implementation? |
I think at least that it stems from the current implementation. Unit Test: public function testArrayHasKey(): void
{
$object = new ArrayObject(['test' => 'hello']);
self::assertArrayHasKey('test', $object);
$object2 = new ArrayObject(['test' => 'hello']);
if ($object2->offsetExists('test') === false) {
echo 'hello';
}
} In version 0.12.21 PHPStan now reports the error for the PHPUnit assertion ( |
According to the phpdoc Can you provide a fix @micheh ? |
To support ArrayAccess properly I think this issue has to be fixed first: phpstan/phpstan#3323 |
With the current implementation, phpstan-phpunit/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php Lines 292 to 300 in f3ea021
|
Hi @ondrejmirtes, I just got an issue with my tests saying that an offset does not exist in an array.
I tried to add a
assertArrayHasKey
check, without success.I think this assert is not handle by this plugin, am I wrong ?
I'll try to do a PR in order to add the support, I think I'll be able to copy the way
isArray
works.https://github.com/phpstan/phpstan-phpunit/blob/master/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php#L158
The text was updated successfully, but these errors were encountered: