From 6d5ac035b7babd5edd61dec95710a23005a8b4e5 Mon Sep 17 00:00:00 2001 From: AhJ Date: Sat, 27 Jul 2024 16:37:05 +0330 Subject: [PATCH] fix phpcs-fix --- src/PseudoTypes/Conditional.php | 16 ++++++------ src/PseudoTypes/ConditionalParameter.php | 16 ++++++------ src/PseudoTypes/OffsetAccess.php | 14 +++++----- src/TypeResolver.php | 33 ++++++++++++------------ 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/PseudoTypes/Conditional.php b/src/PseudoTypes/Conditional.php index 44e0dec..bb610c5 100644 --- a/src/PseudoTypes/Conditional.php +++ b/src/PseudoTypes/Conditional.php @@ -40,12 +40,12 @@ public function getSubject(): Type public function __toString(): string { return sprintf( - '(%s %s %s ? %s : %s)', - $this->subject, - $this->negated ? 'is not' : 'is', - $this->target, - $this->if, - $this->else - ); - } + '(%s %s %s ? %s : %s)', + $this->subject, + $this->negated ? 'is not' : 'is', + $this->target, + $this->if, + $this->else + ); + } } diff --git a/src/PseudoTypes/ConditionalParameter.php b/src/PseudoTypes/ConditionalParameter.php index 7030151..b41eaec 100644 --- a/src/PseudoTypes/ConditionalParameter.php +++ b/src/PseudoTypes/ConditionalParameter.php @@ -40,12 +40,12 @@ public function getParameterName(): string public function __toString(): string { return sprintf( - '(%s %s %s ? %s : %s)', - $this->parameter, - $this->negated ? 'is not' : 'is', - $this->target, - $this->if, - $this->else - ); - } + '(%s %s %s ? %s : %s)', + $this->parameter, + $this->negated ? 'is not' : 'is', + $this->target, + $this->if, + $this->else + ); + } } diff --git a/src/PseudoTypes/OffsetAccess.php b/src/PseudoTypes/OffsetAccess.php index f752186..6b2587d 100644 --- a/src/PseudoTypes/OffsetAccess.php +++ b/src/PseudoTypes/OffsetAccess.php @@ -54,13 +54,13 @@ public function underlyingType(): Type */ public function __toString(): string { - if ( - $this->valueType instanceof Callable_ - || $this->valueType instanceof Nullable - ) { - return '(' . $this->valueType . ')[' . $this->offsetType . ']'; - } + if ( + $this->valueType instanceof Callable_ + || $this->valueType instanceof Nullable + ) { + return '(' . $this->valueType . ')[' . $this->offsetType . ']'; + } - return $this->valueType . '[' . $this->offsetType . ']'; + return $this->valueType . '[' . $this->offsetType . ']'; } } diff --git a/src/TypeResolver.php b/src/TypeResolver.php index 2d52f3c..cab4655 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -22,20 +22,8 @@ use phpDocumentor\Reflection\PseudoTypes\ProtectedPropertiesOf; use phpDocumentor\Reflection\PseudoTypes\PublicPropertiesOf; use phpDocumentor\Reflection\PseudoTypes\ValueOf; -use function trim; -use function strpos; -use function sprintf; use RuntimeException; -use function in_array; -use function array_map; -use function get_class; -use function strtolower; -use function array_filter; -use function class_exists; -use function array_reverse; use InvalidArgumentException; -use function array_key_exists; -use function class_implements; use phpDocumentor\Reflection\Type; use PHPStan\PhpDocParser\Lexer\Lexer; use Doctrine\Deprecations\Deprecation; @@ -112,7 +100,6 @@ use phpDocumentor\Reflection\PseudoTypes\ArrayShapeItem; use phpDocumentor\Reflection\PseudoTypes\CallableString; use phpDocumentor\Reflection\PseudoTypes\NonEmptyString; - use phpDocumentor\Reflection\PseudoTypes\ConstExpression; use phpDocumentor\Reflection\PseudoTypes\LowercaseString; use phpDocumentor\Reflection\PseudoTypes\NegativeInteger; @@ -125,7 +112,20 @@ use PHPStan\PhpDocParser\Ast\Type\CallableTypeParameterNode; use phpDocumentor\Reflection\PseudoTypes\ConditionalParameter; use phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString; + use PHPStan\PhpDocParser\Ast\Type\ConditionalTypeForParameterNode; +use function trim; +use function strpos; +use function sprintf; +use function in_array; +use function array_map; +use function get_class; +use function strtolower; +use function array_filter; +use function class_exists; +use function array_reverse; +use function array_key_exists; +use function class_implements; final class TypeResolver { @@ -290,6 +290,7 @@ function (ArrayShapeItemNode $item) use ($context): ListShapeItem { default: throw new RuntimeException('Unsupported array shape kind'); } + // no break case ObjectShapeNode::class: return new ObjectShape( ...array_map( @@ -464,7 +465,7 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ return new PrivatePropertiesOf( $subType->getFqsen() ); - + case 'list': return new List_( $this->createType($type->genericTypes[0], $context) @@ -474,12 +475,12 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ return new NonEmptyList( $this->createType($type->genericTypes[0], $context) ); - + case 'key-of': return new KeyOf( $this->createType($type->genericTypes[0], $context) ); - + case 'value-of': return new ValueOf( $this->createType($type->genericTypes[0], $context)