Skip to content

Commit 9bdd3b4

Browse files
committed
Updated Rector to commit 0180e9bb149b532f2864c60bf255b04bf75107f0
rectorphp/rector-src@0180e9b [deprecation] Deprecate JoinStringConcatRector (#8107)
1 parent 2660080 commit 9bdd3b4

7 files changed

Lines changed: 36 additions & 70 deletions

File tree

rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,18 @@
33
declare (strict_types=1);
44
namespace Rector\CodeQuality\Rector\Concat;
55

6-
use RectorPrefix202606\Nette\Utils\Strings;
76
use PhpParser\Node;
87
use PhpParser\Node\Expr\BinaryOp\Concat;
9-
use PhpParser\Node\Scalar\String_;
8+
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
9+
use Rector\Exception\ShouldNotHappenException;
1010
use Rector\Rector\AbstractRector;
11-
use Rector\Util\StringUtils;
1211
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1312
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1413
/**
15-
* @see \Rector\Tests\CodeQuality\Rector\Concat\JoinStringConcatRector\JoinStringConcatRectorTest
14+
* @deprecated as depends on context and personal preference, hard to generalize. Handle it manually or via a custom rule instead.
1615
*/
17-
final class JoinStringConcatRector extends AbstractRector
16+
final class JoinStringConcatRector extends AbstractRector implements DeprecatedInterface
1817
{
19-
/**
20-
* @var int
21-
*/
22-
private const LINE_BREAK_POINT = 100;
23-
/**
24-
* @see https://regex101.com/r/VaXM1t/1
25-
* @see https://stackoverflow.com/questions/4147646/determine-if-utf-8-text-is-all-ascii
26-
* @var string
27-
*/
28-
private const ASCII_REGEX = '#[^\x00-\x7F]#';
2918
public function getRuleDefinition(): RuleDefinition
3019
{
3120
return new RuleDefinition('Joins concat of 2 strings, unless the length is too long', [new CodeSample(<<<'CODE_SAMPLE'
@@ -60,33 +49,6 @@ public function getNodeTypes(): array
6049
*/
6150
public function refactor(Node $node): ?Node
6251
{
63-
if (!$node->left instanceof String_) {
64-
return null;
65-
}
66-
if (!$node->right instanceof String_) {
67-
return null;
68-
}
69-
$leftStartLine = $node->left->getStartLine();
70-
$rightStartLine = $node->right->getStartLine();
71-
if ($leftStartLine > 0 && $rightStartLine > 0 && $rightStartLine > $leftStartLine) {
72-
return null;
73-
}
74-
return $this->joinConcatIfStrings($node->left, $node->right);
75-
}
76-
private function joinConcatIfStrings(String_ $leftString, String_ $rightString): ?String_
77-
{
78-
$leftValue = $leftString->value;
79-
$rightValue = $rightString->value;
80-
if (strpos($leftValue, "\n") !== \false || strpos($rightValue, "\n") !== \false) {
81-
return null;
82-
}
83-
$joinedStringValue = $leftValue . $rightValue;
84-
if (StringUtils::isMatch($joinedStringValue, self::ASCII_REGEX)) {
85-
return null;
86-
}
87-
if (Strings::length($joinedStringValue) >= self::LINE_BREAK_POINT) {
88-
return null;
89-
}
90-
return new String_($joinedStringValue);
52+
throw new ShouldNotHappenException(sprintf('"%s" is deprecated as depends on context and personal preference, hard to generalize. Handle it manually or via a custom rule instead', self::class));
9153
}
9254
}

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '07d1687ba9e752d2b0cfdf3cdb29a90630d2e257';
22+
public const PACKAGE_VERSION = '0180e9bb149b532f2864c60bf255b04bf75107f0';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-06-29 10:48:15';
27+
public const RELEASE_DATE = '2026-06-29 11:16:35';
2828
/**
2929
* @var int
3030
*/

src/Config/Level/CodeQualityLevel.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector;
2626
use Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector;
2727
use Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector;
28-
use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector;
2928
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
3029
use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector;
3130
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
@@ -108,7 +107,7 @@ final class CodeQualityLevel
108107
*
109108
* @var array<class-string<RectorInterface>>
110109
*/
111-
public const RULES = [FixClassCaseSensitivityVarDocblockRector::class, CombinedAssignRector::class, NewArrayItemConcatAssignToAssignRector::class, SimplifyEmptyArrayCheckRector::class, ReplaceMultipleBooleanNotRector::class, ReplaceConstantBooleanNotRector::class, ForeachToInArrayRector::class, RepeatedOrEqualToInArrayRector::class, RepeatedAndNotEqualToNotInArrayRector::class, MoveInnerFunctionToTopLevelRector::class, InnerFunctionToPrivateMethodRector::class, SimplifyForeachToCoalescingRector::class, SimplifyFuncGetArgsCountRector::class, SimplifyInArrayValuesRector::class, SimplifyStrposLowerRector::class, SimplifyArraySearchRector::class, SimplifyConditionsRector::class, SimplifyIfNotNullReturnRector::class, SimplifyIfReturnBoolRector::class, UnnecessaryTernaryExpressionRector::class, RemoveExtraParametersRector::class, SimplifyDeMorganBinaryRector::class, NegatedAndsToPositiveOrsRector::class, SimplifyTautologyTernaryRector::class, SingleInArrayToCompareRector::class, SimplifyIfElseToTernaryRector::class, TernaryImplodeToImplodeRector::class, JoinStringConcatRector::class, ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, ExplicitBoolCompareRector::class, CombineIfRector::class, UseIdenticalOverEqualWithSameTypeRector::class, SimplifyBoolIdenticalTrueRector::class, SimplifyRegexPatternRector::class, BooleanNotIdenticalToNotIdenticalRector::class, AndAssignsToSeparateLinesRector::class, CompactToVariablesRector::class, CompleteDynamicPropertiesRector::class, IsAWithStringWithThirdArgumentRector::class, StrlenZeroToIdenticalEmptyStringRector::class, ThrowWithPreviousExceptionRector::class, RemoveSoleValueSprintfRector::class, ShortenElseIfRector::class, ExplicitReturnNullRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, ArrayKeyExistsTernaryThenValueToCoalescingRector::class, AbsolutizeRequireAndIncludePathRector::class, ChangeArrayPushToArrayAssignRector::class, ForRepeatedCountToOwnVariableRector::class, ForeachItemsAssignToEmptyArrayToAssignRector::class, InlineIfToExplicitIfRector::class, UnusedForeachValueToArrayKeysRector::class, CommonNotEqualRector::class, SetTypeToCastRector::class, LogicalToBooleanRector::class, VarToPublicPropertyRector::class, IssetOnPropertyObjectToPropertyExistsRector::class, NewStaticToNewSelfRector::class, UnwrapSprintfOneArgumentRector::class, VariableConstFetchToClassConstFetchRector::class, SwitchNegatedTernaryRector::class, SingularSwitchToIfRector::class, SimplifyIfNullableReturnRector::class, CallUserFuncWithArrowFunctionToInlineRector::class, FlipTypeControlToUseExclusiveTypeRector::class, InlineArrayReturnAssignRector::class, InlineIsAInstanceOfRector::class, TernaryFalseExpressionToIfRector::class, InlineConstructorDefaultToPropertyRector::class, TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, OptionalParametersAfterRequiredRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, SwitchTrueToIfRector::class, CleanupUnneededNullsafeOperatorRector::class, DisallowedEmptyRuleFixerRector::class, LocallyCalledStaticMethodToNonStaticRector::class, NumberCompareToMaxFuncCallRector::class, CompleteMissingIfElseBracketRector::class, RemoveUselessIsObjectCheckRector::class, ConvertStaticToSelfRector::class, SortCallLikeNamedArgsRector::class, SortAttributeNamedArgsRector::class, RemoveReadonlyPropertyVisibilityOnReadonlyClassRector::class, SafeDeclareStrictTypesRector::class];
110+
public const RULES = [FixClassCaseSensitivityVarDocblockRector::class, CombinedAssignRector::class, NewArrayItemConcatAssignToAssignRector::class, SimplifyEmptyArrayCheckRector::class, ReplaceMultipleBooleanNotRector::class, ReplaceConstantBooleanNotRector::class, ForeachToInArrayRector::class, RepeatedOrEqualToInArrayRector::class, RepeatedAndNotEqualToNotInArrayRector::class, MoveInnerFunctionToTopLevelRector::class, InnerFunctionToPrivateMethodRector::class, SimplifyForeachToCoalescingRector::class, SimplifyFuncGetArgsCountRector::class, SimplifyInArrayValuesRector::class, SimplifyStrposLowerRector::class, SimplifyArraySearchRector::class, SimplifyConditionsRector::class, SimplifyIfNotNullReturnRector::class, SimplifyIfReturnBoolRector::class, UnnecessaryTernaryExpressionRector::class, RemoveExtraParametersRector::class, SimplifyDeMorganBinaryRector::class, NegatedAndsToPositiveOrsRector::class, SimplifyTautologyTernaryRector::class, SingleInArrayToCompareRector::class, SimplifyIfElseToTernaryRector::class, TernaryImplodeToImplodeRector::class, ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, ExplicitBoolCompareRector::class, CombineIfRector::class, UseIdenticalOverEqualWithSameTypeRector::class, SimplifyBoolIdenticalTrueRector::class, SimplifyRegexPatternRector::class, BooleanNotIdenticalToNotIdenticalRector::class, AndAssignsToSeparateLinesRector::class, CompactToVariablesRector::class, CompleteDynamicPropertiesRector::class, IsAWithStringWithThirdArgumentRector::class, StrlenZeroToIdenticalEmptyStringRector::class, ThrowWithPreviousExceptionRector::class, RemoveSoleValueSprintfRector::class, ShortenElseIfRector::class, ExplicitReturnNullRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, ArrayKeyExistsTernaryThenValueToCoalescingRector::class, AbsolutizeRequireAndIncludePathRector::class, ChangeArrayPushToArrayAssignRector::class, ForRepeatedCountToOwnVariableRector::class, ForeachItemsAssignToEmptyArrayToAssignRector::class, InlineIfToExplicitIfRector::class, UnusedForeachValueToArrayKeysRector::class, CommonNotEqualRector::class, SetTypeToCastRector::class, LogicalToBooleanRector::class, VarToPublicPropertyRector::class, IssetOnPropertyObjectToPropertyExistsRector::class, NewStaticToNewSelfRector::class, UnwrapSprintfOneArgumentRector::class, VariableConstFetchToClassConstFetchRector::class, SwitchNegatedTernaryRector::class, SingularSwitchToIfRector::class, SimplifyIfNullableReturnRector::class, CallUserFuncWithArrowFunctionToInlineRector::class, FlipTypeControlToUseExclusiveTypeRector::class, InlineArrayReturnAssignRector::class, InlineIsAInstanceOfRector::class, TernaryFalseExpressionToIfRector::class, InlineConstructorDefaultToPropertyRector::class, TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, OptionalParametersAfterRequiredRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, SwitchTrueToIfRector::class, CleanupUnneededNullsafeOperatorRector::class, DisallowedEmptyRuleFixerRector::class, LocallyCalledStaticMethodToNonStaticRector::class, NumberCompareToMaxFuncCallRector::class, CompleteMissingIfElseBracketRector::class, RemoveUselessIsObjectCheckRector::class, ConvertStaticToSelfRector::class, SortCallLikeNamedArgsRector::class, SortAttributeNamedArgsRector::class, RemoveReadonlyPropertyVisibilityOnReadonlyClassRector::class, SafeDeclareStrictTypesRector::class];
112111
/**
113112
* @var array<class-string<RectorInterface>, mixed[]>
114113
*/

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,12 +1802,12 @@
18021802
"source": {
18031803
"type": "git",
18041804
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
1805-
"reference": "191ed98195c62df0fd02755966caff7aa3d49a9d"
1805+
"reference": "2e1cd295f46219819063991671b5be30868aa35c"
18061806
},
18071807
"dist": {
18081808
"type": "zip",
1809-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/191ed98195c62df0fd02755966caff7aa3d49a9d",
1810-
"reference": "191ed98195c62df0fd02755966caff7aa3d49a9d",
1809+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/2e1cd295f46219819063991671b5be30868aa35c",
1810+
"reference": "2e1cd295f46219819063991671b5be30868aa35c",
18111811
"shasum": ""
18121812
},
18131813
"require": {
@@ -1835,7 +1835,7 @@
18351835
"tomasvotruba\/unused-public": "^2.2",
18361836
"tracy\/tracy": "^2.11"
18371837
},
1838-
"time": "2026-06-28T13:10:54+00:00",
1838+
"time": "2026-06-29T08:43:59+00:00",
18391839
"default-branch": true,
18401840
"type": "rector-extension",
18411841
"extra": {

0 commit comments

Comments
 (0)