Skip to content

Commit

Permalink
NodeTestCase Add "@return" annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre committed Jan 5, 2025
1 parent a2cc09e commit f1fc4f4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Test/NodeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ abstract class NodeTestCase extends TestCase
*/
private $currentEnv;

/**
* @return iterable<array{0: Node, 1: string, 2?: Environment|null, 3?: bool}>
*/
public function getTests()
{
return [];
Expand All @@ -44,13 +47,18 @@ public static function provideTests(): iterable
/**
* @dataProvider getTests
* @dataProvider provideTests
*
* @return void
*/
#[DataProvider('getTests'), DataProvider('provideTests')]
public function testCompile($node, $source, $environment = null, $isPattern = false)
{
$this->assertNodeCompilation($source, $node, $environment, $isPattern);
}

/**
* @return void
*/
public function assertNodeCompilation($source, Node $node, ?Environment $environment = null, $isPattern = false)
{
$compiler = $this->getCompiler($environment);
Expand All @@ -63,12 +71,17 @@ public function assertNodeCompilation($source, Node $node, ?Environment $environ
}
}

/**
* @return Compiler
*/
protected function getCompiler(?Environment $environment = null)
{
return new Compiler($environment ?? $this->getEnvironment());
}

/**
* @return Environment
*
* @final since Twig 3.13
*/
protected function getEnvironment()
Expand All @@ -82,6 +95,8 @@ protected static function createEnvironment(): Environment
}

/**
* @return string
*
* @deprecated since Twig 3.13, use createVariableGetter() instead.
*/
protected function getVariableGetter($name, $line = false)
Expand All @@ -99,6 +114,8 @@ final protected static function createVariableGetter(string $name, bool $line =
}

/**
* @return string
*
* @deprecated since Twig 3.13, use createAttributeGetter() instead.
*/
protected function getAttributeGetter()
Expand Down

0 comments on commit f1fc4f4

Please sign in to comment.