Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extract creating PhpDocParser to setUp
  • Loading branch information
ondrejmirtes committed Apr 28, 2023
commit 68d46b98b080c1652b64ed4b91d10f38f5ac8a5d
29 changes: 18 additions & 11 deletions 29 tests/PHPStan/Printer/PrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@
class PrinterTest extends TestCase
{

/** @var PhpDocParser */
private $phpDocParser;

protected function setUp(): void
{
$usedAttributes = ['lines' => true, 'indexes' => true];
$constExprParser = new ConstExprParser(true, true, $usedAttributes);
$this->phpDocParser = new PhpDocParser(
new TypeParser($constExprParser, true, $usedAttributes),
$constExprParser,
true,
true,
$usedAttributes
);
}

/**
* @return iterable<array{string, string, NodeVisitor}>
*/
Expand Down Expand Up @@ -1153,18 +1169,9 @@ public function enterNode(Node $node)
*/
public function testPrintFormatPreserving(string $phpDoc, string $expectedResult, NodeVisitor $visitor): void
{
$usedAttributes = ['lines' => true, 'indexes' => true];
$constExprParser = new ConstExprParser(true, true, $usedAttributes);
$phpDocParser = new PhpDocParser(
new TypeParser($constExprParser, true, $usedAttributes),
$constExprParser,
true,
true,
$usedAttributes
);
$lexer = new Lexer();
$tokens = new TokenIterator($lexer->tokenize($phpDoc));
$phpDocNode = $phpDocParser->parse($tokens);
$phpDocNode = $this->phpDocParser->parse($tokens);
$cloningTraverser = new NodeTraverser([new NodeVisitor\CloningVisitor()]);
$newNodes = $cloningTraverser->traverse([$phpDocNode]);

Expand All @@ -1179,7 +1186,7 @@ public function testPrintFormatPreserving(string $phpDoc, string $expectedResult

$this->assertEquals(
$this->unsetAttributes($newNode),
$this->unsetAttributes($phpDocParser->parse(new TokenIterator($lexer->tokenize($newPhpDoc))))
$this->unsetAttributes($this->phpDocParser->parse(new TokenIterator($lexer->tokenize($newPhpDoc))))
);
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.