diff --git a/system/Database/OCI8/Connection.php b/system/Database/OCI8/Connection.php index 12fa3b4d3df6..6f3d0dd7794c 100644 --- a/system/Database/OCI8/Connection.php +++ b/system/Database/OCI8/Connection.php @@ -53,6 +53,9 @@ class Connection extends BaseConnection 'rownum', ]; + /** + * @var array + */ protected $validDSNs = [ // TNS 'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', @@ -79,6 +82,8 @@ class Connection extends BaseConnection * * Used by storedProcedure() to prevent execute() from * re-setting the statement ID. + * + * @var bool */ protected $resetStmtId = true; diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index 2326eb06ac3b..fc5421a894ea 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -51,9 +51,24 @@ class Connection extends BaseConnection */ public $escapeChar = '"'; + /** + * @var string|null + */ protected $connect_timeout; + + /** + * @var string|null + */ protected $options; + + /** + * @var string|null + */ protected $sslmode; + + /** + * @var string|null + */ protected $service; /** diff --git a/tests/system/Config/FactoriesTest.php b/tests/system/Config/FactoriesTest.php index eafde84857e6..c87e4a135e2a 100644 --- a/tests/system/Config/FactoriesTest.php +++ b/tests/system/Config/FactoriesTest.php @@ -87,7 +87,10 @@ public function testUsesConfigOptions(): void { // Simulate having a $widgets property in App\Config\Factory $config = new class () extends Factory { - public $widgets = ['bar' => 'bam']; + /** + * @var array + */ + public array $widgets = ['bar' => 'bam']; }; Factories::injectMock('config', Factory::class, $config); diff --git a/tests/system/Config/fixtures/RegistrarConfig.php b/tests/system/Config/fixtures/RegistrarConfig.php index c2ea35927228..f42b8d5fa29c 100644 --- a/tests/system/Config/fixtures/RegistrarConfig.php +++ b/tests/system/Config/fixtures/RegistrarConfig.php @@ -15,8 +15,12 @@ class RegistrarConfig extends BaseConfig { - public $foo = 'bar'; - public $bar = [ + public string $foo = 'bar'; + + /** + * @var list + */ + public array $bar = [ 'baz', ]; } diff --git a/tests/system/Config/fixtures/SimpleConfig.php b/tests/system/Config/fixtures/SimpleConfig.php index 9c34d8561a3c..7f9be5b52dd8 100644 --- a/tests/system/Config/fixtures/SimpleConfig.php +++ b/tests/system/Config/fixtures/SimpleConfig.php @@ -15,45 +15,63 @@ class SimpleConfig extends BaseConfig { - public $QZERO; - public $QZEROSTR; - public $QEMPTYSTR; - public $QFALSE; - public $first = 'foo'; - public $second = 'bar'; - public $FOO; - public $onedeep; - public $default = [ + public ?string $QZERO = null; + public ?string $QZEROSTR = null; + public ?string $QEMPTYSTR = null; + public bool|string|null $QFALSE = null; + public string $first = 'foo'; + public string $second = 'bar'; + public ?string $FOO = null; + public ?string $onedeep = null; + + /** + * @var array + */ + public array $default = [ 'name' => null, ]; - public $simple = [ + + /** + * @var array + */ + public array $simple = [ 'name' => null, ]; // properties for environment override testing - public $alpha = 'one'; - public $bravo = 'two'; - public $charlie = 'three'; - public $delta = 'four'; - public $echo = ''; - public $foxtrot = 'false'; - public $fruit = 'pineapple'; - public $dessert = ''; - public $golf = 18; - public $crew = [ + public string $alpha = 'one'; + public string $bravo = 'two'; + public string $charlie = 'three'; + public string $delta = 'four'; + public string $echo = ''; + public bool|string $foxtrot = 'false'; + public string $fruit = 'pineapple'; + public string $dessert = ''; + public int $golf = 18; + + /** + * @var array + */ + public array $crew = [ 'captain' => 'Kirk', 'science' => 'Spock', 'doctor' => 'Bones', 'comms' => 'Uhuru', ]; - public $shortie; - public $longie; - public $onedeep_value; - public $one_deep = [ + + public ?string $shortie = null; + public ?string $longie = null; + public ?string $onedeep_value = null; + + /** + * @var array + */ + public array $one_deep = [ 'under_deep' => null, ]; - public $float = 12.34; - public $int = 1234; - public $password = 'secret'; - public ?int $size = null; + + public float $float = 12.34; + public int $int = 1234; + public string $password = 'secret'; + public ?int $size = null; } diff --git a/tests/system/Database/Live/ConnectTest.php b/tests/system/Database/Live/ConnectTest.php index e41fdbdfc114..e981d3ab33cf 100644 --- a/tests/system/Database/Live/ConnectTest.php +++ b/tests/system/Database/Live/ConnectTest.php @@ -28,9 +28,20 @@ final class ConnectTest extends CIUnitTestCase { use DatabaseTestTrait; - private $group1; - private $group2; - private $tests; + /** + * @var array + */ + private array $group1 = []; + + /** + * @var array + */ + private array $group2 = []; + + /** + * @var array + */ + private array $tests = []; protected function setUp(): void { diff --git a/tests/system/Database/Live/GetTest.php b/tests/system/Database/Live/GetTest.php index ce98ebf413e0..57a124d4fd0b 100644 --- a/tests/system/Database/Live/GetTest.php +++ b/tests/system/Database/Live/GetTest.php @@ -254,13 +254,13 @@ public function testGetRowWithReturnType(): void public function testGetRowWithCustomReturnType(): void { $testClass = new class () { - public $id; - public $name; - public $email; - public $country; - public $created_at; - public $updated_at; - public $deleted_at; + public mixed $id = null; + public mixed $name = null; + public mixed $email = null; + public mixed $country = null; + public mixed $created_at = null; + public mixed $updated_at = null; + public mixed $deleted_at = null; }; $user = $this->db->table('user')->get()->getRow(0, $testClass::class); diff --git a/tests/system/Database/Live/MySQLi/NumberNativeTest.php b/tests/system/Database/Live/MySQLi/NumberNativeTest.php index 4469e4c3659a..3834c4c3f9b0 100644 --- a/tests/system/Database/Live/MySQLi/NumberNativeTest.php +++ b/tests/system/Database/Live/MySQLi/NumberNativeTest.php @@ -27,7 +27,11 @@ final class NumberNativeTest extends CIUnitTestCase { use DatabaseTestTrait; - private $tests; + /** + * @var array + */ + private array $tests = []; + protected $refresh = true; protected $seed = CITestSeeder::class; diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 1c720f3cb0d4..37ac9a181531 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 1527 errors +# total 1480 errors includes: - argument.type.neon @@ -12,7 +12,6 @@ includes: - method.notFound.neon - missingType.iterableValue.neon - missingType.parameter.neon - - missingType.property.neon - nullCoalesce.property.neon - property.defaultValue.neon - property.nonObject.neon diff --git a/utils/phpstan-baseline/missingType.property.neon b/utils/phpstan-baseline/missingType.property.neon deleted file mode 100644 index 451773e8bc5d..000000000000 --- a/utils/phpstan-baseline/missingType.property.neon +++ /dev/null @@ -1,238 +0,0 @@ -# total 47 errors - -parameters: - ignoreErrors: - - - message: '#^Property CodeIgniter\\Database\\OCI8\\Connection\:\:\$resetStmtId has no type specified\.$#' - count: 1 - path: ../../system/Database/OCI8/Connection.php - - - - message: '#^Property CodeIgniter\\Database\\OCI8\\Connection\:\:\$validDSNs has no type specified\.$#' - count: 1 - path: ../../system/Database/OCI8/Connection.php - - - - message: '#^Property CodeIgniter\\Database\\Postgre\\Connection\:\:\$connect_timeout has no type specified\.$#' - count: 1 - path: ../../system/Database/Postgre/Connection.php - - - - message: '#^Property CodeIgniter\\Database\\Postgre\\Connection\:\:\$options has no type specified\.$#' - count: 1 - path: ../../system/Database/Postgre/Connection.php - - - - message: '#^Property CodeIgniter\\Database\\Postgre\\Connection\:\:\$service has no type specified\.$#' - count: 1 - path: ../../system/Database/Postgre/Connection.php - - - - message: '#^Property CodeIgniter\\Database\\Postgre\\Connection\:\:\$sslmode has no type specified\.$#' - count: 1 - path: ../../system/Database/Postgre/Connection.php - - - - message: '#^Property CodeIgniter\\Config\\Factory@anonymous/tests/system/Config/FactoriesTest\.php\:89\:\:\$widgets has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/FactoriesTest.php - - - - message: '#^Property RegistrarConfig\:\:\$bar has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/RegistrarConfig.php - - - - message: '#^Property RegistrarConfig\:\:\$foo has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/RegistrarConfig.php - - - - message: '#^Property SimpleConfig\:\:\$FOO has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$QEMPTYSTR has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$QFALSE has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$QZERO has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$QZEROSTR has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$alpha has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$bravo has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$charlie has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$crew has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$default has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$delta has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$dessert has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$echo has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$first has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$float has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$foxtrot has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$fruit has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$golf has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$int has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$longie has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$one_deep has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$onedeep has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$onedeep_value has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$password has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$second has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$shortie has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property SimpleConfig\:\:\$simple has no type specified\.$#' - count: 1 - path: ../../tests/system/Config/fixtures/SimpleConfig.php - - - - message: '#^Property CodeIgniter\\Database\\Live\\ConnectTest\:\:\$group1 has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/ConnectTest.php - - - - message: '#^Property CodeIgniter\\Database\\Live\\ConnectTest\:\:\$group2 has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/ConnectTest.php - - - - message: '#^Property CodeIgniter\\Database\\Live\\ConnectTest\:\:\$tests has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/ConnectTest.php - - - - message: '#^Property class@anonymous/tests/system/Database/Live/GetTest\.php\:256\:\:\$country has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/GetTest.php - - - - message: '#^Property class@anonymous/tests/system/Database/Live/GetTest\.php\:256\:\:\$created_at has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/GetTest.php - - - - message: '#^Property class@anonymous/tests/system/Database/Live/GetTest\.php\:256\:\:\$deleted_at has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/GetTest.php - - - - message: '#^Property class@anonymous/tests/system/Database/Live/GetTest\.php\:256\:\:\$email has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/GetTest.php - - - - message: '#^Property class@anonymous/tests/system/Database/Live/GetTest\.php\:256\:\:\$id has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/GetTest.php - - - - message: '#^Property class@anonymous/tests/system/Database/Live/GetTest\.php\:256\:\:\$name has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/GetTest.php - - - - message: '#^Property class@anonymous/tests/system/Database/Live/GetTest\.php\:256\:\:\$updated_at has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/GetTest.php - - - - message: '#^Property CodeIgniter\\Database\\Live\\MySQLi\\NumberNativeTest\:\:\$tests has no type specified\.$#' - count: 1 - path: ../../tests/system/Database/Live/MySQLi/NumberNativeTest.php