Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
"require-dev": {
"boundwize/structarmed": "^0.14",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1.33",
"phpstan/phpstan": "^2.2",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^11.5",
"rector/jack": "^0.5.1",
"phpunit/phpunit": "^13.2",
"rector/jack": "^1.0",
"rector/rector-src": "dev-main",
"rector/swiss-knife": "^2.3",
"symplify/easy-coding-standard": "^13.0",
"rector/swiss-knife": "^2.4",
"symplify/easy-coding-standard": "^13.2",
"symplify/phpstan-extensions": "^12.0",
"symplify/phpstan-rules": "^14.9",
"symplify/phpstan-rules": "^14.12",
"symplify/rule-doc-generator": "^12.2",
"symplify/vendor-patches": "^11.5",
"tomasvotruba/class-leak": "^2.1",
"tomasvotruba/type-coverage": "^2.3",
"tomasvotruba/unused-public": "^2.2",
"tracy/tracy": "^2.11"
"tracy/tracy": "^2.12"
},
"autoload": {
"psr-4": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
final class DowngradeVoidCastRectorTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
#[RequiresPhp('8.5')]
#[RequiresPhp('>= 8.5.0')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
final class DowngradePipeOperatorRectorTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
#[RequiresPhp('>= 8.5')]
#[RequiresPhp('>= 8.5.0')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private function removeParamTypeFromMethod(ClassMethod $classMethod, int $paramP

private function hasParamAlreadyNonTyped(ClassMethod $classMethod): bool
{
return array_all($classMethod->params, fn(Param $param): bool => !$param->type instanceof Node);
return array_all($classMethod->params, static fn (Param $param): bool => ! $param->type instanceof Node);
}

private function isSafeType(ClassReflection $classReflection, ClassMethod $classMethod): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ public function refactor(Node $node): ?array
* Remove the right-side-most params by reference or empty from `list()`,
* since they are not needed anymore.
*/
private function removeStaleParams(List_ | Array_ $node, int $rightSideRemovableParamsCount): void
private function removeStaleParams(List_|Array_ $node, int $rightSideRemovableParamsCount): void
{
$nodeItemsCount = count($node->items);
if ($rightSideRemovableParamsCount > 0) {
array_splice($node->items, $nodeItemsCount - $rightSideRemovableParamsCount);
}
}

private function shouldSkipAssign(Assign $assign, List_ | Array_ $arrayOrList): bool
private function shouldSkipAssign(Assign $assign, List_|Array_ $arrayOrList): bool
{
if (! $assign->expr instanceof Variable) {
return true;
Expand Down Expand Up @@ -264,7 +264,7 @@ private function hasAllItemsByRef(array $items): bool
/**
* Return the key inside the ArrayItem, if provided, or the position otherwise
*/
private function getArrayItemKey(ArrayItem $arrayItem, int | string $position): int | string
private function getArrayItemKey(ArrayItem $arrayItem, int|string $position): int|string
{
if ($arrayItem->key instanceof String_) {
return $arrayItem->key->value;
Expand All @@ -285,7 +285,7 @@ private function createAssignRefWithArrayDimFetch(
Variable $assignVariable,
Variable $exprVariable,
array $nestedArrayIndexes,
string | int $arrayIndex
string|int $arrayIndex
): Expression {
$nestedExprVariable = $exprVariable;
foreach ($nestedArrayIndexes as $nestedArrayIndex) {
Expand All @@ -301,7 +301,7 @@ private function createAssignRefWithArrayDimFetch(
}

/**
* @param array<(ArrayItem | null)> $arrayItems
* @param array<(ArrayItem|null)> $arrayItems
* @return ArrayItem[]
*/
private function getItemsByRef(array $arrayItems, int $condition): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private function getDifferentParamTypeFromReflectionMethod(
return null;
}

private function refactorParam(Param $param, ClassMethod | Function_ $functionLike): void
private function refactorParam(Param $param, ClassMethod|Function_ $functionLike): void
{
if (! $this->isNullableParam($param, $functionLike)) {
return;
Expand All @@ -260,7 +260,7 @@ private function refactorParam(Param $param, ClassMethod | Function_ $functionLi
$this->hasChanged = true;
}

private function decorateWithDocBlock(ClassMethod | Function_ $functionLike, Param $param): void
private function decorateWithDocBlock(ClassMethod|Function_ $functionLike, Param $param): void
{
if (! $param->type instanceof Node) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function refactor(Node $node): ?Node

private function resolveDifferentAncestorReturnType(
ClassMethod $classMethod,
UnionType | NullableType | Name | Identifier | ComplexType $returnTypeNode
UnionType|NullableType|Name|Identifier|ComplexType $returnTypeNode
): Type {
$classReflection = $this->reflectionResolver->resolveClassReflection($classMethod);
if (! $classReflection instanceof ClassReflection) {
Expand Down Expand Up @@ -261,6 +261,6 @@ private function isNullable(Type $parentReturnType, Type $returnType): bool
return false;
}

return array_any($parentReturnType->getTypes(), fn(Type $type): bool => $type->equals($returnType));
return array_any($parentReturnType->getTypes(), static fn (Type $type): bool => $type->equals($returnType));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private function shouldSkipFuncCall(FuncCall $funcCall): bool
}

private function createArrayFromString(
Array_ | Variable | PropertyFetch | ConstFetch | ClassConstFetch $expr
Array_|Variable|PropertyFetch|ConstFetch|ClassConstFetch $expr
): Concat {
$args = [new Arg(new String_('><')), new Arg($expr)];
$implodeFuncCall = new FuncCall(new Name('implode'), $args);
Expand All @@ -153,7 +153,7 @@ private function createArrayFromString(
}

private function createIsArrayTernaryFromExpression(
Variable | PropertyFetch | ConstFetch | ClassConstFetch $expr
Variable|PropertyFetch|ConstFetch|ClassConstFetch $expr
): Ternary {
$isArrayFuncCall = new FuncCall(new Name('is_array'), [new Arg($expr)]);
$nullNotIdentical = new NotIdentical($expr, $this->nodeFactory->createNull());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function refactor(Node $node): ?Node
return $node;
}

private function shouldSkip(Int_ | Float_ $node, mixed $rawValue): bool
private function shouldSkip(Int_|Float_ $node, mixed $rawValue): bool
{
if (! is_string($rawValue)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion rules/DowngradePhp80/NodeAnalyzer/NamedToUnnamedArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function fillFromNamedArgs(
* @return array<int, Arg>
*/
public function fillFromJumpedNamedArgs(
FunctionReflection | MethodReflection | ReflectionFunction $functionLikeReflection,
FunctionReflection|MethodReflection|ReflectionFunction $functionLikeReflection,
array $unnamedArgs,
array $parameters
): array {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
* @return Arg[]
*/
public function resolveFromReflection(
FunctionReflection | MethodReflection $functionLikeReflection,
FunctionReflection|MethodReflection $functionLikeReflection,
array $currentArgs
): array {
$extendedParametersAcceptor = ParametersAcceptorSelector::combineAcceptors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private function resolveIndentation(Node $node, AttributeGroup $attributeGroup,
}

private function cleanupEmptyAttrGroups(
ClassMethod | Property | Class_ | Interface_ | Param | Function_ $node
ClassMethod|Property|Class_|Interface_|Param|Function_ $node
): void {
foreach ($node->attrGroups as $key => $attrGroup) {
if ($attrGroup->attrs !== []) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private function refactorInArrowFunction(
* @return Case_[]
*/
private function createSwitchCasesFromMatchArms(
Echo_ | Expression | Return_ $node,
Echo_|Expression|Return_ $node,
Match_ $match,
bool $isInsideArrayItem = false
): array {
Expand Down Expand Up @@ -312,7 +312,7 @@ private function createSwitchCasesFromMatchArms(
* @return Stmt[]
*/
private function createSwitchStmts(
Echo_ | Expression | Return_ $node,
Echo_|Expression|Return_ $node,
MatchArm $matchArm,
bool $isInsideArrayItem
): array {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function refactorArrowFunctionReturn(ArrowFunction $arrowFunction): ?Clo
/**
* @return If_|Expression|Stmt[]|null
*/
private function refactorAssign(Assign $assign): If_ | Expression | null | array
private function refactorAssign(Assign $assign): If_|Expression|null|array
{
if (! $this->hasThrowInAssignExpr($assign)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getNodeTypes(): array
* @param FuncCall|BooleanNot $node
* @return Identical|NotIdentical|null The refactored node.
*/
public function refactor(Node $node): Identical | NotIdentical | null
public function refactor(Node $node): Identical|NotIdentical|null
{
$funcCall = $this->matchStrContainsOrNotStrContains($node);

Expand All @@ -87,7 +87,7 @@ public function refactor(Node $node): Identical | NotIdentical | null
return new NotIdentical($funcCall, $this->nodeFactory->createFalse());
}

private function matchStrContainsOrNotStrContains(FuncCall | BooleanNot $expr): ?FuncCall
private function matchStrContainsOrNotStrContains(FuncCall|BooleanNot $expr): ?FuncCall
{
$expr = ($expr instanceof BooleanNot) ? $expr->expr : $expr;
if (! $expr instanceof FuncCall) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function refactor(Node $node): ?Node
/**
* @param Arg[] $args
*/
private function removeNamedArguments(MethodCall | StaticCall | New_ | FuncCall $node, array $args): ?Node
private function removeNamedArguments(MethodCall|StaticCall|New_|FuncCall $node, array $args): ?Node
{
if ($node instanceof New_) {
$functionLikeReflection = $this->reflectionResolver->resolveMethodReflectionFromNew($node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private function createIfs(
/**
* @return string[]
*/
private function resolveClassConstFetchNames(ClassConstFetch | BitwiseOr $value): array
private function resolveClassConstFetchNames(ClassConstFetch|BitwiseOr $value): array
{
if ($value instanceof ClassConstFetch) {
$classConstFetchNames = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

final class DefaultParameterValueResolver
{
public function resolveFromParameterReflection(ParameterReflection $parameterReflection): Expr | null
public function resolveFromParameterReflection(ParameterReflection $parameterReflection): Expr|null
{
$defaultValueType = $parameterReflection->getDefaultValue();
if (! $defaultValueType instanceof Type) {
Expand All @@ -34,7 +34,7 @@ public function resolveFromParameterReflection(ParameterReflection $parameterRef
return $this->resolveValueFromType($defaultValueType);
}

private function resolveValueFromType(Type $constantType): ConstFetch | Expr
private function resolveValueFromType(Type $constantType): ConstFetch|Expr
{
if ($constantType instanceof ConstantBooleanType) {
return $this->resolveConstantBooleanType($constantType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Rector\DowngradePhp82\Rector\Class_;

use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Identifier;
use PhpParser\Node\IntersectionType;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
Expand Down Expand Up @@ -137,6 +137,6 @@ private function isUnionIntersection(?Node $node): bool
return false;
}

return array_any($node->types, fn(Identifier|Name|IntersectionType $type): bool => $type instanceof IntersectionType);
return array_any($node->types, static fn (Identifier|Name|IntersectionType $type): bool => $type instanceof IntersectionType);
}
}
Loading