3
3
4
4
use PhpParser \Comment \Doc as DocComment ;
5
5
use PhpParser \ConstExprEvaluator ;
6
+ use PhpParser \Modifiers ;
6
7
use PhpParser \Node ;
7
8
use PhpParser \Node \AttributeGroup ;
8
9
use PhpParser \Node \Expr ;
@@ -1260,12 +1261,12 @@ public function isMethod(): bool
1260
1261
1261
1262
public function isFinalMethod (): bool
1262
1263
{
1263
- return ($ this ->flags & Class_:: MODIFIER_FINAL ) || ($ this ->classFlags & Class_:: MODIFIER_FINAL );
1264
+ return ($ this ->flags & Modifiers:: FINAL ) || ($ this ->classFlags & Modifiers:: FINAL );
1264
1265
}
1265
1266
1266
1267
public function isInstanceMethod (): bool
1267
1268
{
1268
- return !($ this ->flags & Class_:: MODIFIER_STATIC ) && $ this ->isMethod () && !$ this ->name ->isConstructor ();
1269
+ return !($ this ->flags & Modifiers:: STATIC ) && $ this ->isMethod () && !$ this ->name ->isConstructor ();
1269
1270
}
1270
1271
1271
1272
/** @return string[] */
@@ -1277,21 +1278,21 @@ public function getModifierNames(): array
1277
1278
1278
1279
$ result = [];
1279
1280
1280
- if ($ this ->flags & Class_:: MODIFIER_FINAL ) {
1281
+ if ($ this ->flags & Modifiers:: FINAL ) {
1281
1282
$ result [] = "final " ;
1282
- } elseif ($ this ->flags & Class_:: MODIFIER_ABSTRACT && $ this ->classFlags & ~Class_:: MODIFIER_ABSTRACT ) {
1283
+ } elseif ($ this ->flags & Modifiers:: ABSTRACT && $ this ->classFlags & ~Modifiers:: ABSTRACT ) {
1283
1284
$ result [] = "abstract " ;
1284
1285
}
1285
1286
1286
- if ($ this ->flags & Class_:: MODIFIER_PROTECTED ) {
1287
+ if ($ this ->flags & Modifiers:: PROTECTED ) {
1287
1288
$ result [] = "protected " ;
1288
- } elseif ($ this ->flags & Class_:: MODIFIER_PRIVATE ) {
1289
+ } elseif ($ this ->flags & Modifiers:: PRIVATE ) {
1289
1290
$ result [] = "private " ;
1290
1291
} else {
1291
1292
$ result [] = "public " ;
1292
1293
}
1293
1294
1294
- if ($ this ->flags & Class_:: MODIFIER_STATIC ) {
1295
+ if ($ this ->flags & Modifiers:: STATIC ) {
1295
1296
$ result [] = "static " ;
1296
1297
}
1297
1298
@@ -1338,7 +1339,7 @@ public function getDeclarationKey(): string
1338
1339
1339
1340
public function getDeclaration (): ?string
1340
1341
{
1341
- if ($ this ->flags & Class_:: MODIFIER_ABSTRACT ) {
1342
+ if ($ this ->flags & Modifiers:: ABSTRACT ) {
1342
1343
return null ;
1343
1344
}
1344
1345
@@ -1367,7 +1368,7 @@ public function getFunctionEntry(): string {
1367
1368
}
1368
1369
} else {
1369
1370
$ declarationClassName = $ this ->name ->getDeclarationClassName ();
1370
- if ($ this ->flags & Class_:: MODIFIER_ABSTRACT ) {
1371
+ if ($ this ->flags & Modifiers:: ABSTRACT ) {
1371
1372
return sprintf (
1372
1373
"\tZEND_ABSTRACT_ME_WITH_FLAGS(%s, %s, %s, %s) \n" ,
1373
1374
$ declarationClassName , $ this ->name ->methodName , $ this ->getArgInfoName (),
@@ -1458,21 +1459,21 @@ public function discardInfoForOldPhpVersions(): void {
1458
1459
private function getFlagsAsArginfoString (): string
1459
1460
{
1460
1461
$ flags = "ZEND_ACC_PUBLIC " ;
1461
- if ($ this ->flags & Class_:: MODIFIER_PROTECTED ) {
1462
+ if ($ this ->flags & Modifiers:: PROTECTED ) {
1462
1463
$ flags = "ZEND_ACC_PROTECTED " ;
1463
- } elseif ($ this ->flags & Class_:: MODIFIER_PRIVATE ) {
1464
+ } elseif ($ this ->flags & Modifiers:: PRIVATE ) {
1464
1465
$ flags = "ZEND_ACC_PRIVATE " ;
1465
1466
}
1466
1467
1467
- if ($ this ->flags & Class_:: MODIFIER_STATIC ) {
1468
+ if ($ this ->flags & Modifiers:: STATIC ) {
1468
1469
$ flags .= "|ZEND_ACC_STATIC " ;
1469
1470
}
1470
1471
1471
- if ($ this ->flags & Class_:: MODIFIER_FINAL ) {
1472
+ if ($ this ->flags & Modifiers:: FINAL ) {
1472
1473
$ flags .= "|ZEND_ACC_FINAL " ;
1473
1474
}
1474
1475
1475
- if ($ this ->flags & Class_:: MODIFIER_ABSTRACT ) {
1476
+ if ($ this ->flags & Modifiers:: ABSTRACT ) {
1476
1477
$ flags .= "|ZEND_ACC_ABSTRACT " ;
1477
1478
}
1478
1479
@@ -2258,9 +2259,9 @@ protected function addTypeToFieldSynopsis(DOMDocument $doc, DOMElement $fieldsyn
2258
2259
protected function getFlagsByPhpVersion(): array
2259
2260
{
2260
2261
$flags = "ZEND_ACC_PUBLIC";
2261
- if ($this->flags & Class_::MODIFIER_PROTECTED ) {
2262
+ if ($this->flags & Modifiers::PROTECTED ) {
2262
2263
$flags = "ZEND_ACC_PROTECTED";
2263
- } elseif ($this->flags & Class_::MODIFIER_PRIVATE ) {
2264
+ } elseif ($this->flags & Modifiers::PRIVATE ) {
2264
2265
$flags = "ZEND_ACC_PRIVATE";
2265
2266
}
2266
2267
@@ -2355,13 +2356,13 @@ public function getFieldSynopsisElement(DOMDocument $doc, array $allConstInfos):
2355
2356
2356
2357
protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fieldsynopsisElement): void
2357
2358
{
2358
- if ($this->flags & Class_::MODIFIER_PUBLIC ) {
2359
+ if ($this->flags & Modifiers::PUBLIC ) {
2359
2360
$fieldsynopsisElement->appendChild(new DOMText("\n "));
2360
2361
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "public"));
2361
- } elseif ($this->flags & Class_::MODIFIER_PROTECTED ) {
2362
+ } elseif ($this->flags & Modifiers::PROTECTED ) {
2362
2363
$fieldsynopsisElement->appendChild(new DOMText("\n "));
2363
2364
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "protected"));
2364
- } elseif ($this->flags & Class_::MODIFIER_PRIVATE ) {
2365
+ } elseif ($this->flags & Modifiers::PRIVATE ) {
2365
2366
$fieldsynopsisElement->appendChild(new DOMText("\n "));
2366
2367
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "private"));
2367
2368
}
@@ -2513,7 +2514,7 @@ public function getPredefinedConstantEntry(DOMDocument $doc, int $indentationLev
2513
2514
2514
2515
public function discardInfoForOldPhpVersions(): void {
2515
2516
$this->type = null;
2516
- $this->flags &= ~Class_::MODIFIER_FINAL ;
2517
+ $this->flags &= ~Modifiers::FINAL ;
2517
2518
$this->isDeprecated = false;
2518
2519
$this->attributes = [];
2519
2520
}
@@ -2704,7 +2705,7 @@ protected function getFlagsByPhpVersion(): array
2704
2705
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_DEPRECATED", PHP_80_VERSION_ID);
2705
2706
}
2706
2707
2707
- if ($this->flags & Class_::MODIFIER_FINAL ) {
2708
+ if ($this->flags & Modifiers::FINAL ) {
2708
2709
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_FINAL", PHP_81_VERSION_ID);
2709
2710
}
2710
2711
@@ -2715,7 +2716,7 @@ protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fie
2715
2716
{
2716
2717
parent::addModifiersToFieldSynopsis($doc, $fieldsynopsisElement);
2717
2718
2718
- if ($this->flags & Class_::MODIFIER_FINAL ) {
2719
+ if ($this->flags & Modifiers::FINAL ) {
2719
2720
$fieldsynopsisElement->appendChild(new DOMText("\n "));
2720
2721
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "final"));
2721
2722
}
@@ -2784,7 +2785,7 @@ protected function getFieldSynopsisValueString(array $allConstInfos): ?string
2784
2785
2785
2786
public function discardInfoForOldPhpVersions(): void {
2786
2787
$this->type = null;
2787
- $this->flags &= ~Class_::MODIFIER_READONLY ;
2788
+ $this->flags &= ~Modifiers::READONLY ;
2788
2789
$this->attributes = [];
2789
2790
}
2790
2791
@@ -2840,11 +2841,11 @@ protected function getFlagsByPhpVersion(): array
2840
2841
{
2841
2842
$flags = parent::getFlagsByPhpVersion();
2842
2843
2843
- if ($this->flags & Class_::MODIFIER_STATIC ) {
2844
+ if ($this->flags & Modifiers::STATIC ) {
2844
2845
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_STATIC", PHP_70_VERSION_ID);
2845
2846
}
2846
2847
2847
- if ($this->flags & Class_::MODIFIER_READONLY ) {
2848
+ if ($this->flags & Modifiers::READONLY ) {
2848
2849
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_READONLY", PHP_81_VERSION_ID);
2849
2850
}
2850
2851
@@ -2855,12 +2856,12 @@ protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fie
2855
2856
{
2856
2857
parent::addModifiersToFieldSynopsis($doc, $fieldsynopsisElement);
2857
2858
2858
- if ($this->flags & Class_::MODIFIER_STATIC ) {
2859
+ if ($this->flags & Modifiers::STATIC ) {
2859
2860
$fieldsynopsisElement->appendChild(new DOMText("\n "));
2860
2861
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "static"));
2861
2862
}
2862
2863
2863
- if ($this->flags & Class_::MODIFIER_READONLY || $this->isDocReadonly) {
2864
+ if ($this->flags & Modifiers::READONLY || $this->isDocReadonly) {
2864
2865
$fieldsynopsisElement->appendChild(new DOMText("\n "));
2865
2866
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "readonly"));
2866
2867
}
@@ -3181,11 +3182,11 @@ private function getFlagsByPhpVersion(): array
3181
3182
$php70Flags[] = "ZEND_ACC_TRAIT";
3182
3183
}
3183
3184
3184
- if ($this->flags & Class_::MODIFIER_FINAL ) {
3185
+ if ($this->flags & Modifiers::FINAL ) {
3185
3186
$php70Flags[] = "ZEND_ACC_FINAL";
3186
3187
}
3187
3188
3188
- if ($this->flags & Class_::MODIFIER_ABSTRACT ) {
3189
+ if ($this->flags & Modifiers::ABSTRACT ) {
3189
3190
$php70Flags[] = "ZEND_ACC_ABSTRACT";
3190
3191
}
3191
3192
@@ -3207,7 +3208,7 @@ private function getFlagsByPhpVersion(): array
3207
3208
3208
3209
$php82Flags = $php81Flags;
3209
3210
3210
- if ($this->flags & Class_::MODIFIER_READONLY ) {
3211
+ if ($this->flags & Modifiers::READONLY ) {
3211
3212
$php82Flags[] = "ZEND_ACC_READONLY_CLASS";
3212
3213
}
3213
3214
@@ -3448,15 +3449,15 @@ private static function createOoElement(
3448
3449
$ooElement->appendChild($doc->createElement('modifier', $modifierOverride));
3449
3450
$ooElement->appendChild(new DOMText("\n$indentation "));
3450
3451
} elseif ($withModifiers) {
3451
- if ($classInfo->flags & Class_::MODIFIER_FINAL ) {
3452
+ if ($classInfo->flags & Modifiers::FINAL ) {
3452
3453
$ooElement->appendChild($doc->createElement('modifier', 'final'));
3453
3454
$ooElement->appendChild(new DOMText("\n$indentation "));
3454
3455
}
3455
- if ($classInfo->flags & Class_::MODIFIER_ABSTRACT ) {
3456
+ if ($classInfo->flags & Modifiers::ABSTRACT ) {
3456
3457
$ooElement->appendChild($doc->createElement('modifier', 'abstract'));
3457
3458
$ooElement->appendChild(new DOMText("\n$indentation "));
3458
3459
}
3459
- if ($classInfo->flags & Class_::MODIFIER_READONLY ) {
3460
+ if ($classInfo->flags & Modifiers::READONLY ) {
3460
3461
$ooElement->appendChild($doc->createElement('modifier', 'readonly'));
3461
3462
$ooElement->appendChild(new DOMText("\n$indentation "));
3462
3463
}
@@ -3601,7 +3602,7 @@ private function hasConstructor(): bool
3601
3602
private function hasNonPrivateConstructor(): bool
3602
3603
{
3603
3604
foreach ($this->funcInfos as $funcInfo) {
3604
- if ($funcInfo->name->isConstructor() && !($funcInfo->flags & Class_::MODIFIER_PRIVATE )) {
3605
+ if ($funcInfo->name->isConstructor() && !($funcInfo->flags & Modifiers::PRIVATE )) {
3605
3606
return true;
3606
3607
}
3607
3608
}
@@ -4339,7 +4340,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
4339
4340
}
4340
4341
4341
4342
$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;
4343
4344
4344
4345
if ($classStmt instanceof Stmt\ClassConst) {
4345
4346
foreach ($classStmt->consts as $const) {
@@ -5530,7 +5531,7 @@ function initPhpParser() {
5530
5531
}
5531
5532
5532
5533
$isInitialized = true;
5533
- $version = "5.0.0alpha3 ";
5534
+ $version = "5.0.0 ";
5534
5535
$phpParserDir = __DIR__ . "/PHP-Parser-$version";
5535
5536
if (!is_dir($phpParserDir)) {
5536
5537
installPhpParser($version, $phpParserDir);
0 commit comments