update lock clucknut
All checks were successful
All checks were successful
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -14,6 +14,7 @@
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Exit_;
|
||||
use PhpParser\Node\Expr\Throw_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Break_;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
@@ -74,14 +75,14 @@ private function addImplicitReturn(array $nodes): array
|
||||
$case->stmts[] = $caseLast;
|
||||
}
|
||||
}
|
||||
} elseif ($last instanceof Expr && !($last instanceof Exit_)) {
|
||||
} elseif ($last instanceof Expr && !($last instanceof Exit_) && !self::isThrowNode($last)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$nodes[\count($nodes) - 1] = new Return_($last, [
|
||||
'startLine' => $last->getStartLine(),
|
||||
'endLine' => $last->getEndLine(),
|
||||
]);
|
||||
// @codeCoverageIgnoreEnd
|
||||
} elseif ($last instanceof Expression && !($last->expr instanceof Exit_)) {
|
||||
} elseif ($last instanceof Expression && !($last->expr instanceof Exit_) && !self::isThrowNode($last->expr)) {
|
||||
$nodes[\count($nodes) - 1] = new Return_($last->expr, [
|
||||
'startLine' => $last->getStartLine(),
|
||||
'endLine' => $last->getEndLine(),
|
||||
@@ -100,7 +101,7 @@ private function addImplicitReturn(array $nodes): array
|
||||
// We're not adding a fallback return after namespace statements,
|
||||
// because code outside namespace statements doesn't really work, and
|
||||
// there's already an implicit return in the namespace statement anyway.
|
||||
if (self::isNonExpressionStmt($last)) {
|
||||
if (self::isNonExpressionStmt($last) && !self::isThrowNode($last)) {
|
||||
$nodes[] = new Return_(NoReturnValue::create());
|
||||
}
|
||||
|
||||
@@ -122,4 +123,13 @@ private static function isNonExpressionStmt(Node $node): bool
|
||||
!$node instanceof Return_ &&
|
||||
!$node instanceof Namespace_;
|
||||
}
|
||||
|
||||
/**
|
||||
* PHP-Parser 4.x modeled standalone `throw` as Stmt\Throw_, while newer
|
||||
* versions expose it as Expr\Throw_ inside Stmt\Expression.
|
||||
*/
|
||||
private static function isThrowNode(Node $node): bool
|
||||
{
|
||||
return $node instanceof Throw_ || $node->getType() === 'Stmt_Throw';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -267,11 +267,11 @@ private function buildShortNameMap(): void
|
||||
{
|
||||
$this->shortNameMap = [];
|
||||
|
||||
$allClasses = \array_merge(
|
||||
\get_declared_classes(),
|
||||
\get_declared_interfaces(),
|
||||
\get_declared_traits()
|
||||
);
|
||||
$allClasses = [
|
||||
...\get_declared_classes(),
|
||||
...\get_declared_interfaces(),
|
||||
...\get_declared_traits(),
|
||||
];
|
||||
|
||||
// First pass: collect all matching classes
|
||||
$candidatesByShortName = [];
|
||||
@@ -342,9 +342,7 @@ private function shouldIncludeClass(string $fqn): bool
|
||||
*/
|
||||
private function normalizeNamespaces(array $namespaces): array
|
||||
{
|
||||
return \array_map(function ($namespace) {
|
||||
return \trim($namespace, '\\').'\\';
|
||||
}, $namespaces);
|
||||
return \array_map(fn ($namespace) => \trim($namespace, '\\').'\\', $namespaces);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -29,6 +29,7 @@ abstract class NamespaceAwarePass extends CodeCleanerPass
|
||||
protected array $namespace = [];
|
||||
protected array $currentScope = [];
|
||||
protected array $aliases = [];
|
||||
protected array $aliasesByType = [];
|
||||
protected ?CodeCleaner $cleaner = null;
|
||||
|
||||
/**
|
||||
@@ -51,6 +52,7 @@ public function beforeTraverse(array $nodes)
|
||||
{
|
||||
$this->namespace = [];
|
||||
$this->currentScope = [];
|
||||
$this->aliasesByType = [];
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -71,23 +73,25 @@ public function enterNode(Node $node)
|
||||
// Only restore use statement aliases for PsySH re-injected namespaces.
|
||||
// Explicit namespace declarations start with a clean slate.
|
||||
if ($this->cleaner && $node->getAttribute('psyshReinjected')) {
|
||||
$this->aliases = $this->cleaner->getAliasesForNamespace($node->name);
|
||||
$this->aliasesByType = $this->cleaner->getAliasesByTypeForNamespace($node->name);
|
||||
$this->aliases = $this->aliasesByType[Use_::TYPE_NORMAL] ?? [];
|
||||
} else {
|
||||
$this->aliases = [];
|
||||
$this->aliasesByType = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Track use statements for alias resolution
|
||||
if ($node instanceof Use_) {
|
||||
foreach ($node->uses as $useItem) {
|
||||
$this->aliases[\strtolower($useItem->getAlias())] = $useItem->name;
|
||||
$this->setAliasForType(\strtolower($useItem->getAlias()), $useItem->name, $this->getUseImportType($node, $useItem));
|
||||
}
|
||||
}
|
||||
|
||||
// Track group use statements
|
||||
if ($node instanceof GroupUse) {
|
||||
foreach ($node->uses as $useItem) {
|
||||
$this->aliases[\strtolower($useItem->getAlias())] = Name::concat($node->prefix, $useItem->name);
|
||||
$this->setAliasForType(\strtolower($useItem->getAlias()), Name::concat($node->prefix, $useItem->name), $this->getUseImportType($node, $useItem));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,14 +112,17 @@ public function enterNode(Node $node)
|
||||
public function leaveNode(Node $node)
|
||||
{
|
||||
if ($node instanceof Namespace_) {
|
||||
$this->syncCompatAliases();
|
||||
|
||||
// Open namespaces (like `namespace Foo;`) have kind == KIND_SEMICOLON.
|
||||
if ($node->getAttribute('kind') === Namespace_::KIND_SEMICOLON || $node->getAttribute('psyshReinjected')) {
|
||||
if ($this->cleaner) {
|
||||
$this->cleaner->setAliasesForNamespace($node->name, $this->aliases);
|
||||
$this->cleaner->setAliasesByTypeForNamespace($node->name, $this->aliasesByType);
|
||||
}
|
||||
}
|
||||
|
||||
$this->aliases = [];
|
||||
$this->aliasesByType = [];
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -130,6 +137,8 @@ public function leaveNode(Node $node)
|
||||
*/
|
||||
protected function getFullyQualifiedName($name): string
|
||||
{
|
||||
$this->syncCompatAliases();
|
||||
|
||||
if ($name instanceof FullyQualifiedName) {
|
||||
return \implode('\\', $this->getParts($name));
|
||||
}
|
||||
@@ -166,4 +175,54 @@ protected function getParts(Name $name): array
|
||||
{
|
||||
return \method_exists($name, 'getParts') ? $name->getParts() : $name->parts;
|
||||
}
|
||||
|
||||
protected function getAliasesForType(int $type): array
|
||||
{
|
||||
$this->syncCompatAliases();
|
||||
|
||||
return $this->aliasesByType[$type] ?? [];
|
||||
}
|
||||
|
||||
private function setAliasForType(string $alias, Name $name, int $type): void
|
||||
{
|
||||
$this->aliasesByType[$type][$alias] = $name;
|
||||
if ($type === Use_::TYPE_NORMAL) {
|
||||
$this->aliases[$alias] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync $aliases into $aliasesByType[TYPE_NORMAL] for subclasses that read $aliases directly.
|
||||
*/
|
||||
private function syncCompatAliases(): void
|
||||
{
|
||||
if ($this->aliases === []) {
|
||||
unset($this->aliasesByType[Use_::TYPE_NORMAL]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->aliasesByType[Use_::TYPE_NORMAL] = $this->aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the import type for a use item across PHP-Parser 4.x and 5.x.
|
||||
*
|
||||
* Individual use items may specify their own type (e.g. in group use
|
||||
* statements), otherwise fall back to the parent statement type.
|
||||
*/
|
||||
protected function getUseImportType(Node $node, Node $useItem): int
|
||||
{
|
||||
$itemType = $useItem->type ?? null;
|
||||
if (\is_int($itemType) && $itemType !== Use_::TYPE_UNKNOWN) {
|
||||
return $itemType;
|
||||
}
|
||||
|
||||
$nodeType = $node->type ?? null;
|
||||
if (\is_int($nodeType) && $nodeType !== Use_::TYPE_UNKNOWN) {
|
||||
return $nodeType;
|
||||
}
|
||||
|
||||
return Use_::TYPE_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -106,7 +106,7 @@ private function setNamespace(?Name $namespace)
|
||||
$this->cleaner->setNamespace($namespace);
|
||||
|
||||
// Always clear aliases when changing namespace
|
||||
$this->cleaner->setAliasesForNamespace($namespace, []);
|
||||
$this->cleaner->setAliasesByTypeForNamespace($namespace, []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name; // @phan-suppress-current-line PhanUnreferencedUseNormal - used for type checks
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseItem;
|
||||
@@ -70,9 +69,9 @@ public function beforeTraverse(array $nodes)
|
||||
// Only re-inject use statements if this is a wrapper created by NamespacePass.
|
||||
// This matches PHP behavior: explicit namespace declaration clears use statements.
|
||||
if ($node->getAttribute('psyshReinjected')) {
|
||||
$aliases = $this->cleaner->getAliasesForNamespace($node->name);
|
||||
if (!empty($aliases)) {
|
||||
$useStatements = $this->createUseStatements($aliases);
|
||||
$aliasesByType = $this->cleaner->getAliasesByTypeForNamespace($node->name);
|
||||
if (!empty($aliasesByType)) {
|
||||
$useStatements = $this->createUseStatements($aliasesByType);
|
||||
$node->stmts = \array_merge($useStatements, $node->stmts ?? []);
|
||||
}
|
||||
}
|
||||
@@ -84,9 +83,9 @@ public function beforeTraverse(array $nodes)
|
||||
|
||||
// No namespace declaration in input, or re-applied by NamespacePass; re-inject use
|
||||
// statements for the empty namespace.
|
||||
$aliases = $this->cleaner->getAliasesForNamespace(null);
|
||||
if (!empty($aliases)) {
|
||||
$useStatements = $this->createUseStatements($aliases);
|
||||
$aliasesByType = $this->cleaner->getAliasesByTypeForNamespace(null);
|
||||
if (!empty($aliasesByType)) {
|
||||
$useStatements = $this->createUseStatements($aliasesByType);
|
||||
$nodes = \array_merge($useStatements, $nodes);
|
||||
}
|
||||
|
||||
@@ -106,8 +105,8 @@ public function afterTraverse(array $nodes)
|
||||
}
|
||||
|
||||
// Persist aliases if they're at the global level (not inside any namespace)
|
||||
if (!empty($this->aliases)) {
|
||||
$this->cleaner->setAliasesForNamespace(null, $this->aliases);
|
||||
if (!empty($this->aliasesByType)) {
|
||||
$this->cleaner->setAliasesByTypeForNamespace(null, $this->aliasesByType);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -122,32 +121,40 @@ public function afterTraverse(array $nodes)
|
||||
*/
|
||||
private function validateUseStatement(Use_ $stmt): void
|
||||
{
|
||||
$seenAliases = [];
|
||||
|
||||
foreach ($stmt->uses as $useItem) {
|
||||
$alias = \strtolower($useItem->getAlias());
|
||||
$type = $this->getUseImportType($stmt, $useItem);
|
||||
|
||||
if (isset($this->aliases[$alias])) {
|
||||
if (isset($seenAliases[$type][$alias]) || isset($this->getAliasesForType($type)[$alias])) {
|
||||
throw new FatalErrorException(\sprintf('Cannot use %s as %s because the name is already in use', $useItem->name->toString(), $useItem->getAlias()), 0, \E_ERROR, null, $stmt->getStartLine());
|
||||
}
|
||||
|
||||
$seenAliases[$type][$alias] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create use statement nodes from stored aliases.
|
||||
*
|
||||
* @param array $aliases Map of lowercase alias names to Name nodes
|
||||
* @param array $aliasesByType Map of Use_::TYPE_* constants to alias maps
|
||||
*
|
||||
* @return Use_[] Array of use statement nodes
|
||||
*/
|
||||
private function createUseStatements(array $aliases): array
|
||||
private function createUseStatements(array $aliasesByType): array
|
||||
{
|
||||
$useStatements = [];
|
||||
foreach ($aliases as $alias => $name) {
|
||||
// Create UseItem (PHP-Parser 5.x) or UseUse (PHP-Parser 4.x)
|
||||
$useItem = \class_exists(UseItem::class)
|
||||
? new UseItem($name, new Identifier($alias))
|
||||
: new UseUse($name, $alias);
|
||||
// Mark as re-injected so we don't validate it
|
||||
$useStatements[] = new Use_([$useItem], Use_::TYPE_NORMAL, ['psyshReinjected' => true]);
|
||||
|
||||
foreach ([Use_::TYPE_NORMAL, Use_::TYPE_FUNCTION, Use_::TYPE_CONSTANT] as $type) {
|
||||
foreach ($aliasesByType[$type] ?? [] as $alias => $name) {
|
||||
// Create UseItem (PHP-Parser 5.x) or UseUse (PHP-Parser 4.x)
|
||||
$useItem = \class_exists(UseItem::class)
|
||||
? new UseItem($name, new Identifier($alias))
|
||||
: new UseUse($name, $alias);
|
||||
// Mark as re-injected so we don't validate it
|
||||
$useStatements[] = new Use_([$useItem], $type, ['psyshReinjected' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
return $useStatements;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2025 Justin Hileman
|
||||
* (c) 2012-2026 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
Reference in New Issue
Block a user