Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8933 from jack-worman/ReflectionClass_implementsI…
…nterface_assert Closes #8920
- Loading branch information
Showing
4 changed files
with
77 additions
and
15 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
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
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Psalm\Tests; | ||
|
||
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait; | ||
|
||
class ReflectionTest extends TestCase | ||
{ | ||
use ValidCodeAnalysisTestTrait; | ||
|
||
public function providerValidCodeParse(): iterable | ||
{ | ||
yield 'ReflectionClass::isSubclassOf' => [ | ||
'code' => <<<'PHP' | ||
<?php | ||
$a = new ReflectionClass(stdClass::class); | ||
if (!$a->isSubclassOf(Iterator::class)) { | ||
throw new Exception(); | ||
} | ||
PHP, | ||
'assertions' => ['$a===' => 'ReflectionClass<stdClass&Iterator>'], | ||
]; | ||
yield 'ReflectionClass::implementsInterface' => [ | ||
'code' => <<<'PHP' | ||
<?php | ||
$a = new ReflectionClass(stdClass::class); | ||
if (!$a->implementsInterface(Iterator::class)) { | ||
throw new Exception(); | ||
} | ||
PHP, | ||
'assertions' => ['$a===' => 'ReflectionClass<stdClass&Iterator>'], | ||
]; | ||
yield 'ReflectionClass::isInstance' => [ | ||
'code' => <<<'PHP' | ||
<?php | ||
$a = new stdClass(); | ||
$b = new ReflectionClass(Iterator::class); | ||
if (!$b->isInstance($a)) { | ||
throw new Exception(); | ||
} | ||
PHP, | ||
'assertions' => ['$a===' => 'Iterator&stdClass'], | ||
]; | ||
} | ||
} |
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