Skip to content

Commit 255b323

Browse files
authored
NoArrayAccessOnObjectRule: Skip Symfony DomCrawler AbstractUriElement and child types (#77)
1 parent bf9bd55 commit 255b323

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"symplify/easy-coding-standard": "^12.6",
1717
"phpstan/extension-installer": "^1.4",
1818
"tomasvotruba/class-leak": "^2.0",
19-
"tracy/tracy": "^2.10"
19+
"tracy/tracy": "^2.10",
20+
"symfony/dom-crawler": "^7.4"
2021
},
2122
"autoload": {
2223
"psr-4": {

src/Rules/NoArrayAccessOnObjectRule.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ final class NoArrayAccessOnObjectRule implements Rule
3232
'Iterator',
3333
'WeakMap',
3434
'Aws\ResultInterface',
35+
'Symfony\Component\DomCrawler\AbstractUriElement',
3536
'Symfony\Component\Form\FormInterface',
3637
'Symfony\Component\OptionsResolver\Options',
3738
];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\TypePerfect\Tests\Rules\NoArrayAccessOnObjectRule\Fixture;
6+
7+
use Symfony\Component\DomCrawler\Link;
8+
9+
final class SkipUriElement
10+
{
11+
public function run(Link $link)
12+
{
13+
return $link['href'];
14+
}
15+
}

tests/Rules/NoArrayAccessOnObjectRule/NoArrayAccessOnObjectRuleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static function provideData(): Iterator
2929
yield [__DIR__ . '/Fixture/SkipIterator.php', []];
3030
yield [__DIR__ . '/Fixture/SkipOnArray.php', []];
3131
yield [__DIR__ . '/Fixture/SkipSplFixedArray.php', []];
32+
yield [__DIR__ . '/Fixture/SkipUriElement.php', []];
3233
yield [__DIR__ . '/Fixture/SkipWeakMap.php', []];
3334
yield [__DIR__ . '/Fixture/SkipXml.php', []];
3435
yield [__DIR__ . '/Fixture/SkipXmlElementForeach.php', []];

0 commit comments

Comments
 (0)