Skip to content

docs: fix phpstan ignored errors in app/ and admin/starter/tests/ #8645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ExampleMigration extends Migration
{
protected $DBGroup = 'tests';

public function up()
public function up(): void
{
$this->forge->addField('id');
$this->forge->addField([
Expand All @@ -30,7 +30,7 @@ public function up()
$this->forge->createTable('factories');
}

public function down()
public function down(): void
{
$this->forge->dropTable('factories');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ExampleSeeder extends Seeder
{
public function run()
public function run(): void
{
$factories = [
[
Expand Down
4 changes: 2 additions & 2 deletions admin/starter/tests/database/ExampleDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class ExampleDatabaseTest extends CIUnitTestCase

protected $seed = ExampleSeeder::class;

public function testModelFindAll()
public function testModelFindAll(): void
{
$model = new ExampleModel();

Expand All @@ -25,7 +25,7 @@ public function testModelFindAll()
$this->assertCount(3, $objects);
}

public function testSoftDeleteLeavesRow()
public function testSoftDeleteLeavesRow(): void
{
$model = new ExampleModel();
$this->setPrivateProperty($model, 'useSoftDeletes', true);
Expand Down
2 changes: 1 addition & 1 deletion admin/starter/tests/session/ExampleSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
final class ExampleSessionTest extends CIUnitTestCase
{
public function testSessionSimple()
public function testSessionSimple(): void
{
$session = Services::session();

Expand Down
4 changes: 2 additions & 2 deletions admin/starter/tests/unit/HealthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*/
final class HealthTest extends CIUnitTestCase
{
public function testIsDefinedAppPath()
public function testIsDefinedAppPath(): void
{
$this->assertTrue(defined('APPPATH'));
}

public function testBaseUrlHasBeenSet()
public function testBaseUrlHasBeenSet(): void
{
$validation = Services::validation();

Expand Down
2 changes: 1 addition & 1 deletion app/Config/ContentSecurityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ContentSecurityPolicy extends BaseConfig
* The frame-src directive restricts the URLs which may
* be loaded into nested browsing contexts.
*
* @var array|string|null
* @var list<string>|string|null
*/
public $frameSrc;

Expand Down
4 changes: 4 additions & 0 deletions app/Config/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Database extends Config

/**
* The default database connection.
*
* @var array<string, mixed>
*/
public array $default = [
'DSN' => '',
Expand All @@ -48,6 +50,8 @@ class Database extends Config
/**
* This database connection is used when
* running PHPUnit database tests.
*
* @var array<string, mixed>
*/
public array $tests = [
'DSN' => '',
Expand Down
4 changes: 4 additions & 0 deletions app/Config/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Exceptions extends BaseConfig
* --------------------------------------------------------------------------
* Any status codes here will NOT be logged if logging is turned on.
* By default, only 404 (Page Not Found) exceptions are ignored.
*
* @var list<int>
*/
public array $ignoreCodes = [404];

Expand All @@ -51,6 +53,8 @@ class Exceptions extends BaseConfig
* Any data that you would like to hide from the debug trace.
* In order to specify 2 levels, use "/" to separate.
* ex. ['server', 'setup/password', 'secret_token']
*
* @var list<string>
*/
public array $sensitiveDataInTrace = [];

Expand Down
4 changes: 4 additions & 0 deletions app/Config/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Filters extends BaseConfig
* If you use this, you should disable auto-routing because auto-routing
* permits any HTTP method to access a controller. Accessing the controller
* with a method you don't expect could bypass the filter.
*
* @var array<string, list<string>>
*/
public array $methods = [];

Expand All @@ -64,6 +66,8 @@ class Filters extends BaseConfig
*
* Example:
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
*
* @var array<string, array<string, list<string>>>
*/
public array $filters = [];
}
4 changes: 3 additions & 1 deletion app/Config/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Logger extends BaseConfig
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
* your log files will fill up very fast.
*
* @var array|int
* @var int|list<int>
*/
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;

Expand Down Expand Up @@ -72,6 +72,8 @@ class Logger extends BaseConfig
*
* Handlers are executed in the order defined in this array, starting with
* the handler on top and continuing down.
*
* @var array<class-string, array<string, int|list<string>|string>>
*/
public array $handlers = [
/*
Expand Down
2 changes: 2 additions & 0 deletions app/Config/Mimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Mimes
{
/**
* Map of extensions to mime types.
*
* @var array<string, list<string>|string>
*/
public static array $mimes = [
'hqx' => [
Expand Down
4 changes: 3 additions & 1 deletion app/Config/Routing.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Routing extends BaseRouting
* found taking precedence.
*
* Default: APPPATH . 'Config/Routes.php'
*
* @var list<string>
*/
public array $routeFiles = [
APPPATH . 'Config/Routes.php',
Expand Down Expand Up @@ -106,7 +108,7 @@ class Routing extends BaseRouting
* 'blog' => 'Acme\Blog\Controllers',
* ]
*
* @var array [ uri_segment => namespace ]
* @var array<string, string>
*/
public array $moduleRoutes = [];
}
6 changes: 5 additions & 1 deletion app/Config/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Toolbar extends BaseConfig
* List of toolbar collectors that will be called when Debug Toolbar
* fires up and collects data from.
*
* @var list<string>
* @var list<class-string>
*/
public array $collectors = [
Timers::class,
Expand Down Expand Up @@ -99,6 +99,8 @@ class Toolbar extends BaseConfig
* We restrict the values to keep performance as high as possible.
*
* NOTE: The ROOTPATH will be prepended to all values.
*
* @var list<string>
*/
public array $watchedDirectories = [
'app',
Expand All @@ -111,6 +113,8 @@ class Toolbar extends BaseConfig
*
* Contains an array of file extensions that will be watched for changes and
* used to determine if the hot-reload feature should reload the page or not.
*
* @var list<string>
*/
public array $watchedExtensions = [
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class BaseController extends Controller
* class instantiation. These helpers will be available
* to all other controllers that extend BaseController.
*
* @var array
* @var list<string>
*/
protected $helpers = [];

Expand Down
Loading