Skip to content

Commit e2b89c5

Browse files
committed
Some extra tests for callable syntax
1 parent 928179e commit e2b89c5

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/PHPStan/Parser/PhpDocParserTest.php

+53
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
use PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode;
2323
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
2424
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
25+
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
26+
use PHPStan\PhpDocParser\Ast\Type\CallableTypeParameterNode;
2527
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
2628
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
2729
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
@@ -1603,6 +1605,57 @@ public function provideSingleLinePhpDocData(): \Iterator
16031605
),
16041606
]),
16051607
];
1608+
1609+
yield [
1610+
'callable with space between keyword and parameters',
1611+
'/** @var callable (int): void */',
1612+
new PhpDocNode([
1613+
new PhpDocTagNode(
1614+
'@var',
1615+
new VarTagValueNode(
1616+
new CallableTypeNode(
1617+
new IdentifierTypeNode('callable'),
1618+
[
1619+
new CallableTypeParameterNode(new IdentifierTypeNode('int'), false, false, '', false)
1620+
],
1621+
new IdentifierTypeNode('void')
1622+
),
1623+
'',
1624+
''
1625+
)
1626+
),
1627+
]),
1628+
];
1629+
1630+
yield [
1631+
'callable with description in parentheses',
1632+
'/** @var callable (int) */',
1633+
new PhpDocNode([
1634+
new PhpDocTagNode(
1635+
'@var',
1636+
new VarTagValueNode(
1637+
new IdentifierTypeNode('callable'),
1638+
'',
1639+
'(int)'
1640+
)
1641+
),
1642+
]),
1643+
];
1644+
1645+
yield [
1646+
'callable with incomplete signature without return type',
1647+
'/** @var callable(int) */',
1648+
new PhpDocNode([
1649+
new PhpDocTagNode(
1650+
'@var',
1651+
new VarTagValueNode(
1652+
new IdentifierTypeNode('callable'),
1653+
'',
1654+
'(int)'
1655+
)
1656+
),
1657+
]),
1658+
];
16061659
}
16071660

16081661

0 commit comments

Comments
 (0)