Skip to content

Commit f2b6ac2

Browse files
authored
NoArrayAccessOnObjectRule: Support WeakMap (#72)
1 parent ccc6d1e commit f2b6ac2

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/Rules/NoArrayAccessOnObjectRule.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ final class NoArrayAccessOnObjectRule implements Rule
3030
'SplFixedArray',
3131
'SimpleXMLElement',
3232
'Iterator',
33+
'WeakMap',
3334
'Aws\ResultInterface',
3435
'Symfony\Component\Form\FormInterface',
3536
'Symfony\Component\OptionsResolver\Options',
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 WeakMap;
8+
9+
final class SkipWeakMap
10+
{
11+
public function run(WeakMap $weakMap)
12+
{
13+
return $weakMap[0];
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/SkipWeakMap.php', []];
3233
yield [__DIR__ . '/Fixture/SkipXml.php', []];
3334
yield [__DIR__ . '/Fixture/SkipXmlElementForeach.php', []];
3435
}

0 commit comments

Comments
 (0)