Skip to content

Commit

Permalink
Restore src/Testing/TypeInferenceTestCase.php
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Dec 31, 2022
1 parent 3427331 commit 2b19d35
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/Testing/TypeInferenceTestCase.php
Expand Up @@ -112,18 +112,8 @@ public function assertFileAsserts(
*/
public function gatherAssertTypes(string $file): array
{
$isNamespaced = false;
$requiresNamespace = false;

$asserts = [];
$this->processFile($file, function (Node $node, Scope $scope) use (&$asserts, $file, &$isNamespaced, &$requiresNamespace): void {
if ($node instanceof Node\Stmt\Namespace_) {
$isNamespaced = true;
}
if ($node instanceof Node\Stmt\Class_ && $node->getAttribute('anonymousClass', false) === false || $node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\Trait_) {
$requiresNamespace = true;
}

$this->processFile($file, function (Node $node, Scope $scope) use (&$asserts, $file): void {
if (!$node instanceof Node\Expr\FuncCall) {
return;
}
Expand Down Expand Up @@ -191,10 +181,6 @@ public function gatherAssertTypes(string $file): array
$this->fail(sprintf('File %s does not contain any asserts', $file));
}

if ($requiresNamespace === true && $isNamespaced === false) {
$this->fail(sprintf('File %s does not contain a namespace declaration', $file));
}

return $asserts;
}

Expand Down

0 comments on commit 2b19d35

Please sign in to comment.