Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -6,19 +6,18 @@ use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt;
class NameContext
{
class NameContext {
/** @var null|Name Current namespace */
protected $namespace;
protected ?Name $namespace;
/** @var Name[][] Map of format [aliasType => [aliasName => originalName]] */
protected $aliases = [];
protected array $aliases = [];
/** @var Name[][] Same as $aliases but preserving original case */
protected $origAliases = [];
protected array $origAliases = [];
/** @var ErrorHandler Error handler */
protected $errorHandler;
protected ErrorHandler $errorHandler;
/**
* Create a name context.
@@ -36,7 +35,7 @@ class NameContext
*
* @param Name|null $namespace Null is the global namespace
*/
public function startNamespace(Name $namespace = null) {
public function startNamespace(?Name $namespace = null): void {
$this->namespace = $namespace;
$this->origAliases = $this->aliases = [
Stmt\Use_::TYPE_NORMAL => [],
@@ -48,12 +47,12 @@ class NameContext
/**
* Add an alias / import.
*
* @param Name $name Original name
* @param string $aliasName Aliased name
* @param int $type One of Stmt\Use_::TYPE_*
* @param array $errorAttrs Attributes to use to report an error
* @param Name $name Original name
* @param string $aliasName Aliased name
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
* @param array<string, mixed> $errorAttrs Attributes to use to report an error
*/
public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []) {
public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []): void {
// Constant names are case sensitive, everything else case insensitive
if ($type === Stmt\Use_::TYPE_CONSTANT) {
$aliasLookupName = $aliasName;
@@ -87,7 +86,7 @@ class NameContext
*
* @return null|Name Namespace (or null if global namespace)
*/
public function getNamespace() {
public function getNamespace(): ?Name {
return $this->namespace;
}
@@ -95,11 +94,11 @@ class NameContext
* Get resolved name.
*
* @param Name $name Name to resolve
* @param int $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT}
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT}
*
* @return null|Name Resolved name, or null if static resolution is not possible
*/
public function getResolvedName(Name $name, int $type) {
public function getResolvedName(Name $name, int $type): ?Name {
// don't resolve special class names
if ($type === Stmt\Use_::TYPE_NORMAL && $name->isSpecialClassName()) {
if (!$name->isUnqualified()) {
@@ -142,7 +141,7 @@ class NameContext
*
* @return Name Resolved name
*/
public function getResolvedClassName(Name $name) : Name {
public function getResolvedClassName(Name $name): Name {
return $this->getResolvedName($name, Stmt\Use_::TYPE_NORMAL);
}
@@ -150,11 +149,11 @@ class NameContext
* Get possible ways of writing a fully qualified name (e.g., by making use of aliases).
*
* @param string $name Fully-qualified name (without leading namespace separator)
* @param int $type One of Stmt\Use_::TYPE_*
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
*
* @return Name[] Possible representations of the name
*/
public function getPossibleNames(string $name, int $type) : array {
public function getPossibleNames(string $name, int $type): array {
$lcName = strtolower($name);
if ($type === Stmt\Use_::TYPE_NORMAL) {
@@ -206,11 +205,11 @@ class NameContext
* Get shortest representation of this fully-qualified name.
*
* @param string $name Fully-qualified name (without leading namespace separator)
* @param int $type One of Stmt\Use_::TYPE_*
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
*
* @return Name Shortest representation
*/
public function getShortName(string $name, int $type) : Name {
public function getShortName(string $name, int $type): Name {
$possibleNames = $this->getPossibleNames($name, $type);
// Find shortest name
@@ -224,10 +223,10 @@ class NameContext
}
}
return $shortestName;
return $shortestName;
}
private function resolveAlias(Name $name, $type) {
private function resolveAlias(Name $name, int $type): ?FullyQualified {
$firstPart = $name->getFirst();
if ($name->isQualified()) {
@@ -250,7 +249,7 @@ class NameContext
return null;
}
private function getNamespaceRelativeName(string $name, string $lcName, int $type) {
private function getNamespaceRelativeName(string $name, string $lcName, int $type): ?Name {
if (null === $this->namespace) {
return new Name($name);
}
@@ -271,7 +270,7 @@ class NameContext
return null;
}
private function normalizeConstName(string $name) {
private function normalizeConstName(string $name): string {
$nsSep = strrpos($name, '\\');
if (false === $nsSep) {
return $name;