Skip to content

Commit c54a04a

Browse files
authored
chore: update to phpstan-codeigniter v2.3 (#10788)
1 parent 28da6fe commit c54a04a

14 files changed

Lines changed: 46 additions & 39 deletions

‎admin/docs-phpstan-baseline.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@
9191
],
9292
],
9393

94+
[
95+
'identifier' => 'codeigniter.languageLineNotFound',
96+
'paths' => [
97+
'docs/outgoing/localization.md:359',
98+
],
99+
],
100+
94101
[
95102
'identifier' => 'deadCode.unreachable',
96103
'paths' => [

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"require-dev": {
2020
"boundwize/structarmed": "^0.21",
21-
"codeigniter/phpstan-codeigniter": "^2.1",
21+
"codeigniter/phpstan-codeigniter": "^2.3",
2222
"fakerphp/faker": "^1.24",
2323
"kint-php/kint": "^6.1",
2424
"mikey179/vfsstream": "^1.6.12",

‎system/HTTP/Exceptions/HTTPException.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public static function forMoveFailed(string $source, string $target, string $err
236236
*/
237237
public static function forInvalidSameSiteSetting(string $samesite)
238238
{
239-
return new static(lang('Security.invalidSameSiteSetting', [$samesite]));
239+
return new static(lang('HTTP.invalidSameSiteSetting', [$samesite]));
240240
}
241241

242242
/**

‎system/Honeypot/Exceptions/HoneypotException.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function forNoNameField()
4747
*/
4848
public static function forNoHiddenValue()
4949
{
50-
return new static(lang('Honeypot.noHiddenValue'), 500);
50+
return new static(lang('Honeypot.noHiddenValue'), 500); // @phpstan-ignore codeigniter.languageLineNotFound
5151
}
5252

5353
/**

‎tests/system/Config/FactoriesTest.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function testRespectsPath(): void
220220
{
221221
Factories::setOptions('models', ['path' => 'Widgets']);
222222

223-
$result = Factories::models('SomeWidget');
223+
$result = Factories::models('SomeWidget'); // @phpstan-ignore codeigniter.modelArgumentType
224224
$this->assertInstanceOf(SomeWidget::class, $result);
225225
}
226226

@@ -275,7 +275,7 @@ class TestRegistrar
275275
EOL;
276276
file_put_contents($file, $source);
277277

278-
$result = Factories::config('TestRegistrar');
278+
$result = Factories::config('TestRegistrar'); // @phpstan-ignore codeigniter.configArgumentType
279279

280280
// @phpstan-ignore argument.type (Config\TestRegistrar is created at runtime by this test)
281281
$this->assertInstanceOf('Config\TestRegistrar', $result);
@@ -296,13 +296,13 @@ class TestRegistrar
296296
EOL;
297297
file_put_contents($file, $source);
298298

299-
$result = Factories::config(TestRegistrar::class);
299+
$result = Factories::config(TestRegistrar::class); // @phpstan-ignore codeigniter.configArgumentInstanceof
300300

301301
$this->assertInstanceOf(TestRegistrar::class, $result);
302302

303303
Factories::setOptions('config', ['preferApp' => false]);
304304

305-
$result = Factories::config(TestRegistrar::class);
305+
$result = Factories::config(TestRegistrar::class); // @phpstan-ignore codeigniter.configArgumentInstanceof
306306

307307
$this->assertInstanceOf(TestRegistrar::class, $result);
308308

@@ -522,7 +522,7 @@ public function testGetCreatesConfigInstanceAndFactoriesConfigReturnsIt(): void
522522

523523
public function testGetNonexistentClass(): void
524524
{
525-
$config = Factories::get('config', 'NonexistentClass');
525+
$config = Factories::get('config', 'NonexistentClass'); // @phpstan-ignore codeigniter.configArgumentType
526526

527527
$this->assertNull($config);
528528
}

‎tests/system/Language/LanguageTest.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ public function testBaseLocaleVsVariants(): void
324324
$this->assertSame('I have a very bad feeling about this', $lang->getLine('More.cannotMove'));
325325

326326
// key is in variant but not base; should pick variant
327-
$this->assertSame('There is no try', $lang->getLine('More.wisdom'));
327+
$this->assertSame('There is no try', $lang->getLine('More.wisdom')); // @phpstan-ignore codeigniter.languageLineNotFound
328328

329329
// key isn't in either base or variant; should return bad key
330-
$this->assertSame('More.shootMe', $lang->getLine('More.shootMe'));
330+
$this->assertSame('More.shootMe', $lang->getLine('More.shootMe')); // @phpstan-ignore codeigniter.languageLineNotFound
331331
}
332332

333333
/**
@@ -365,10 +365,10 @@ public function testLangKeepLocale(): void
365365
public function testAllTheWayFallbacks(): void
366366
{
367367
$lang = service('language', 'ab-CD', false);
368-
$this->assertSame('Allin.none', $lang->getLine('Allin.none'));
369-
$this->assertSame('Pyramid of Giza', $lang->getLine('Allin.one'));
370-
$this->assertSame('gluttony', $lang->getLine('Allin.two'));
371-
$this->assertSame('Colossus of Rhodes', $lang->getLine('Allin.tre'));
368+
$this->assertSame('Allin.none', $lang->getLine('Allin.none')); // @phpstan-ignore codeigniter.languageLineNotFound
369+
$this->assertSame('Pyramid of Giza', $lang->getLine('Allin.one')); // @phpstan-ignore codeigniter.languageLineNotFound
370+
$this->assertSame('gluttony', $lang->getLine('Allin.two')); // @phpstan-ignore codeigniter.languageLineNotFound
371+
$this->assertSame('Colossus of Rhodes', $lang->getLine('Allin.tre')); // @phpstan-ignore codeigniter.languageLineNotFound
372372
$this->assertSame('four calling birds', $lang->getLine('Allin.for'));
373373
$this->assertSame('Temple of Artemis', $lang->getLine('Allin.fiv'));
374374
$this->assertSame('envy', $lang->getLine('Allin.six'));
@@ -402,6 +402,6 @@ public function testLanguageKeySeparatedByDot(): void
402402
$lang->loadem('Foo', 'en');
403403

404404
$this->assertSame('The fieldname field is very short.', $lang->getLine('Foo.bar.min_length1', ['field' => 'fieldname']));
405-
$this->assertSame('The fieldname field is very short.', $lang->getLine('Foo.baz.min_length3.short', ['field' => 'fieldname']));
405+
$this->assertSame('The fieldname field is very short.', $lang->getLine('Foo.baz.min_length3.short', ['field' => 'fieldname'])); // @phpstan-ignore codeigniter.languageLineNotFound
406406
}
407407
}

‎tests/system/Models/DataConverterModelTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public function testUpdateArray(): void
291291
$user = $this->model->find($id);
292292

293293
$user['email'][] = 'private@example.org';
294-
$this->model->update($user['id'], $user);
294+
$this->model->update($user['id'], $user); // @phpstan-ignore codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed
295295

296296
$user = $this->model->find($id);
297297

@@ -358,7 +358,7 @@ public function testSaveArray(): void
358358
$user = $this->model->find($id);
359359

360360
$user['email'][] = 'private@example.org';
361-
$this->model->save($user);
361+
$this->model->save($user); // @phpstan-ignore codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed
362362

363363
$user = $this->model->find($id);
364364

‎tests/system/Models/EventsModelTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testInsertEvent(): void
4545
'deleted' => 0,
4646
];
4747

48-
$this->model()->insert($data);
48+
$this->model()->insert($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed
4949
$this->assertTrue($this->model()->hasToken('beforeInsert'));
5050
$this->assertTrue($this->model()->hasToken('afterInsert'));
5151
}
@@ -59,9 +59,9 @@ public function testUpdateEvent(): void
5959
'deleted' => 0,
6060
];
6161

62-
$id = $this->model()->insert($data);
62+
$id = $this->model()->insert($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed
6363

64-
$this->model()->update($id, $data);
64+
$this->model()->update($id, $data); // @phpstan-ignore codeigniter.modelFieldNotAllowed
6565
$this->assertTrue($this->model()->hasToken('beforeUpdate'));
6666
$this->assertTrue($this->model()->hasToken('afterUpdate'));
6767
}
@@ -174,7 +174,7 @@ public function testInvalidEventException(): void
174174

175175
$this->expectException(DataException::class);
176176
$this->expectExceptionMessage('"anotherBeforeInsertMethod" is not a valid Model Event callback.');
177-
$this->model()->insert($data);
177+
$this->model()->insert($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed
178178
}
179179

180180
public function testInsertBatchEvent(): void

‎tests/system/Models/InsertModelTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function testInsertResultFail(): void
179179
];
180180
$this->createModel(JobModel::class);
181181

182-
$result = $this->model->protect(false)->insert($data, false);
182+
$result = $this->model->protect(false)->insert($data, false); // @phpstan-ignore codeigniter.modelFieldNotAllowed
183183

184184
$this->assertFalse($result);
185185

@@ -278,7 +278,7 @@ public function testInsertArrayWithNoDataExceptionNoAllowedData(): void
278278
{
279279
$this->expectException(DataException::class);
280280
$this->expectExceptionMessage('There is no data to insert.');
281-
$this->createModel(UserModel::class)->insert(['thisKeyIsNotAllowed' => 'Bar']);
281+
$this->createModel(UserModel::class)->insert(['thisKeyIsNotAllowed' => 'Bar']); // @phpstan-ignore codeigniter.modelFieldNotAllowed
282282
}
283283

284284
public function testInsertEntityWithNoDataExceptionNoAllowedData(): void
@@ -320,7 +320,7 @@ public function testUseAutoIncrementSetToFalseInsert(): void
320320
];
321321

322322
$this->createModel(WithoutAutoIncrementModel::class);
323-
$this->model->insert($insert);
323+
$this->model->insert($insert); // @phpstan-ignore codeigniter.modelFieldNotAllowed
324324

325325
$this->assertSame($insert['key'], $this->model->getInsertID());
326326
$this->seeInDatabase('without_auto_increment', $insert);
@@ -413,7 +413,7 @@ public function testInsertWithInvalidPrimaryKeyWhenAutoIncrementDisabled(
413413
'value' => 'some value',
414414
];
415415

416-
$this->createModel(WithoutAutoIncrementModel::class)->insert($insert);
416+
$this->createModel(WithoutAutoIncrementModel::class)->insert($insert); // @phpstan-ignore codeigniter.modelFieldNotAllowed
417417
}
418418

419419
/**

‎tests/system/Models/SaveModelTest.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testSaveNewRecordArrayWithEmptyStringId(): void
5858
'description' => 'Makes peoples things dissappear.',
5959
];
6060

61-
$this->model->save($data);
61+
$this->model->save($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed
6262

6363
$this->seeInDatabase('job', ['name' => 'Magician']);
6464
}
@@ -86,7 +86,7 @@ public function testSaveNewRecordArrayFail(): void
8686
'name123' => 'Apprentice',
8787
'description' => 'That thing you do.',
8888
];
89-
$result = $this->model->protect(false)->save($data);
89+
$result = $this->model->protect(false)->save($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed
9090

9191
$this->assertFalse($result);
9292
$this->dontSeeInDatabase('job', ['name' => 'Apprentice']);
@@ -119,7 +119,7 @@ public function testSaveUpdateRecordArrayFail(): void
119119
'name123' => 'Apprentice',
120120
'description' => 'That thing you do.',
121121
];
122-
$result = $this->model->protect(false)->save($data);
122+
$result = $this->model->protect(false)->save($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed
123123

124124
$this->assertFalse($result);
125125
$this->dontSeeInDatabase('job', ['name' => 'Apprentice']);
@@ -210,7 +210,7 @@ public function testSetTable(): void
210210
'description' => 'That thing you do.',
211211
];
212212

213-
$this->model->protect(false)->save($data);
213+
$this->model->protect(false)->save($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed
214214
$lastInsertId = $this->model->getInsertID();
215215
$this->seeInDatabase('job', ['id' => $lastInsertId]);
216216
}
@@ -325,7 +325,7 @@ public function testUseAutoIncrementSetToFalseSave(): void
325325
];
326326

327327
$this->createModel(WithoutAutoIncrementModel::class);
328-
$this->model->save($insert);
328+
$this->model->save($insert); // @phpstan-ignore codeigniter.modelFieldNotAllowed
329329

330330
$this->assertSame($insert['key'], $this->model->getInsertID());
331331
$this->seeInDatabase('without_auto_increment', $insert);

0 commit comments

Comments
 (0)