-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `toString()` tests for all nodes * Fix printing array shapes * Improve callable type printing * Add missing function import
- Loading branch information
Showing
6 changed files
with
608 additions
and
48 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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\PhpDocParser\Ast\ToString; | ||
|
||
use Generator; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayItemNode; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayNode; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFloatNode; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNullNode; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode; | ||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode; | ||
use PHPStan\PhpDocParser\Ast\Node; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ConstExprToStringTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @dataProvider provideConstExprCases | ||
*/ | ||
public function testToString(string $expected, Node $node): void | ||
{ | ||
$this->assertSame($expected, (string) $node); | ||
} | ||
|
||
public static function provideConstExprCases(): Generator | ||
{ | ||
yield from [ | ||
['null', new ConstExprNullNode()], | ||
['true', new ConstExprTrueNode()], | ||
['false', new ConstExprFalseNode()], | ||
['8', new ConstExprIntegerNode('8')], | ||
['21.37', new ConstExprFloatNode('21.37')], | ||
['foo', new ConstExprStringNode('foo')], | ||
['FooBar', new ConstFetchNode('', 'FooBar')], | ||
['Foo\\Bar::Baz', new ConstFetchNode('Foo\\Bar', 'Baz')], | ||
['[]', new ConstExprArrayNode([])], | ||
[ | ||
'[foo, 4 => foo, bar => baz]', | ||
new ConstExprArrayNode([ | ||
new ConstExprArrayItemNode(null, new ConstExprStringNode('foo')), | ||
new ConstExprArrayItemNode(new ConstExprIntegerNode('4'), new ConstExprStringNode('foo')), | ||
new ConstExprArrayItemNode(new ConstExprStringNode('bar'), new ConstExprStringNode('baz')), | ||
]), | ||
], | ||
]; | ||
} | ||
|
||
} |
Oops, something went wrong.