-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
316f269
commit 10b295f
Showing
4 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleEqualsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Rules\Comparison; | ||
|
||
use PHPStan\Rules\Rule; | ||
use PHPStan\Testing\RuleTestCase; | ||
|
||
/** | ||
* @extends RuleTestCase<ImpossibleCheckTypeMethodCallRule> | ||
*/ | ||
class ImpossibleCheckTypeMethodCallRuleEqualsTest extends RuleTestCase | ||
{ | ||
|
||
public function getRule(): Rule | ||
{ | ||
return new ImpossibleCheckTypeMethodCallRule( | ||
new ImpossibleCheckTypeHelper( | ||
$this->createReflectionProvider(), | ||
$this->getTypeSpecifier(), | ||
[], | ||
true, | ||
), | ||
true, | ||
true, | ||
); | ||
} | ||
|
||
public function testRule(): void | ||
{ | ||
$this->analyse([__DIR__ . '/data/impossible-method-call.php'], [ | ||
[ | ||
'Call to method PHPStan\Tests\AssertionClass::assertString() with string will always evaluate to true.', | ||
14, | ||
], | ||
[ | ||
'Call to method PHPStan\Tests\AssertionClass::assertString() with int will always evaluate to false.', | ||
15, | ||
], | ||
[ | ||
'Call to method PHPStan\Tests\AssertionClass::assertNotInt() with int will always evaluate to false.', | ||
30, | ||
], | ||
[ | ||
'Call to method PHPStan\Tests\AssertionClass::assertNotInt() with string will always evaluate to true.', | ||
36, | ||
], | ||
[ | ||
'Call to method ImpossibleMethodCall\Foo::isSame() with 1 and 1 will always evaluate to true.', | ||
60, | ||
], | ||
[ | ||
'Call to method ImpossibleMethodCall\Foo::isSame() with 1 and 2 will always evaluate to false.', | ||
63, | ||
], | ||
[ | ||
'Call to method ImpossibleMethodCall\Foo::isNotSame() with 1 and 1 will always evaluate to false.', | ||
66, | ||
], | ||
[ | ||
'Call to method ImpossibleMethodCall\Foo::isNotSame() with 1 and 2 will always evaluate to true.', | ||
69, | ||
], | ||
[ | ||
'Call to method ImpossibleMethodCall\Foo::isSame() with stdClass and stdClass will always evaluate to true.', | ||
78, | ||
], | ||
[ | ||
'Call to method ImpossibleMethodCall\Foo::isNotSame() with stdClass and stdClass will always evaluate to false.', | ||
81, | ||
], | ||
]); | ||
} | ||
|
||
public static function getAdditionalConfigFiles(): array | ||
{ | ||
return [ | ||
__DIR__ . '/impossible-check-type-method-call-equals.neon', | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/PHPStan/Rules/Comparison/impossible-check-type-method-call-equals.neon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
services: | ||
- | ||
class: PHPStan\Tests\AssertionClassMethodTypeSpecifyingExtension | ||
arguments: | ||
nullContext: null | ||
tags: | ||
- phpstan.typeSpecifier.methodTypeSpecifyingExtension | ||
- | ||
class: PHPStan\Rules\Comparison\AssertNotInt | ||
tags: | ||
- phpstan.typeSpecifier.methodTypeSpecifyingExtension | ||
- | ||
class: PHPStan\Rules\Comparison\FooIsEqual | ||
tags: | ||
- phpstan.typeSpecifier.methodTypeSpecifyingExtension | ||
- | ||
class: PHPStan\Rules\Comparison\FooIsNotEqual | ||
tags: | ||
- phpstan.typeSpecifier.methodTypeSpecifyingExtension |