From d54ceaa0d6b6f8b824db3e51099289c7eaeb47ea Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 19 Aug 2025 18:00:33 +0700 Subject: [PATCH] [CodeQuality] Skip docblock base type on 2nd arg on MatchAssertSameExpectedTypeRector --- .../Fixture/skip_docblock_type.php.inc | 21 +++++++++++++++++++ .../MatchAssertSameExpectedTypeRector.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/skip_docblock_type.php.inc diff --git a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/skip_docblock_type.php.inc b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/skip_docblock_type.php.inc new file mode 100644 index 00000000..a567ba36 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/skip_docblock_type.php.inc @@ -0,0 +1,21 @@ +assertSame('123', $this->getOrderId()); + } + + /** + * @return int + */ + private function getOrderId() + { + return '123'; + } +} diff --git a/rules/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector.php b/rules/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector.php index 4068f152..7492cdea 100644 --- a/rules/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector.php +++ b/rules/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector.php @@ -103,7 +103,7 @@ public function refactor(Node $node): ?Node $variableExpr = $node->getArgs()[1] ->value; - $variableType = $this->getType($variableExpr); + $variableType = $this->nodeTypeResolver->getNativeType($variableExpr); $directVariableType = TypeCombinator::removeNull($variableType);