Skip to content

Commit

Permalink
Fix classmap authoritative autoloading (#1046)
Browse files Browse the repository at this point in the history
This patch resolves #1045 by adding dummy class definitions
behind if (false) checks that are picked up the authoritative
autoloader.
  • Loading branch information
ghostwriter authored Dec 6, 2024
1 parent 74d3f7f commit 469377f
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/PhpParser/Node/Expr/ArrayItem.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Expr;

require __DIR__ . '/../ArrayItem.php';

if (false) {
// For classmap-authoritative support.
class ArrayItem extends \PhpParser\Node\ArrayItem {
}
}
8 changes: 8 additions & 0 deletions lib/PhpParser/Node/Expr/ClosureUse.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Expr;

require __DIR__ . '/../ClosureUse.php';

if (false) {
// For classmap-authoritative support.
class ClosureUse extends \PhpParser\Node\ClosureUse {
}
}
8 changes: 8 additions & 0 deletions lib/PhpParser/Node/Scalar/DNumber.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Scalar;

require __DIR__ . '/Float_.php';

if (false) {
// For classmap-authoritative support.
class DNumber extends Float_ {
}
}
8 changes: 8 additions & 0 deletions lib/PhpParser/Node/Scalar/Encapsed.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Scalar;

require __DIR__ . '/InterpolatedString.php';

if (false) {
// For classmap-authoritative support.
class Encapsed extends InterpolatedString {
}
}
10 changes: 10 additions & 0 deletions lib/PhpParser/Node/Scalar/EncapsedStringPart.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Scalar;

use PhpParser\Node\InterpolatedStringPart;

require __DIR__ . '/../InterpolatedStringPart.php';

if (false) {
// For classmap-authoritative support.
class EncapsedStringPart extends InterpolatedStringPart {
}
}
8 changes: 8 additions & 0 deletions lib/PhpParser/Node/Scalar/LNumber.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Scalar;

require __DIR__ . '/Int_.php';

if (false) {
// For classmap-authoritative support.
class LNumber extends Int_ {
}
}
10 changes: 10 additions & 0 deletions lib/PhpParser/Node/Stmt/DeclareDeclare.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Stmt;

use PhpParser\Node\DeclareItem;

require __DIR__ . '/../DeclareItem.php';

if (false) {
// For classmap-authoritative support.
class DeclareDeclare extends DeclareItem {
}
}
10 changes: 10 additions & 0 deletions lib/PhpParser/Node/Stmt/PropertyProperty.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Stmt;

use PhpParser\Node\PropertyItem;

require __DIR__ . '/../PropertyItem.php';

if (false) {
// For classmap-authoritative support.
class PropertyProperty extends PropertyItem {
}
}
8 changes: 8 additions & 0 deletions lib/PhpParser/Node/Stmt/StaticVar.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Stmt;

require __DIR__ . '/../StaticVar.php';

if (false) {
// For classmap-authoritative support.
class StaticVar extends \PhpParser\Node\StaticVar {
}
}
10 changes: 10 additions & 0 deletions lib/PhpParser/Node/Stmt/UseUse.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<?php declare(strict_types=1);

namespace PhpParser\Node\Stmt;

use PhpParser\Node\UseItem;

require __DIR__ . '/../UseItem.php';

if (false) {
// For classmap-authoritative support.
class UseUse extends UseItem {
}
}
50 changes: 50 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,56 @@ parameters:
count: 1
path: lib/PhpParser/Lexer/Emulative.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Expr/ArrayItem.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Expr/ClosureUse.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Scalar/DNumber.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Scalar/Encapsed.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Scalar/EncapsedStringPart.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Scalar/LNumber.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Stmt/DeclareDeclare.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Stmt/PropertyProperty.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Stmt/StaticVar.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: lib/PhpParser/Node/Stmt/UseUse.php

-
message: "#^Constant T_PRIVATE_SET not found\\.$#"
count: 2
Expand Down

0 comments on commit 469377f

Please sign in to comment.