8000 UseIdenticalOverEqualWithSameTypeRector should not trust phpdoc (#6880) · rectorphp/rector-src@fdbcc40 · GitHub
[go: up one dir, main page]

Skip to content

Commit fdbcc40

Browse files
authored
UseIdenticalOverEqualWithSameTypeRector should not trust phpdoc (#6880)
* UseIdenticalOverEqualWithSameTypeRector should not trust phpdoc * fix * better fix * Update skip_phpdoc_shape.php.inc
1 parent c6df7f5 commit fdbcc40

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Rector\Tests\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector\Fixture;
4+
5+
final class SkipPhpdocArrayshape
6+
{
7+
/**
8+
* @return array{'sql': string, 'files': array<string>}
9+
*/
10+
public function getContent(): array
11+
{
12+
}
13+
14+
public function import()
15+
{
16+
$content = $this->getContent();
17+
18+
if (! isset($content['sql']) || $content['sql'] == '') {
19+
}
20+
}
21+
}

rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Rector\CodeQuality\Rector\Equal;
66

77
use PhpParser\Node;
8+
use PhpParser\Node\Expr\ArrayDimFetch;
89
use PhpParser\Node\Expr\BinaryOp\Equal;
910
use PhpParser\Node\Expr\BinaryOp\Identical;
1011
use PhpParser\Node\Expr\BinaryOp\NotEqual;
@@ -64,6 +65,10 @@ public function getNodeTypes(): array
6465
*/
6566
public function refactor(Node $node): ?Node
6667
{
68+
if ($node->left instanceof ArrayDimFetch || $node->right instanceof ArrayDimFetch) {
69+
return null;
70+
}
71+
6772
$leftStaticType = $this->nodeTypeResolver->getNativeType($node->left);
6873
$rightStaticType = $this->nodeTypeResolver->getNativeType($node->right);
6974

0 commit comments

Comments
 (0)
0