forked from rectorphp/type-perfect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoArrayAccessOnObjectRuleTest.php
More file actions
49 lines (41 loc) · 1.59 KB
/
NoArrayAccessOnObjectRuleTest.php
File metadata and controls
49 lines (41 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace Rector\TypePerfect\Tests\Rules\NoArrayAccessOnObjectRule;
use Iterator;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\TypePerfect\Rules\NoArrayAccessOnObjectRule;
final class NoArrayAccessOnObjectRuleTest extends RuleTestCase
{
/**
* @param list<array{0: string, 1: int, 2?: string|null}> $expectedErrorMessagesWithLines
*/
#[DataProvider('provideData')]
public function testRule(string $filePath, array $expectedErrorMessagesWithLines): void
{
$this->analyse([$filePath], $expectedErrorMessagesWithLines);
}
public static function provideData(): Iterator
{
yield [__DIR__ . '/Fixture/ArrayAccessOnObject.php', [[NoArrayAccessOnObjectRule::ERROR_MESSAGE, 14]]];
yield [__DIR__ . '/Fixture/ArrayAccessOnNestedObject.php', [[NoArrayAccessOnObjectRule::ERROR_MESSAGE, 14]]];
yield [__DIR__ . '/Fixture/SkipIterator.php', []];
yield [__DIR__ . '/Fixture/SkipOnArray.php', []];
yield [__DIR__ . '/Fixture/SkipSplFixedArray.php', []];
yield [__DIR__ . '/Fixture/SkipWeakMap.php', []];
yield [__DIR__ . '/Fixture/SkipXml.php', []];
yield [__DIR__ . '/Fixture/SkipXmlElementForeach.php', []];
}
/**
* @return string[]
*/
public static function getAdditionalConfigFiles(): array
{
return [__DIR__ . '/../../../config/extension.neon'];
}
protected function getRule(): Rule
{
return self::getContainer()->getByType(NoArrayAccessOnObjectRule::class);
}
}