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

@@ -15,8 +15,7 @@ use PhpParser\Node\Stmt;
*
* @internal
*/
final class BuilderHelpers
{
final class BuilderHelpers {
/**
* Normalizes a node: Converts builder objects to nodes.
*
@@ -24,7 +23,7 @@ final class BuilderHelpers
*
* @return Node The normalized node
*/
public static function normalizeNode($node) : Node {
public static function normalizeNode($node): Node {
if ($node instanceof Builder) {
return $node->getNode();
}
@@ -45,7 +44,7 @@ final class BuilderHelpers
*
* @return Stmt The normalized statement node
*/
public static function normalizeStmt($node) : Stmt {
public static function normalizeStmt($node): Stmt {
$node = self::normalizeNode($node);
if ($node instanceof Stmt) {
return $node;
@@ -65,7 +64,7 @@ final class BuilderHelpers
*
* @return Identifier The normalized identifier
*/
public static function normalizeIdentifier($name) : Identifier {
public static function normalizeIdentifier($name): Identifier {
if ($name instanceof Identifier) {
return $name;
}
@@ -103,7 +102,7 @@ final class BuilderHelpers
*
* @return Name The normalized name
*/
public static function normalizeName($name) : Name {
public static function normalizeName($name): Name {
if ($name instanceof Name) {
return $name;
}
@@ -178,7 +177,20 @@ final class BuilderHelpers
}
$builtinTypes = [
'array', 'callable', 'string', 'int', 'float', 'bool', 'iterable', 'void', 'object', 'mixed', 'never',
'array',
'callable',
'bool',
'int',
'float',
'string',
'iterable',
'void',
'object',
'null',
'false',
'mixed',
'never',
'true',
];
$lowerType = strtolower($type);
@@ -206,7 +218,7 @@ final class BuilderHelpers
*
* @return Expr The normalized value
*/
public static function normalizeValue($value) : Expr {
public static function normalizeValue($value): Expr {
if ($value instanceof Node\Expr) {
return $value;
}
@@ -224,11 +236,11 @@ final class BuilderHelpers
}
if (is_int($value)) {
return new Scalar\LNumber($value);
return new Scalar\Int_($value);
}
if (is_float($value)) {
return new Scalar\DNumber($value);
return new Scalar\Float_($value);
}
if (is_string($value)) {
@@ -241,12 +253,12 @@ final class BuilderHelpers
foreach ($value as $itemKey => $itemValue) {
// for consecutive, numeric keys don't generate keys
if (null !== $lastKey && ++$lastKey === $itemKey) {
$items[] = new Expr\ArrayItem(
$items[] = new Node\ArrayItem(
self::normalizeValue($itemValue)
);
} else {
$lastKey = null;
$items[] = new Expr\ArrayItem(
$items[] = new Node\ArrayItem(
self::normalizeValue($itemValue),
self::normalizeValue($itemKey)
);
@@ -266,7 +278,7 @@ final class BuilderHelpers
*
* @return Comment\Doc The normalized doc comment
*/
public static function normalizeDocComment($docComment) : Comment\Doc {
public static function normalizeDocComment($docComment): Comment\Doc {
if ($docComment instanceof Comment\Doc) {
return $docComment;
}
@@ -285,8 +297,7 @@ final class BuilderHelpers
*
* @return Node\AttributeGroup The Attribute Group
*/
public static function normalizeAttribute($attribute) : Node\AttributeGroup
{
public static function normalizeAttribute($attribute): Node\AttributeGroup {
if ($attribute instanceof Node\AttributeGroup) {
return $attribute;
}
@@ -302,12 +313,21 @@ final class BuilderHelpers
* Adds a modifier and returns new modifier bitmask.
*
* @param int $modifiers Existing modifiers
* @param int $modifier Modifier to set
* @param int $modifier Modifier to set
*
* @return int New modifiers
*/
public static function addModifier(int $modifiers, int $modifier) : int {
Stmt\Class_::verifyModifier($modifiers, $modifier);
public static function addModifier(int $modifiers, int $modifier): int {
Modifiers::verifyModifier($modifiers, $modifier);
return $modifiers | $modifier;
}
/**
* Adds a modifier and returns new modifier bitmask.
* @return int New modifiers
*/
public static function addClassModifier(int $existingModifiers, int $modifierToSet): int {
Modifiers::verifyClassModifier($existingModifiers, $modifierToSet);
return $existingModifiers | $modifierToSet;
}
}