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
2 changes: 1 addition & 1 deletion config/set/php72.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'jpeg2wbmp' => 'imagecreatefromjpeg',
# or imagewbmp
'png2wbmp' => 'imagecreatefrompng',
#migration72.deprecated.gmp_random-function
# migration72.deprecated.gmp_random-function
# http://php.net/manual/en/migration72.deprecated.php
# or gmp_random_range
'gmp_random' => 'gmp_random_bits',
Expand Down
2 changes: 1 addition & 1 deletion config/set/php74.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
return static function (RectorConfig $rectorConfig): void {
$rectorConfig
->ruleWithConfiguration(RenameFunctionRector::class, [
#the_real_type
# the_real_type
# https://wiki.php.net/rfc/deprecations_php_7_4
'is_real' => 'is_float',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function test(string $methodName, ?string $expectedReplacement): void
}

/**
* @return Iterator<string, array{string, (string | null)}>
* @return Iterator<string, array{string, (string|null)}>
*/
public static function provideData(): Iterator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
->ruleWithConfiguration(RenameClassRector::class, [
OldClass::class => NewClass::class,
// interface to class
SomeBasicDateTime::class =>
SomeBasicDateTimeInterface::class,
SomeBasicDateTime::class => SomeBasicDateTimeInterface::class,

// test casing
OldClassWithTypo::class => NewClassWithoutTypo::class,
Expand Down
6 changes: 3 additions & 3 deletions rules/Arguments/ArgumentDefaultValueReplacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function __construct(
* @return TCall|null
*/
public function processReplaces(
MethodCall | StaticCall | ClassMethod | FuncCall | New_ $node,
MethodCall|StaticCall|ClassMethod|FuncCall|New_ $node,
ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue
): MethodCall | StaticCall | ClassMethod | FuncCall | New_ |null {
): MethodCall|StaticCall|ClassMethod|FuncCall|New_|null {
if ($node instanceof ClassMethod) {
if (! isset($node->params[$replaceArgumentDefaultValue->getPosition()])) {
return null;
Expand Down Expand Up @@ -103,7 +103,7 @@ private function processParams(
* @return TCall|null
*/
private function processArgs(
MethodCall | StaticCall | FuncCall | New_ $expr,
MethodCall|StaticCall|FuncCall|New_ $expr,
ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue
): ?Expr {
if ($expr->isFirstClassCallable()) {
Expand Down
2 changes: 1 addition & 1 deletion rules/Arguments/NodeAnalyzer/ArgumentAddingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(
}

public function isInCorrectScope(
MethodCall | StaticCall $expr,
MethodCall|StaticCall $expr,
ArgumentAdder|ArgumentAdderWithoutDefaultValue $argumentAdder
): bool {
if ($argumentAdder->getScope() === null) {
Expand Down
12 changes: 6 additions & 6 deletions rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function getNodeTypes(): array
/**
* @param MethodCall|StaticCall|Class_ $node
*/
public function refactor(Node $node): MethodCall | StaticCall | Class_ | null
public function refactor(Node $node): MethodCall|StaticCall|Class_|null
{
$this->hasChanged = false;

Expand Down Expand Up @@ -139,7 +139,7 @@ public function configure(array $configuration): void
$this->addedArguments = $configuration;
}

private function isObjectTypeMatch(MethodCall | StaticCall $call, ObjectType $objectType): bool
private function isObjectTypeMatch(MethodCall|StaticCall $call, ObjectType $objectType): bool
{
if ($call instanceof MethodCall) {
return $this->isObjectType($call->var, $objectType);
Expand All @@ -149,7 +149,7 @@ private function isObjectTypeMatch(MethodCall | StaticCall $call, ObjectType $ob
}

private function processPositionWithDefaultValues(
ClassMethod | MethodCall | StaticCall $node,
ClassMethod|MethodCall|StaticCall $node,
ArgumentAdder|ArgumentAdderWithoutDefaultValue $argumentAdder
): void {
if ($this->shouldSkipParameter($node, $argumentAdder)) {
Expand Down Expand Up @@ -202,7 +202,7 @@ private function processMethodCall(
$this->hasChanged = true;
}

private function fillGapBetweenWithDefaultValue(MethodCall | StaticCall $node, int $position): void
private function fillGapBetweenWithDefaultValue(MethodCall|StaticCall $node, int $position): void
{
$lastPosition = count($node->getArgs()) - 1;
if ($position <= $lastPosition) {
Expand All @@ -229,7 +229,7 @@ private function fillGapBetweenWithDefaultValue(MethodCall | StaticCall $node, i
}

private function shouldSkipParameter(
ClassMethod | MethodCall | StaticCall $node,
ClassMethod|MethodCall|StaticCall $node,
ArgumentAdder|ArgumentAdderWithoutDefaultValue $argumentAdder
): bool {
$position = $argumentAdder->getPosition();
Expand Down Expand Up @@ -266,7 +266,7 @@ private function shouldSkipParameter(
if ($firstNamedArgumentPosition !== null) {
// Check if the parameter we're trying to add is before the first named argument
if ($position < $firstNamedArgumentPosition) {
return true; //if that is the case, the parameter already exists, skip
return true; // if that is the case, the parameter already exists, skip
}

// Check if the parameter we're trying to add is already present as a named argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getNodeTypes(): array
/**
* @param MethodCall|StaticCall|ClassMethod|New_ $node
*/
public function refactor(Node $node): MethodCall | StaticCall | ClassMethod | New_ | null
public function refactor(Node $node): MethodCall|StaticCall|ClassMethod|New_|null
{
if ($node instanceof New_) {
return $this->refactorNew($node);
Expand Down
2 changes: 1 addition & 1 deletion rules/Arguments/ValueObject/ArgumentAdder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
private readonly int $position,
private readonly ?string $argumentName = null,
private $argumentDefaultValue = null,
private readonly Type | null $argumentType = null,
private readonly Type|null $argumentType = null,
private readonly ?string $scope = null
) {
RectorAssert::className($class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(
private string $method,
private int $position,
private ?string $argumentName = null,
private Type | null $argumentType = null,
private Type|null $argumentType = null,
private ?string $scope = null
) {
RectorAssert::className($class);
Expand Down
2 changes: 1 addition & 1 deletion rules/CodeQuality/NodeManipulator/NamedArgsSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class NamedArgsSorter
*/
public function sortArgsToMatchReflectionParameters(
array $currentArgs,
FunctionReflection | MethodReflection $functionLikeReflection,
FunctionReflection|MethodReflection $functionLikeReflection,
): array {
$extendedParametersAcceptor = ParametersAcceptorSelector::combineAcceptors(
$functionLikeReflection->getVariants()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function refactor(Node $node): ?Class_
}

private function shouldSkip(
StaticPropertyFetch | StaticCall | ClassConstFetch $node,
StaticPropertyFetch|StaticCall|ClassConstFetch $node,
ClassReflection $classReflection,
bool $isFinal,
Scope $scope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private function isIfBodyABoolReturnNode(If_ $if): bool
return $this->valueResolver->isTrueOrFalse($ifStatement->expr);
}

private function createInArrayFunction(Expr $expr, Identical | Equal $binaryOp, Foreach_ $foreach): FuncCall
private function createInArrayFunction(Expr $expr, Identical|Equal $binaryOp, Foreach_ $foreach): FuncCall
{
$arguments = $this->nodeFactory->createArgs([$expr, $foreach->expr]);

Expand Down
16 changes: 8 additions & 8 deletions rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private function resolveNewConditionNode(Expr $expr, bool $isNegated): BinaryOp|
return null;
}

private function resolveCount(bool $isNegated, FuncCall $funcCall): Identical | Greater | null
private function resolveCount(bool $isNegated, FuncCall $funcCall): Identical|Greater|null
{
if ($funcCall->isFirstClassCallable()) {
return null;
Expand Down Expand Up @@ -208,7 +208,7 @@ private function resolveArray(bool $isNegated, Expr $expr): ?BinaryOp
return new NotIdentical($expr, $array);
}

private function resolveString(bool $isNegated, Expr $expr): Identical | NotIdentical | BooleanAnd | BooleanOr
private function resolveString(bool $isNegated, Expr $expr): Identical|NotIdentical|BooleanAnd|BooleanOr
{
$emptyString = new String_('');

Expand All @@ -231,7 +231,7 @@ private function resolveString(bool $isNegated, Expr $expr): Identical | NotIden
return $identical;
}

private function resolveIdentical(Expr $expr, bool $isNegated, String_ $string): Identical | NotIdentical
private function resolveIdentical(Expr $expr, bool $isNegated, String_ $string): Identical|NotIdentical
{
/**
* // compare === ''
Expand All @@ -244,17 +244,17 @@ private function resolveIdentical(Expr $expr, bool $isNegated, String_ $string):
}

private function resolveZeroIdenticalString(
Identical | NotIdentical $identical,
Identical|NotIdentical $identical,
bool $isNegated,
Expr $expr
): BooleanAnd | BooleanOr {
): BooleanAnd|BooleanOr {
$string = new String_('0');

$zeroIdentical = $isNegated ? new Identical($expr, $string) : new NotIdentical($expr, $string);
return $isNegated ? new BooleanOr($identical, $zeroIdentical) : new BooleanAnd($identical, $zeroIdentical);
}

private function resolveInteger(bool $isNegated, Expr $expr): Identical | NotIdentical
private function resolveInteger(bool $isNegated, Expr $expr): Identical|NotIdentical
{
$int = new Int_(0);

Expand All @@ -265,7 +265,7 @@ private function resolveInteger(bool $isNegated, Expr $expr): Identical | NotIde
return new NotIdentical($expr, $int);
}

private function resolveFloat(bool $isNegated, Expr $expr): Identical | NotIdentical
private function resolveFloat(bool $isNegated, Expr $expr): Identical|NotIdentical
{
$float = new Float_(0.0);

Expand All @@ -280,7 +280,7 @@ private function resolveNullable(
bool $isNegated,
Expr $expr,
ObjectType $objectType
): BooleanNot | Instanceof_ {
): BooleanNot|Instanceof_ {
$fullyQualified = new FullyQualified($objectType->getClassName());
$instanceof = new Instanceof_($expr, $fullyQualified);

Expand Down
2 changes: 1 addition & 1 deletion rules/CodingStyle/Naming/ClassNaming.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

final class ClassNaming
{
public function getShortName(string | Name | Identifier | ClassLike $name): string
public function getShortName(string|Name|Identifier|ClassLike $name): string
{
if ($name instanceof ClassLike) {
if (! $name->name instanceof Identifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public function provideMinPhpVersion(): int
}

private function applyVariadicParams(
ClassMethod | Function_ | Closure $node,
ClassMethod|Function_|Closure $node,
string $variableName
): ClassMethod | Function_ | Closure | null {
): ClassMethod|Function_|Closure|null {
$param = $this->createVariadicParam($variableName);

if ($param->var instanceof Variable && $this->hasFunctionOrClosureInside($node, $param->var)) {
Expand All @@ -124,7 +124,7 @@ private function applyVariadicParams(
}

private function hasFunctionOrClosureInside(
ClassMethod | Function_ | Closure $functionLike,
ClassMethod|Function_|Closure $functionLike,
Variable $variable
): bool {
if ($functionLike->stmts === null) {
Expand Down Expand Up @@ -156,7 +156,7 @@ private function hasFunctionOrClosureInside(
/**
* @return Expression<Assign>|null
*/
private function matchFuncGetArgsVariableAssign(ClassMethod | Function_ | Closure $functionLike): ?Expression
private function matchFuncGetArgsVariableAssign(ClassMethod|Function_|Closure $functionLike): ?Expression
{
/** @var Expression[] $expressions */
$expressions = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($functionLike, Expression::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function resolveCurrentStmtVariableName(Stmt $stmt): ?string

private function shouldAddEmptyLine(
?string $currentStmtVariableName,
ClassMethod | Function_ | Closure $node,
ClassMethod|Function_|Closure $node,
int $key
): bool {
if (! $this->isNewVariableThanBefore($currentStmtVariableName)) {
Expand All @@ -170,7 +170,7 @@ private function shouldAddEmptyLine(
return ! $this->isPrecededByEmptyLine($node, $key);
}

private function shouldSkipLeftVariable(Assign | MethodCall $node): bool
private function shouldSkipLeftVariable(Assign|MethodCall $node): bool
{
if (! $node->var instanceof Variable) {
return false;
Expand Down Expand Up @@ -201,7 +201,7 @@ private function isNewVariableThanBefore(?string $currentStmtVariableName): bool
return $this->previousStmtVariableName !== $currentStmtVariableName;
}

private function isPrecededByEmptyLine(ClassMethod | Function_ | Closure $node, int $key): bool
private function isPrecededByEmptyLine(ClassMethod|Function_|Closure $node, int $key): bool
{
if ($node->stmts === null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private function refactorIdenticalOrNotIdentical(
return null;
}

private function refactorGreaterOrSmaller(Greater | Smaller $binaryOp): NotIdentical | null
private function refactorGreaterOrSmaller(Greater|Smaller $binaryOp): NotIdentical|null
{
if ($binaryOp instanceof Greater) {
$leftExpr = $this->matchCountFuncCallArgExpr($binaryOp->left);
Expand All @@ -170,7 +170,7 @@ private function refactorGreaterOrSmaller(Greater | Smaller $binaryOp): NotIdent
return new NotIdentical(new Array_([]), $rightExpr);
}

private function refactorIfElseIf(If_ | ElseIf_ $ifElseIf): If_ | ElseIf_ | null
private function refactorIfElseIf(If_|ElseIf_ $ifElseIf): If_|ElseIf_|null
{
$expr = $this->matchCountFuncCallArgExpr($ifElseIf->cond);
if (! $expr instanceof Expr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private function isPhpVersionConstant(Expr $expr): bool
return $expr->name->toString() === 'PHP_VERSION';
}

private function getNewNodeForArg(Expr $expr): ConstFetch | Int_ | null
private function getNewNodeForArg(Expr $expr): ConstFetch|Int_|null
{
if ($this->isPhpVersionConstant($expr)) {
return new ConstFetch(new Name('PHP_VERSION_ID'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function refactorFor(For_ $for): For_|null
return $for;
}

private function processPrePost(PostInc | PostDec $node): PreInc | PreDec
private function processPrePost(PostInc|PostDec $node): PreInc|PreDec
{
if ($node instanceof PostInc) {
return new PreInc($node->var);
Expand Down
2 changes: 1 addition & 1 deletion rules/DeadCode/ConditionEvaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function evaluate(ConditionInterface $condition): bool|int|null

private function evaluateVersionCompareCondition(
VersionCompareCondition $versionCompareCondition
): bool | int | null {
): bool|int|null {
$compareSign = $versionCompareCondition->getCompareSign();
if ($compareSign !== null) {
if ($compareSign === '<' && $this->phpVersionProvider->provide() < $versionCompareCondition->getSecondVersion()) {
Expand Down
3 changes: 1 addition & 2 deletions rules/DeadCode/NodeAnalyzer/IsClassMethodUsedAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private function isClassMethodCalledInLocalArrayCall(Class_ $class, ClassMethod
return false;
}

private function shouldSkipArrayCallable(Class_ $class, null | ArrayCallable $arrayCallable): bool
private function shouldSkipArrayCallable(Class_ $class, null|ArrayCallable $arrayCallable): bool
{
if (! $arrayCallable instanceof ArrayCallable) {
return true;
Expand Down Expand Up @@ -183,7 +183,6 @@ private function isUsedByTrait(Trait_ $trait, string $classMethodName, string $c
/**
* Trait can't detect class type, so it rely on "this" or "self" or "static" or "ClassName::methodName()" usage...
*/

$callMethod = null;
$this->simpleCallableNodeTraverser->traverseNodesWithCallable(
(array) $classMethod->stmts,
Expand Down
2 changes: 1 addition & 1 deletion rules/DeadCode/NodeManipulator/LivingCodeManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
/**
* @return Expr[]|mixed[]
*/
public function keepLivingCodeFromExpr(Node | int | string | null $expr): array
public function keepLivingCodeFromExpr(Node|int|string|null $expr): array
{
if (! $expr instanceof Expr) {
return [];
Expand Down
2 changes: 1 addition & 1 deletion rules/DeadCode/PhpDoc/TagRemover/VarTagRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function removeVarTag(Node $node): bool
return true;
}

public function removeVarPhpTagValueNodeIfNotComment(Expression | Property | Param $node, Type $type): void
public function removeVarPhpTagValueNodeIfNotComment(Expression|Property|Param $node, Type $type): void
{
if ($type instanceof TemplateObjectWithoutClassType) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class RemovePhpVersionIdCheckRector extends AbstractRector
/**
* @var PhpVersion::*|null
*/
private int | null $phpVersion = null;
private int|null $phpVersion = null;

public function __construct(
private readonly PhpVersionProvider $phpVersionProvider,
Expand Down
Loading
Loading