Skip to content

Commit

Permalink
Add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm committed Mar 3, 2022
1 parent ade7898 commit fbf6c86
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class NodeScopeResolverTest extends TypeInferenceTestCase

public function dataFileAsserts(): iterable
{
yield from $this->gatherAssertTypes(__DIR__ . '/data/equal.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/identical.php');
return;
require_once __DIR__ . '/data/implode.php';
yield from $this->gatherAssertTypes(__DIR__ . '/data/implode.php');

Expand Down
12 changes: 12 additions & 0 deletions tests/PHPStan/Analyser/data/equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ public function doIpsum(array $a): void

public function stdClass(\stdClass $a, \stdClass $b): void
{
if ($a == $a) {
assertType('stdClass', $a);
} else {
assertType('*NEVER*', $a);
}

if ($b != $b) {
assertType('*NEVER*', $b);
} else {
assertType('stdClass', $b);
}

if ($a == $b) {
assertType('stdClass', $a);
assertType('stdClass', $b);
Expand Down
16 changes: 16 additions & 0 deletions tests/PHPStan/Analyser/data/identical.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ public function foo(\stdClass $a, \stdClass $b): void
assertType('stdClass', $b);
}

if ($a === $b) {
assertType('stdClass', $a);
assertType('stdClass', $b);
} else {
assertType('stdClass', $a);
assertType('stdClass', $b);
}

if ($a !== $b) {
assertType('stdClass', $a);
assertType('stdClass', $b);
} else {
assertType('stdClass', $a);
assertType('stdClass', $b);
}

assertType('stdClass', $a);
assertType('stdClass', $b);
}
Expand Down

0 comments on commit fbf6c86

Please sign in to comment.