Skip to content

Commit 281555d

Browse files
committed
Migrate to the final version of PHP-Parser 5.0.0
1 parent 73722df commit 281555d

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

build/gen_stub.php

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use PhpParser\Comment\Doc as DocComment;
55
use PhpParser\ConstExprEvaluator;
6+
use PhpParser\Modifiers;
67
use PhpParser\Node;
78
use PhpParser\Node\AttributeGroup;
89
use PhpParser\Node\Expr;
@@ -1260,12 +1261,12 @@ public function isMethod(): bool
12601261

12611262
public function isFinalMethod(): bool
12621263
{
1263-
return ($this->flags & Class_::MODIFIER_FINAL) || ($this->classFlags & Class_::MODIFIER_FINAL);
1264+
return ($this->flags & Modifiers::FINAL) || ($this->classFlags & Modifiers::FINAL);
12641265
}
12651266

12661267
public function isInstanceMethod(): bool
12671268
{
1268-
return !($this->flags & Class_::MODIFIER_STATIC) && $this->isMethod() && !$this->name->isConstructor();
1269+
return !($this->flags & Modifiers::STATIC) && $this->isMethod() && !$this->name->isConstructor();
12691270
}
12701271

12711272
/** @return string[] */
@@ -1277,21 +1278,21 @@ public function getModifierNames(): array
12771278

12781279
$result = [];
12791280

1280-
if ($this->flags & Class_::MODIFIER_FINAL) {
1281+
if ($this->flags & Modifiers::FINAL) {
12811282
$result[] = "final";
1282-
} elseif ($this->flags & Class_::MODIFIER_ABSTRACT && $this->classFlags & ~Class_::MODIFIER_ABSTRACT) {
1283+
} elseif ($this->flags & Modifiers::ABSTRACT && $this->classFlags & ~Modifiers::ABSTRACT) {
12831284
$result[] = "abstract";
12841285
}
12851286

1286-
if ($this->flags & Class_::MODIFIER_PROTECTED) {
1287+
if ($this->flags & Modifiers::PROTECTED) {
12871288
$result[] = "protected";
1288-
} elseif ($this->flags & Class_::MODIFIER_PRIVATE) {
1289+
} elseif ($this->flags & Modifiers::PRIVATE) {
12891290
$result[] = "private";
12901291
} else {
12911292
$result[] = "public";
12921293
}
12931294

1294-
if ($this->flags & Class_::MODIFIER_STATIC) {
1295+
if ($this->flags & Modifiers::STATIC) {
12951296
$result[] = "static";
12961297
}
12971298

@@ -1338,7 +1339,7 @@ public function getDeclarationKey(): string
13381339

13391340
public function getDeclaration(): ?string
13401341
{
1341-
if ($this->flags & Class_::MODIFIER_ABSTRACT) {
1342+
if ($this->flags & Modifiers::ABSTRACT) {
13421343
return null;
13431344
}
13441345

@@ -1367,7 +1368,7 @@ public function getFunctionEntry(): string {
13671368
}
13681369
} else {
13691370
$declarationClassName = $this->name->getDeclarationClassName();
1370-
if ($this->flags & Class_::MODIFIER_ABSTRACT) {
1371+
if ($this->flags & Modifiers::ABSTRACT) {
13711372
return sprintf(
13721373
"\tZEND_ABSTRACT_ME_WITH_FLAGS(%s, %s, %s, %s)\n",
13731374
$declarationClassName, $this->name->methodName, $this->getArgInfoName(),
@@ -1458,21 +1459,21 @@ public function discardInfoForOldPhpVersions(): void {
14581459
private function getFlagsAsArginfoString(): string
14591460
{
14601461
$flags = "ZEND_ACC_PUBLIC";
1461-
if ($this->flags & Class_::MODIFIER_PROTECTED) {
1462+
if ($this->flags & Modifiers::PROTECTED) {
14621463
$flags = "ZEND_ACC_PROTECTED";
1463-
} elseif ($this->flags & Class_::MODIFIER_PRIVATE) {
1464+
} elseif ($this->flags & Modifiers::PRIVATE) {
14641465
$flags = "ZEND_ACC_PRIVATE";
14651466
}
14661467

1467-
if ($this->flags & Class_::MODIFIER_STATIC) {
1468+
if ($this->flags & Modifiers::STATIC) {
14681469
$flags .= "|ZEND_ACC_STATIC";
14691470
}
14701471

1471-
if ($this->flags & Class_::MODIFIER_FINAL) {
1472+
if ($this->flags & Modifiers::FINAL) {
14721473
$flags .= "|ZEND_ACC_FINAL";
14731474
}
14741475

1475-
if ($this->flags & Class_::MODIFIER_ABSTRACT) {
1476+
if ($this->flags & Modifiers::ABSTRACT) {
14761477
$flags .= "|ZEND_ACC_ABSTRACT";
14771478
}
14781479

@@ -2258,9 +2259,9 @@ protected function addTypeToFieldSynopsis(DOMDocument $doc, DOMElement $fieldsyn
22582259
protected function getFlagsByPhpVersion(): array
22592260
{
22602261
$flags = "ZEND_ACC_PUBLIC";
2261-
if ($this->flags & Class_::MODIFIER_PROTECTED) {
2262+
if ($this->flags & Modifiers::PROTECTED) {
22622263
$flags = "ZEND_ACC_PROTECTED";
2263-
} elseif ($this->flags & Class_::MODIFIER_PRIVATE) {
2264+
} elseif ($this->flags & Modifiers::PRIVATE) {
22642265
$flags = "ZEND_ACC_PRIVATE";
22652266
}
22662267

@@ -2355,13 +2356,13 @@ public function getFieldSynopsisElement(DOMDocument $doc, array $allConstInfos):
23552356

23562357
protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fieldsynopsisElement): void
23572358
{
2358-
if ($this->flags & Class_::MODIFIER_PUBLIC) {
2359+
if ($this->flags & Modifiers::PUBLIC) {
23592360
$fieldsynopsisElement->appendChild(new DOMText("\n "));
23602361
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "public"));
2361-
} elseif ($this->flags & Class_::MODIFIER_PROTECTED) {
2362+
} elseif ($this->flags & Modifiers::PROTECTED) {
23622363
$fieldsynopsisElement->appendChild(new DOMText("\n "));
23632364
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "protected"));
2364-
} elseif ($this->flags & Class_::MODIFIER_PRIVATE) {
2365+
} elseif ($this->flags & Modifiers::PRIVATE) {
23652366
$fieldsynopsisElement->appendChild(new DOMText("\n "));
23662367
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "private"));
23672368
}
@@ -2513,7 +2514,7 @@ public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLev
25132514

25142515
public function discardInfoForOldPhpVersions(): void {
25152516
$this->type = null;
2516-
$this->flags &= ~Class_::MODIFIER_FINAL;
2517+
$this->flags &= ~Modifiers::FINAL;
25172518
$this->isDeprecated = false;
25182519
$this->attributes = [];
25192520
}
@@ -2704,7 +2705,7 @@ protected function getFlagsByPhpVersion(): array
27042705
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_DEPRECATED", PHP_80_VERSION_ID);
27052706
}
27062707

2707-
if ($this->flags & Class_::MODIFIER_FINAL) {
2708+
if ($this->flags & Modifiers::FINAL) {
27082709
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_FINAL", PHP_81_VERSION_ID);
27092710
}
27102711

@@ -2715,7 +2716,7 @@ protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fie
27152716
{
27162717
parent::addModifiersToFieldSynopsis($doc, $fieldsynopsisElement);
27172718

2718-
if ($this->flags & Class_::MODIFIER_FINAL) {
2719+
if ($this->flags & Modifiers::FINAL) {
27192720
$fieldsynopsisElement->appendChild(new DOMText("\n "));
27202721
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "final"));
27212722
}
@@ -2784,7 +2785,7 @@ protected function getFieldSynopsisValueString(array $allConstInfos): ?string
27842785

27852786
public function discardInfoForOldPhpVersions(): void {
27862787
$this->type = null;
2787-
$this->flags &= ~Class_::MODIFIER_READONLY;
2788+
$this->flags &= ~Modifiers::READONLY;
27882789
$this->attributes = [];
27892790
}
27902791

@@ -2840,11 +2841,11 @@ protected function getFlagsByPhpVersion(): array
28402841
{
28412842
$flags = parent::getFlagsByPhpVersion();
28422843

2843-
if ($this->flags & Class_::MODIFIER_STATIC) {
2844+
if ($this->flags & Modifiers::STATIC) {
28442845
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_STATIC", PHP_70_VERSION_ID);
28452846
}
28462847

2847-
if ($this->flags & Class_::MODIFIER_READONLY) {
2848+
if ($this->flags & Modifiers::READONLY) {
28482849
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_READONLY", PHP_81_VERSION_ID);
28492850
}
28502851

@@ -2855,12 +2856,12 @@ protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fie
28552856
{
28562857
parent::addModifiersToFieldSynopsis($doc, $fieldsynopsisElement);
28572858

2858-
if ($this->flags & Class_::MODIFIER_STATIC) {
2859+
if ($this->flags & Modifiers::STATIC) {
28592860
$fieldsynopsisElement->appendChild(new DOMText("\n "));
28602861
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "static"));
28612862
}
28622863

2863-
if ($this->flags & Class_::MODIFIER_READONLY || $this->isDocReadonly) {
2864+
if ($this->flags & Modifiers::READONLY || $this->isDocReadonly) {
28642865
$fieldsynopsisElement->appendChild(new DOMText("\n "));
28652866
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "readonly"));
28662867
}
@@ -3181,11 +3182,11 @@ private function getFlagsByPhpVersion(): array
31813182
$php70Flags[] = "ZEND_ACC_TRAIT";
31823183
}
31833184

3184-
if ($this->flags & Class_::MODIFIER_FINAL) {
3185+
if ($this->flags & Modifiers::FINAL) {
31853186
$php70Flags[] = "ZEND_ACC_FINAL";
31863187
}
31873188

3188-
if ($this->flags & Class_::MODIFIER_ABSTRACT) {
3189+
if ($this->flags & Modifiers::ABSTRACT) {
31893190
$php70Flags[] = "ZEND_ACC_ABSTRACT";
31903191
}
31913192

@@ -3207,7 +3208,7 @@ private function getFlagsByPhpVersion(): array
32073208

32083209
$php82Flags = $php81Flags;
32093210

3210-
if ($this->flags & Class_::MODIFIER_READONLY) {
3211+
if ($this->flags & Modifiers::READONLY) {
32113212
$php82Flags[] = "ZEND_ACC_READONLY_CLASS";
32123213
}
32133214

@@ -3448,15 +3449,15 @@ private static function createOoElement(
34483449
$ooElement->appendChild($doc->createElement('modifier', $modifierOverride));
34493450
$ooElement->appendChild(new DOMText("\n$indentation "));
34503451
} elseif ($withModifiers) {
3451-
if ($classInfo->flags & Class_::MODIFIER_FINAL) {
3452+
if ($classInfo->flags & Modifiers::FINAL) {
34523453
$ooElement->appendChild($doc->createElement('modifier', 'final'));
34533454
$ooElement->appendChild(new DOMText("\n$indentation "));
34543455
}
3455-
if ($classInfo->flags & Class_::MODIFIER_ABSTRACT) {
3456+
if ($classInfo->flags & Modifiers::ABSTRACT) {
34563457
$ooElement->appendChild($doc->createElement('modifier', 'abstract'));
34573458
$ooElement->appendChild(new DOMText("\n$indentation "));
34583459
}
3459-
if ($classInfo->flags & Class_::MODIFIER_READONLY) {
3460+
if ($classInfo->flags & Modifiers::READONLY) {
34603461
$ooElement->appendChild($doc->createElement('modifier', 'readonly'));
34613462
$ooElement->appendChild(new DOMText("\n$indentation "));
34623463
}
@@ -3601,7 +3602,7 @@ private function hasConstructor(): bool
36013602
private function hasNonPrivateConstructor(): bool
36023603
{
36033604
foreach ($this->funcInfos as $funcInfo) {
3604-
if ($funcInfo->name->isConstructor() && !($funcInfo->flags & Class_::MODIFIER_PRIVATE)) {
3605+
if ($funcInfo->name->isConstructor() && !($funcInfo->flags & Modifiers::PRIVATE)) {
36053606
return true;
36063607
}
36073608
}
@@ -4339,7 +4340,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
43394340
}
43404341

43414342
$classFlags = $stmt instanceof Class_ ? $stmt->flags : 0;
4342-
$abstractFlag = $stmt instanceof Stmt\Interface_ ? Class_::MODIFIER_ABSTRACT : 0;
4343+
$abstractFlag = $stmt instanceof Stmt\Interface_ ? Modifiers::ABSTRACT : 0;
43434344

43444345
if ($classStmt instanceof Stmt\ClassConst) {
43454346
foreach ($classStmt->consts as $const) {
@@ -5530,7 +5531,7 @@ function initPhpParser() {
55305531
}
55315532

55325533
$isInitialized = true;
5533-
$version = "5.0.0alpha3";
5534+
$version = "5.0.0";
55345535
$phpParserDir = __DIR__ . "/PHP-Parser-$version";
55355536
if (!is_dir($phpParserDir)) {
55365537
installPhpParser($version, $phpParserDir);

0 commit comments

Comments
 (0)