From 3f3de0c08be1a6b5ac3abca77d23621b3fb84317 Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 5 Sep 2025 06:52:37 +0530 Subject: [PATCH 01/11] OrdSingleByteRector --- .../Fixture/multibyte-int.php.inc | 9 ++ .../Fixture/multibyte-str.php.inc | 9 ++ .../OrdSingleByteRectorTest.php | 28 ++++++ .../config/configured_rule.php | 13 +++ .../Rector/FuncCall/OrdSingleByteRector.php | 96 +++++++++++++++++++ src/ValueObject/PhpVersionFeature.php | 6 ++ 6 files changed, 161 insertions(+) create mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-int.php.inc create mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-str.php.inc create mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/OrdSingleByteRectorTest.php create mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/config/configured_rule.php create mode 100644 rules/Php85/Rector/FuncCall/OrdSingleByteRector.php diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-int.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-int.php.inc new file mode 100644 index 00000000000..aaffcdbfa77 --- /dev/null +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-int.php.inc @@ -0,0 +1,9 @@ + +----- + \ No newline at end of file diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-str.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-str.php.inc new file mode 100644 index 00000000000..aeb83b0cd5c --- /dev/null +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-str.php.inc @@ -0,0 +1,9 @@ + +----- + \ No newline at end of file diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/OrdSingleByteRectorTest.php b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/OrdSingleByteRectorTest.php new file mode 100644 index 00000000000..a9db1796a52 --- /dev/null +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/OrdSingleByteRectorTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/config/configured_rule.php b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/config/configured_rule.php new file mode 100644 index 00000000000..6989be8e1f1 --- /dev/null +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/config/configured_rule.php @@ -0,0 +1,13 @@ +rule(OrdSingleByteRector::class); + + $rectorConfig->phpVersion(PhpVersion::PHP_85); +}; diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php new file mode 100644 index 00000000000..f4dd71398a0 --- /dev/null +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -0,0 +1,96 @@ +isFirstClassCallable()) { + return null; + } + + if (! $this->isName($node, 'ord')) { + return null; + } + + $args = $node->getArgs(); + + if (! isset($node->args[0])) { + return null; + } + + $argExpr = $args[0]->value; + + $value = $this->valueResolver->getValue($argExpr); + + if ($value === null) { + return null; + } + + $isInt = is_int($value); + $value = (string) $value; + $byte = $value[0] ?? ''; + + $byteValue = $isInt ? new Int_((int) $byte) : new String_($byte); + + $args[0]->value = $byteValue; + $node->args = $args; + + return $node; + } + + public function provideMinPhpVersion(): int + { + return PhpVersionFeature::DEPRECATE_ORD_WITH_MULTIBYTE_STRING; + } +} diff --git a/src/ValueObject/PhpVersionFeature.php b/src/ValueObject/PhpVersionFeature.php index cf0b48bd481..087d11985a2 100644 --- a/src/ValueObject/PhpVersionFeature.php +++ b/src/ValueObject/PhpVersionFeature.php @@ -810,4 +810,10 @@ final class PhpVersionFeature * @var int */ public const DEPRECATE_OUTSIDE_INTERVEL_VAL_IN_CHR_FUNCTION = PhpVersion::PHP_85; + + /** + * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_string_which_are_not_one_byte_long_to_ord + * @var int + */ + public const DEPRECATE_ORD_WITH_MULTIBYTE_STRING = PhpVersion::PHP_85; } From 8cc7f07066f3abade286bcb1c50247aad87e347d Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 5 Sep 2025 07:11:58 +0530 Subject: [PATCH 02/11] OrdSingleByteRector --- .../{multibyte-int.php.inc => multibyte_int.php.inc} | 0 .../OrdSingleByteRector/Fixture/multibyte_int_var.php | 11 +++++++++++ .../{multibyte-str.php.inc => multibyte_str.php.inc} | 0 rules/Php85/Rector/FuncCall/OrdSingleByteRector.php | 7 ++++++- 4 files changed, 17 insertions(+), 1 deletion(-) rename rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/{multibyte-int.php.inc => multibyte_int.php.inc} (100%) create mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php rename rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/{multibyte-str.php.inc => multibyte_str.php.inc} (100%) diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-int.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc similarity index 100% rename from rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-int.php.inc rename to rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php new file mode 100644 index 00000000000..f4b0c78d071 --- /dev/null +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php @@ -0,0 +1,11 @@ + +----- + \ No newline at end of file diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-str.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_str.php.inc similarity index 100% rename from rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte-str.php.inc rename to rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_str.php.inc diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php index f4dd71398a0..e375f9bca73 100644 --- a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -70,6 +70,11 @@ public function refactor(Node $node): ?Node } $argExpr = $args[0]->value; + $type = $this->nodeTypeResolver->getNativeType($argExpr); + + if (! $type->isInteger()->yes() && ! $type->isString()->yes()) { + return null; + } $value = $this->valueResolver->getValue($argExpr); @@ -93,4 +98,4 @@ public function provideMinPhpVersion(): int { return PhpVersionFeature::DEPRECATE_ORD_WITH_MULTIBYTE_STRING; } -} +} \ No newline at end of file From 89eb0b48ab317bb7a40af3fb2074c019032e76b5 Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 5 Sep 2025 07:17:02 +0530 Subject: [PATCH 03/11] OrdSingleByteRector --- .../Fixture/{multibyte_int_var.php => multibyte_int_var.php.inc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/{multibyte_int_var.php => multibyte_int_var.php.inc} (100%) diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc similarity index 100% rename from rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php rename to rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc From 3c43485a9897883e7330800d55e091d14b68f753 Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 5 Sep 2025 07:17:56 +0530 Subject: [PATCH 04/11] OrdSingleByteRector --- config/set/php85.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/set/php85.php b/config/set/php85.php index a5a49624beb..19715d7a0c2 100644 --- a/config/set/php85.php +++ b/config/set/php85.php @@ -12,6 +12,7 @@ use Rector\Php85\Rector\Const_\DeprecatedAnnotationToDeprecatedAttributeRector; use Rector\Php85\Rector\FuncCall\ArrayKeyExistsNullToEmptyStringRector; use Rector\Php85\Rector\FuncCall\ChrArgModuloRector; +use Rector\Php85\Rector\FuncCall\OrdSingleByteRector; use Rector\Php85\Rector\FuncCall\RemoveFinfoBufferContextArgRector; use Rector\Php85\Rector\Switch_\ColonAfterSwitchCaseRector; use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector; @@ -37,6 +38,7 @@ ColonAfterSwitchCaseRector::class, ArrayKeyExistsNullToEmptyStringRector::class, ChrArgModuloRector::class, + OrdSingleByteRector::class, ] ); From 795f52e5a6129e11c0c6caf1b521751155758ffc Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 5 Sep 2025 21:52:35 +0530 Subject: [PATCH 05/11] OrdSingleByteRector --- .../Fixture/multibyte_int.php.inc | 9 -------- .../Fixture/multibyte_int_var.php.inc | 2 +- .../Fixture/multibyte_str.php.inc | 6 +++-- .../Fixture/skip_bool.php.inc | 5 ++++ .../Rector/FuncCall/OrdSingleByteRector.php | 23 ++++++------------- 5 files changed, 17 insertions(+), 28 deletions(-) delete mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc create mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/skip_bool.php.inc diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc deleted file mode 100644 index aaffcdbfa77..00000000000 --- a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc +++ /dev/null @@ -1,9 +0,0 @@ - ------ - \ No newline at end of file diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc index f4b0c78d071..b6cd3c4e60a 100644 --- a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc @@ -7,5 +7,5 @@ echo ord($i); \ No newline at end of file diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_str.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_str.php.inc index aeb83b0cd5c..af2fe155cb8 100644 --- a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_str.php.inc +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_str.php.inc @@ -1,9 +1,11 @@ ----- \ No newline at end of file diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/skip_bool.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/skip_bool.php.inc new file mode 100644 index 00000000000..db18509cbdf --- /dev/null +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/skip_bool.php.inc @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php index e375f9bca73..027cd8de271 100644 --- a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -5,9 +5,11 @@ namespace Rector\Php85\Rector\FuncCall; use PhpParser\Node; +use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Scalar\Int_; use PhpParser\Node\Scalar\String_; +use PhpParser\Node\Stmt\Expression; use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; @@ -34,11 +36,12 @@ public function getRuleDefinition(): RuleDefinition [ new CodeSample( <<<'CODE_SAMPLE' -echo ord('abc'); +$str = 'abc'; +echo ord($str); CODE_SAMPLE , <<<'CODE_SAMPLE' -echo ord('a'); +echo ord($str[0]); CODE_SAMPLE ), ] @@ -75,20 +78,8 @@ public function refactor(Node $node): ?Node if (! $type->isInteger()->yes() && ! $type->isString()->yes()) { return null; } - - $value = $this->valueResolver->getValue($argExpr); - - if ($value === null) { - return null; - } - - $isInt = is_int($value); - $value = (string) $value; - $byte = $value[0] ?? ''; - - $byteValue = $isInt ? new Int_((int) $byte) : new String_($byte); - - $args[0]->value = $byteValue; + + $args[0]->value = new ArrayDimFetch($argExpr, new Int_(0));; $node->args = $args; return $node; From ba1f3a363f7d55cd744ebb69e981b45b5421f484 Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 5 Sep 2025 21:59:01 +0530 Subject: [PATCH 06/11] OrdSingleByteRector --- .../Fixture/multibyte_int_var.php.inc | 11 ----------- .../Fixture/skip_multibyte_int_var.php.inc | 5 +++++ rules/Php85/Rector/FuncCall/OrdSingleByteRector.php | 4 ++-- 3 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc create mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/skip_multibyte_int_var.php.inc diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc deleted file mode 100644 index b6cd3c4e60a..00000000000 --- a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int_var.php.inc +++ /dev/null @@ -1,11 +0,0 @@ - ------ - \ No newline at end of file diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/skip_multibyte_int_var.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/skip_multibyte_int_var.php.inc new file mode 100644 index 00000000000..7cc95c53a58 --- /dev/null +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/skip_multibyte_int_var.php.inc @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php index 027cd8de271..93f0ad55b49 100644 --- a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -75,10 +75,10 @@ public function refactor(Node $node): ?Node $argExpr = $args[0]->value; $type = $this->nodeTypeResolver->getNativeType($argExpr); - if (! $type->isInteger()->yes() && ! $type->isString()->yes()) { + if (! $type->isString()->yes()) { return null; } - + $args[0]->value = new ArrayDimFetch($argExpr, new Int_(0));; $node->args = $args; From d40bfc0d16cb63f56c4c9f2938b4b11834f8cba2 Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 5 Sep 2025 22:05:37 +0530 Subject: [PATCH 07/11] OrdSingleByteRector --- rules/Php85/Rector/FuncCall/OrdSingleByteRector.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php index 93f0ad55b49..094c377daf0 100644 --- a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -8,9 +8,6 @@ use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Scalar\Int_; -use PhpParser\Node\Scalar\String_; -use PhpParser\Node\Stmt\Expression; -use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; @@ -23,12 +20,6 @@ */ final class OrdSingleByteRector extends AbstractRector implements MinPhpVersionInterface { - public function __construct( - private readonly ValueResolver $valueResolver - ) { - - } - public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( From bebd0f060218a73f1453461ff79d4919f53c1fa0 Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 5 Sep 2025 23:58:54 +0530 Subject: [PATCH 08/11] OrdSingleByteRector --- .../Fixture/multibyte_int.php.inc | 9 ++++ .../Rector/FuncCall/OrdSingleByteRector.php | 44 ++++++++++++++++--- 2 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc diff --git a/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc new file mode 100644 index 00000000000..aaffcdbfa77 --- /dev/null +++ b/rules-tests/Php85/Rector/FuncCall/OrdSingleByteRector/Fixture/multibyte_int.php.inc @@ -0,0 +1,9 @@ + +----- + \ No newline at end of file diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php index 094c377daf0..3aa022dd4a8 100644 --- a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -7,7 +7,10 @@ use PhpParser\Node; use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\FuncCall; +use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\Int_; +use PhpParser\Node\Scalar\String_; +use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; @@ -20,6 +23,12 @@ */ final class OrdSingleByteRector extends AbstractRector implements MinPhpVersionInterface { + public function __construct( + private readonly ValueResolver $valueResolver + ) { + + } + public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( @@ -27,12 +36,11 @@ public function getRuleDefinition(): RuleDefinition [ new CodeSample( <<<'CODE_SAMPLE' -$str = 'abc'; -echo ord($str); +echo ord('abc'); CODE_SAMPLE , <<<'CODE_SAMPLE' -echo ord($str[0]); +echo ord('a'); CODE_SAMPLE ), ] @@ -66,11 +74,35 @@ public function refactor(Node $node): ?Node $argExpr = $args[0]->value; $type = $this->nodeTypeResolver->getNativeType($argExpr); - if (! $type->isString()->yes()) { + if ($type->isString()->no() && $type->isInteger()->no()) { + return null; + } + + $value = $this->valueResolver->getValue($argExpr); + $isInt = is_int($value); + + if ($argExpr instanceof Variable) { + + if ($isInt) { + return null; + } + + $args[0]->value = new ArrayDimFetch($argExpr, new Int_(0)); + $node->args = $args; + + return $node; + } + + if ($value === null) { return null; } - $args[0]->value = new ArrayDimFetch($argExpr, new Int_(0));; + $value = (string) $value; + $byte = $value[0] ?? ''; + + $byteValue = $isInt ? new Int_((int) $byte) : new String_($byte); + + $args[0]->value = $byteValue; $node->args = $args; return $node; @@ -80,4 +112,4 @@ public function provideMinPhpVersion(): int { return PhpVersionFeature::DEPRECATE_ORD_WITH_MULTIBYTE_STRING; } -} \ No newline at end of file +} From f653cbf1b4de4c769df4a4fa2c6fc4d9bb7d3850 Mon Sep 17 00:00:00 2001 From: Arshid Date: Sat, 6 Sep 2025 00:16:41 +0530 Subject: [PATCH 09/11] OrdSingleByteRector --- rules/Php85/Rector/FuncCall/OrdSingleByteRector.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php index 3aa022dd4a8..17631ec73f6 100644 --- a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -7,7 +7,6 @@ use PhpParser\Node; use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\FuncCall; -use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\Int_; use PhpParser\Node\Scalar\String_; use Rector\PhpParser\Node\Value\ValueResolver; @@ -81,7 +80,7 @@ public function refactor(Node $node): ?Node $value = $this->valueResolver->getValue($argExpr); $isInt = is_int($value); - if ($argExpr instanceof Variable) { + if (! $argExpr instanceof Int_) { if ($isInt) { return null; From 9eeff4262c9d47df91448838590aa2e032e8627a Mon Sep 17 00:00:00 2001 From: Arshid Date: Sat, 6 Sep 2025 00:17:49 +0530 Subject: [PATCH 10/11] OrdSingleByteRector --- rules/Php85/Rector/FuncCall/OrdSingleByteRector.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php index 17631ec73f6..03a09292ed2 100644 --- a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -92,10 +92,6 @@ public function refactor(Node $node): ?Node return $node; } - if ($value === null) { - return null; - } - $value = (string) $value; $byte = $value[0] ?? ''; From 33841574d35c275a638bd53a0451ee9520caefec Mon Sep 17 00:00:00 2001 From: Arshid Date: Sat, 6 Sep 2025 20:40:43 +0530 Subject: [PATCH 11/11] Update rules/Php85/Rector/FuncCall/OrdSingleByteRector.php Co-authored-by: Abdul Malik Ikhsan --- rules/Php85/Rector/FuncCall/OrdSingleByteRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php index 03a09292ed2..d1219b039b6 100644 --- a/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php +++ b/rules/Php85/Rector/FuncCall/OrdSingleByteRector.php @@ -73,7 +73,7 @@ public function refactor(Node $node): ?Node $argExpr = $args[0]->value; $type = $this->nodeTypeResolver->getNativeType($argExpr); - if ($type->isString()->no() && $type->isInteger()->no()) { + if (! $type->isString()->yes() && ! $type->isInteger()->yes()) { return null; }