Skip to content

Commit acdfa57

Browse files
committed
Add support for PHP 8.0 mixed type
1 parent f2ec9ea commit acdfa57

File tree

6 files changed

+100
-1
lines changed

6 files changed

+100
-1
lines changed

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function __construct() {
142142
[TokenKind::ArrayKeyword, TokenKind::CallableKeyword, TokenKind::BoolReservedWord,
143143
TokenKind::FloatReservedWord, TokenKind::IntReservedWord, TokenKind::StringReservedWord,
144144
TokenKind::ObjectReservedWord, TokenKind::NullReservedWord, TokenKind::FalseReservedWord,
145-
TokenKind::IterableKeyword]; // TODO update spec
145+
TokenKind::IterableKeyword, TokenKind::MixedReservedWord]; // TODO update spec
146146
$this->returnTypeDeclarationTokens = \array_merge([TokenKind::VoidReservedWord, TokenKind::NullReservedWord, TokenKind::FalseReservedWord, TokenKind::StaticKeyword], $this->parameterTypeDeclarationTokens);
147147
}
148148

src/TokenKind.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class TokenKind {
170170
const StringReservedWord = 320;
171171
const BoolReservedWord = 321;
172172
const NullReservedWord = 322;
173+
const MixedReservedWord = 420;
173174

174175
const ScriptSectionStartTag = 323;
175176
const ScriptSectionEndTag = 324;

src/TokenStringMaps.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class TokenStringMaps {
105105
"real" => TokenKind::RealReservedWord,
106106
"void" => TokenKind::VoidReservedWord,
107107
"iterable" => TokenKind::IterableKeyword,
108+
"mixed" => TokenKind::MixedReservedWord,
108109
];
109110

110111
const OPERATORS_AND_PUNCTUATORS = array(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
function foobar(mixed $bar): mixed
4+
{
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"SourceFileNode": {
3+
"statementList": [
4+
{
5+
"InlineHtml": {
6+
"scriptSectionEndTag": null,
7+
"text": null,
8+
"scriptSectionStartTag": {
9+
"kind": "ScriptSectionStartTag",
10+
"textLength": 6
11+
}
12+
}
13+
},
14+
{
15+
"FunctionDeclaration": {
16+
"attributes": null,
17+
"functionKeyword": {
18+
"kind": "FunctionKeyword",
19+
"textLength": 8
20+
},
21+
"byRefToken": null,
22+
"name": {
23+
"kind": "Name",
24+
"textLength": 6
25+
},
26+
"openParen": {
27+
"kind": "OpenParenToken",
28+
"textLength": 1
29+
},
30+
"parameters": {
31+
"ParameterDeclarationList": {
32+
"children": [
33+
{
34+
"Parameter": {
35+
"attributes": null,
36+
"visibilityToken": null,
37+
"questionToken": null,
38+
"typeDeclaration": {
39+
"kind": "MixedReservedWord",
40+
"textLength": 5
41+
},
42+
"otherTypeDeclarations": null,
43+
"byRefToken": null,
44+
"dotDotDotToken": null,
45+
"variableName": {
46+
"kind": "VariableName",
47+
"textLength": 4
48+
},
49+
"equalsToken": null,
50+
"default": null
51+
}
52+
}
53+
]
54+
}
55+
},
56+
"closeParen": {
57+
"kind": "CloseParenToken",
58+
"textLength": 1
59+
},
60+
"colonToken": {
61+
"kind": "ColonToken",
62+
"textLength": 1
63+
},
64+
"questionToken": null,
65+
"returnType": {
66+
"kind": "MixedReservedWord",
67+
"textLength": 5
68+
},
69+
"otherReturnTypes": null,
70+
"compoundStatementOrSemicolon": {
71+
"CompoundStatementNode": {
72+
"openBrace": {
73+
"kind": "OpenBraceToken",
74+
"textLength": 1
75+
},
76+
"statements": [],
77+
"closeBrace": {
78+
"kind": "CloseBraceToken",
79+
"textLength": 1
80+
}
81+
}
82+
}
83+
}
84+
}
85+
],
86+
"endOfFileToken": {
87+
"kind": "EndOfFileToken",
88+
"textLength": 0
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)