Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions admin/docs-phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
],
],

[
'identifier' => 'codeigniter.languageLineNotFound',
'paths' => [
'docs/outgoing/localization.md:359',
],
],

[
'identifier' => 'deadCode.unreachable',
'paths' => [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"require-dev": {
"boundwize/structarmed": "^0.21",
"codeigniter/phpstan-codeigniter": "^2.1",
"codeigniter/phpstan-codeigniter": "^2.3",
"fakerphp/faker": "^1.24",
"kint-php/kint": "^6.1",
"mikey179/vfsstream": "^1.6.12",
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Exceptions/HTTPException.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static function forMoveFailed(string $source, string $target, string $err
*/
public static function forInvalidSameSiteSetting(string $samesite)
{
return new static(lang('Security.invalidSameSiteSetting', [$samesite]));
return new static(lang('HTTP.invalidSameSiteSetting', [$samesite]));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Honeypot/Exceptions/HoneypotException.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function forNoNameField()
*/
public static function forNoHiddenValue()
{
return new static(lang('Honeypot.noHiddenValue'), 500);
return new static(lang('Honeypot.noHiddenValue'), 500); // @phpstan-ignore codeigniter.languageLineNotFound
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/system/Config/FactoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function testRespectsPath(): void
{
Factories::setOptions('models', ['path' => 'Widgets']);

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

Expand Down Expand Up @@ -275,7 +275,7 @@ class TestRegistrar
EOL;
file_put_contents($file, $source);

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

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

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

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

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

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

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

Expand Down Expand Up @@ -522,7 +522,7 @@ public function testGetCreatesConfigInstanceAndFactoriesConfigReturnsIt(): void

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

$this->assertNull($config);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/system/Language/LanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ public function testBaseLocaleVsVariants(): void
$this->assertSame('I have a very bad feeling about this', $lang->getLine('More.cannotMove'));

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

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

/**
Expand Down Expand Up @@ -365,10 +365,10 @@ public function testLangKeepLocale(): void
public function testAllTheWayFallbacks(): void
{
$lang = service('language', 'ab-CD', false);
$this->assertSame('Allin.none', $lang->getLine('Allin.none'));
$this->assertSame('Pyramid of Giza', $lang->getLine('Allin.one'));
$this->assertSame('gluttony', $lang->getLine('Allin.two'));
$this->assertSame('Colossus of Rhodes', $lang->getLine('Allin.tre'));
$this->assertSame('Allin.none', $lang->getLine('Allin.none')); // @phpstan-ignore codeigniter.languageLineNotFound
$this->assertSame('Pyramid of Giza', $lang->getLine('Allin.one')); // @phpstan-ignore codeigniter.languageLineNotFound
$this->assertSame('gluttony', $lang->getLine('Allin.two')); // @phpstan-ignore codeigniter.languageLineNotFound
$this->assertSame('Colossus of Rhodes', $lang->getLine('Allin.tre')); // @phpstan-ignore codeigniter.languageLineNotFound
$this->assertSame('four calling birds', $lang->getLine('Allin.for'));
$this->assertSame('Temple of Artemis', $lang->getLine('Allin.fiv'));
$this->assertSame('envy', $lang->getLine('Allin.six'));
Expand Down Expand Up @@ -402,6 +402,6 @@ public function testLanguageKeySeparatedByDot(): void
$lang->loadem('Foo', 'en');

$this->assertSame('The fieldname field is very short.', $lang->getLine('Foo.bar.min_length1', ['field' => 'fieldname']));
$this->assertSame('The fieldname field is very short.', $lang->getLine('Foo.baz.min_length3.short', ['field' => 'fieldname']));
$this->assertSame('The fieldname field is very short.', $lang->getLine('Foo.baz.min_length3.short', ['field' => 'fieldname'])); // @phpstan-ignore codeigniter.languageLineNotFound
}
}
4 changes: 2 additions & 2 deletions tests/system/Models/DataConverterModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function testUpdateArray(): void
$user = $this->model->find($id);

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

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

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

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

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

Expand Down
8 changes: 4 additions & 4 deletions tests/system/Models/EventsModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testInsertEvent(): void
'deleted' => 0,
];

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

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

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

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

public function testInsertBatchEvent(): void
Expand Down
8 changes: 4 additions & 4 deletions tests/system/Models/InsertModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function testInsertResultFail(): void
];
$this->createModel(JobModel::class);

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

$this->assertFalse($result);

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

public function testInsertEntityWithNoDataExceptionNoAllowedData(): void
Expand Down Expand Up @@ -320,7 +320,7 @@ public function testUseAutoIncrementSetToFalseInsert(): void
];

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

$this->assertSame($insert['key'], $this->model->getInsertID());
$this->seeInDatabase('without_auto_increment', $insert);
Expand Down Expand Up @@ -413,7 +413,7 @@ public function testInsertWithInvalidPrimaryKeyWhenAutoIncrementDisabled(
'value' => 'some value',
];

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

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/system/Models/SaveModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testSaveNewRecordArrayWithEmptyStringId(): void
'description' => 'Makes peoples things dissappear.',
];

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

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

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

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

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

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

$this->assertSame($insert['key'], $this->model->getInsertID());
$this->seeInDatabase('without_auto_increment', $insert);
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Models/TimestampModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function testDoNotAllowDatesUpdateArrayUpdatesUpdatedAt(): void
$user = $this->model->find($id);

$user['country'] = 'CA';
$this->model->update($user['id'], $user);
$this->model->update($user['id'], $user); // @phpstan-ignore codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed

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

Expand Down Expand Up @@ -265,7 +265,7 @@ public function testAllowDatesUpdateArrayUpdatesUpdatedAt(): void
$user = $this->model->find($id);

$user['country'] = 'CA';
$this->model->update($user['id'], $user);
$this->model->update($user['id'], $user); // @phpstan-ignore codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed

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

Expand Down
10 changes: 5 additions & 5 deletions tests/system/Models/UpdateModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function testUpdateArray(): void
];

$this->createModel(UserModel::class);
$this->model->insert($data);
$this->model->insert($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed

$result = $this->model->update([1, 2], ['name' => 'Foo Bar']);
$this->assertTrue($result);
Expand Down Expand Up @@ -130,11 +130,11 @@ public function testUpdateResultFail(): void
'country' => 'US',
'deleted' => 0,
];
$this->model->insert($data);
$this->model->insert($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed

$this->setPrivateProperty($this->model, 'allowedFields', ['name123']);

$result = $this->model->update(1, ['name123' => 'Foo Bar 1']);
$result = $this->model->update(1, ['name123' => 'Foo Bar 1']); // @phpstan-ignore codeigniter.modelFieldNotAllowed

$this->assertFalse($result);
$this->dontSeeInDatabase('user', ['id' => 1, 'name' => 'Foo Bar 1']);
Expand Down Expand Up @@ -327,7 +327,7 @@ public function testUpdateArrayWithDataException(): void
'deleted' => 0,
];

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

$this->expectException(DataException::class);
$this->expectExceptionMessage('There is no data to update.');
Expand Down Expand Up @@ -365,7 +365,7 @@ public function testUpdateArrayWithDataExceptionNoAllowedFields(): void
'deleted' => 0,
];

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

$this->expectException(DataException::class);
$this->expectExceptionMessage('There is no data to update.');
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Models/ValidationModelRuleGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function testValidationIncludingErrors(): void

$this->createModel(ValidErrorsModel::class);

$id = $this->model->insert($data);
$id = $this->model->insert($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed
$this->assertFalse((bool) $id);
$this->assertSame('Minimum Length Error', $this->model->errors()['name']);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Models/ValidationModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public function testValidationIncludingErrors(): void

$this->createModel(ValidErrorsModel::class);

$id = $this->model->insert($data);
$id = $this->model->insert($data); // @phpstan-ignore codeigniter.modelFieldNotAllowed, codeigniter.modelFieldNotAllowed
$this->assertFalse((bool) $id);
$this->assertSame('Minimum Length Error', $this->model->errors()['name']);
}
Expand Down
Loading