Skip to content

Commit ff700b3

Browse files
committed
Change lang.ast.types.IsGeneric::$base to lang.ast.Type
1 parent 659d707 commit ff700b3

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/main/php/lang/ast/syntax/PHP.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ private function type0($parse, $optional) {
12271227
if ('array' === $type) {
12281228
return 1 === sizeof($components) ? new IsArray($components[0]) : new IsMap($components[0], $components[1]);
12291229
} else {
1230-
return new IsGeneric($type, $components);
1230+
return new IsGeneric(new IsValue($type), $components);
12311231
}
12321232
}
12331233

src/main/php/lang/ast/types/IsGeneric.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class IsGeneric extends Type {
88
/**
99
* Creates a new type
1010
*
11-
* @param string $base
11+
* @param parent $base
1212
* @param parent[] $components
1313
*/
1414
public function __construct($base, $components= []) {

src/test/php/lang/ast/unittest/TypeTest.class.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,26 @@ public function nullable($t) {
4444

4545
#[Test, Values(['int', 'string'])]
4646
public function generic_list($t) {
47-
Assert::equals(new IsGeneric('List', [new IsLiteral($t)]), $this->parse('List<'.$t.'>'));
47+
Assert::equals(
48+
new IsGeneric(new IsValue('List'), [new IsLiteral($t)]),
49+
$this->parse('List<'.$t.'>')
50+
);
4851
}
4952

5053
#[Test, Values(['int', 'string'])]
5154
public function generic_map($t) {
52-
Assert::equals(new IsGeneric('Map', [new IsLiteral('string'), new IsLiteral($t)]), $this->parse('Map<string, '.$t.'>'));
55+
Assert::equals(
56+
new IsGeneric(new IsValue('Map'), [new IsLiteral('string'), new IsLiteral($t)]),
57+
$this->parse('Map<string, '.$t.'>')
58+
);
59+
}
60+
61+
#[Test]
62+
public function nested_generic() {
63+
Assert::equals(
64+
new IsGeneric(new IsValue('Filter'), [new IsGeneric(new IsValue('Set'), [new IsLiteral('T')])]),
65+
$this->parse('Filter<Set<T>>')
66+
);
5367
}
5468

5569
#[Test, Values(['self', 'static', 'parent', 'Value', '\\lang\\Value',])]

0 commit comments

Comments
 (0)