|
13 | 13 | class InvalidKeyInArrayDimFetchRuleTest extends RuleTestCase
|
14 | 14 | {
|
15 | 15 |
|
| 16 | + private bool $checkUnion = true; |
| 17 | + |
| 18 | + private bool $checkExplicitMixed = false; |
| 19 | + |
| 20 | + private bool $checkImplicitMixed = false; |
| 21 | + |
16 | 22 | protected function getRule(): Rule
|
17 | 23 | {
|
18 |
| - $ruleLevelHelper = new RuleLevelHelper(self::createReflectionProvider(), true, false, true, false, false, false, true); |
| 24 | + $ruleLevelHelper = new RuleLevelHelper( |
| 25 | + self::createReflectionProvider(), |
| 26 | + true, |
| 27 | + false, |
| 28 | + $this->checkUnion, |
| 29 | + $this->checkExplicitMixed, |
| 30 | + $this->checkImplicitMixed, |
| 31 | + false, |
| 32 | + true, |
| 33 | + ); |
| 34 | + |
19 | 35 | return new InvalidKeyInArrayDimFetchRule($ruleLevelHelper, true);
|
20 | 36 | }
|
21 | 37 |
|
@@ -61,6 +77,95 @@ public function testInvalidKey(): void
|
61 | 77 | ]);
|
62 | 78 | }
|
63 | 79 |
|
| 80 | + public function testInvalidKeyOnLevel6(): void |
| 81 | + { |
| 82 | + $this->checkUnion = false; |
| 83 | + |
| 84 | + $this->analyse([__DIR__ . '/data/invalid-key-array-dim-fetch.php'], [ |
| 85 | + [ |
| 86 | + 'Invalid array key type DateTimeImmutable.', |
| 87 | + 7, |
| 88 | + ], |
| 89 | + [ |
| 90 | + 'Invalid array key type array.', |
| 91 | + 8, |
| 92 | + ], |
| 93 | + [ |
| 94 | + 'Invalid array key type DateTimeImmutable.', |
| 95 | + 31, |
| 96 | + ], |
| 97 | + [ |
| 98 | + 'Invalid array key type DateTimeImmutable.', |
| 99 | + 45, |
| 100 | + ], |
| 101 | + [ |
| 102 | + 'Invalid array key type DateTimeImmutable.', |
| 103 | + 46, |
| 104 | + ], |
| 105 | + [ |
| 106 | + 'Invalid array key type DateTimeImmutable.', |
| 107 | + 47, |
| 108 | + ], |
| 109 | + [ |
| 110 | + 'Invalid array key type stdClass.', |
| 111 | + 47, |
| 112 | + ], |
| 113 | + [ |
| 114 | + 'Invalid array key type DateTimeImmutable.', |
| 115 | + 48, |
| 116 | + ], |
| 117 | + ]); |
| 118 | + } |
| 119 | + |
| 120 | + public function testInvalidKeyOnLevel10(): void |
| 121 | + { |
| 122 | + $this->checkExplicitMixed = true; |
| 123 | + $this->checkImplicitMixed = true; |
| 124 | + |
| 125 | + $this->analyse([__DIR__ . '/data/invalid-key-array-dim-fetch.php'], [ |
| 126 | + [ |
| 127 | + 'Invalid array key type DateTimeImmutable.', |
| 128 | + 7, |
| 129 | + ], |
| 130 | + [ |
| 131 | + 'Invalid array key type array.', |
| 132 | + 8, |
| 133 | + ], |
| 134 | + [ |
| 135 | + 'Possibly invalid array key type stdClass|string.', |
| 136 | + 24, |
| 137 | + ], |
| 138 | + [ |
| 139 | + 'Invalid array key type DateTimeImmutable.', |
| 140 | + 31, |
| 141 | + ], |
| 142 | + [ |
| 143 | + 'Possibly invalid array key type mixed.', |
| 144 | + 41, |
| 145 | + ], |
| 146 | + [ |
| 147 | + 'Invalid array key type DateTimeImmutable.', |
| 148 | + 45, |
| 149 | + ], |
| 150 | + [ |
| 151 | + 'Invalid array key type DateTimeImmutable.', |
| 152 | + 46, |
| 153 | + ], |
| 154 | + [ |
| 155 | + 'Invalid array key type DateTimeImmutable.', |
| 156 | + 47, |
| 157 | + ], |
| 158 | + [ |
| 159 | + 'Invalid array key type stdClass.', |
| 160 | + 47, |
| 161 | + ], |
| 162 | + [ |
| 163 | + 'Invalid array key type DateTimeImmutable.', |
| 164 | + 48, |
| 165 | + ], |
| 166 | + ]); |
| 167 | + } |
| 168 | + |
64 | 169 | #[RequiresPhp('>= 8.1')]
|
65 | 170 | public function testBug6315(): void
|
66 | 171 | {
|
|
0 commit comments