Skip to content

Commit bdf18d1

Browse files
authored
Merge pull request #7 from mrsuh/php-parser
php 8.2
2 parents 064f824 + 4b6bab2 commit bdf18d1

File tree

10 files changed

+91
-0
lines changed

10 files changed

+91
-0
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
- "7.4"
1616
- "8.0"
1717
- "8.1"
18+
- "8.2"
1819
operating-system:
1920
- "ubuntu-latest"
2021

src/Compiler/Parser.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ public static function getNodeTypes(Node &$node): array
158158
case $node instanceof Node\NullableType:
159159
return [&$node->type];
160160
case $node instanceof Node\UnionType:
161+
$nodeTypes = [];
162+
foreach ($node->types as &$nodeType) {
163+
$nodeTypes = array_merge($nodeTypes, self::getNodeTypes($nodeType));
164+
}
165+
return $nodeTypes;
166+
case $node instanceof Node\IntersectionType:
161167
return $node->types;
162168
default:
163169
throw new \TypeError(sprintf('Invalid node type "%s" for getNodeTypes()', get_class($node)));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Test\Command;
4+
5+
use Test\Generic\Box;
6+
7+
class Usage extends Box<>
8+
{
9+
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Test\Entity;
4+
5+
class Bird
6+
{
7+
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Test\Entity;
4+
5+
class Cat
6+
{
7+
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Test\Generic;
4+
5+
use Test\Entity\Bird;
6+
use Test\Entity\Cat;
7+
8+
class Box<BoxA = Bird,BoxB = Cat,BoxC = int> {
9+
10+
public function test($obj): void {
11+
var_dump(Container<BoxA, Cat, BoxC>::class);
12+
}
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Test\Generic;
4+
5+
class Container<ContainerA,ContainerB,ContainerC> {
6+
7+
private readonly null|(ContainerA&ContainerB)|ContainerC|false|true $content = null;//@todo https://github.com/nikic/PHP-Parser/issues/910
8+
9+
public function setContent((ContainerA&ContainerB)|ContainerC|null|false|true $content): (ContainerA&ContainerB)|ContainerC|null|false|true {
10+
11+
}
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Test\Command;
4+
5+
use Test\Generic\Box;
6+
class Usage extends \Test\Generic\BoxForTestEntityBirdAndTestEntityCatAndInt
7+
{
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Test\Generic;
4+
5+
use Test\Entity\Bird;
6+
use Test\Entity\Cat;
7+
class BoxForTestEntityBirdAndTestEntityCatAndInt
8+
{
9+
public function test($obj): void
10+
{
11+
var_dump(\Test\Generic\ContainerForTestEntityBirdAndTestEntityCatAndInt::class);
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Test\Generic;
4+
5+
class ContainerForTestEntityBirdAndTestEntityCatAndInt
6+
{
7+
private readonly null|(\Test\Entity\Bird&\Test\Entity\Cat)|int|false|true $content = null;
8+
//@todo https://github.com/nikic/PHP-Parser/issues/910
9+
public function setContent((\Test\Entity\Bird&\Test\Entity\Cat)|int|null|false|true $content): (\Test\Entity\Bird&\Test\Entity\Cat)|int|null|false|true
10+
{
11+
}
12+
}

0 commit comments

Comments
 (0)