diff --git a/system/CLI/BaseCommand.php b/system/CLI/BaseCommand.php index afeb80eb5267..57df52d47f55 100644 --- a/system/CLI/BaseCommand.php +++ b/system/CLI/BaseCommand.php @@ -142,7 +142,7 @@ public function showHelp() { CLI::write(lang('CLI.helpUsage'), 'yellow'); - if (isset($this->usage)) { + if ($this->usage !== null) { $usage = $this->usage; } else { $usage = $this->name; @@ -154,7 +154,7 @@ public function showHelp() CLI::write($this->setPad($usage, 0, 0, 2)); - if (isset($this->description)) { + if ($this->description !== null) { CLI::newLine(); CLI::write(lang('CLI.helpDescription'), 'yellow'); CLI::write($this->setPad($this->description, 0, 0, 2)); diff --git a/system/CLI/Commands.php b/system/CLI/Commands.php index aecd22c3f348..5630ee0f7b69 100644 --- a/system/CLI/Commands.php +++ b/system/CLI/Commands.php @@ -129,7 +129,7 @@ public function discoverCommands() $class = new $className($this->logger, $this); - if (isset($class->group) && ! isset($this->commands[$class->name])) { + if ($class->group !== null && ! isset($this->commands[$class->name])) { $this->commands[$class->name] = [ 'class' => $className, 'file' => $file, diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 2a9f9d3401c8..a1c0dcce8479 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -123,7 +123,7 @@ public function connect(bool $persistent = false) $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1); } - if (isset($this->strictOn)) { + if ($this->strictOn !== null) { if ($this->strictOn) { $this->mysqli->options( MYSQLI_INIT_COMMAND, diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index 0d3290b38d9d..7c3ad66e6fd5 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -107,7 +107,7 @@ public function connect(bool $persistent = false) $this->database = WRITEPATH . $this->database; } - $sqlite = (! isset($this->password) || $this->password !== '') + $sqlite = ($this->password === null || $this->password !== '') ? new SQLite3($this->database) : new SQLite3($this->database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $this->password); diff --git a/system/Test/FeatureTestTrait.php b/system/Test/FeatureTestTrait.php index 4e98fb505343..b1f6275ba60f 100644 --- a/system/Test/FeatureTestTrait.php +++ b/system/Test/FeatureTestTrait.php @@ -404,7 +404,7 @@ protected function populateGlobals(string $name, Request $request, ?array $param ); } - $_SESSION = $this->session ?? []; + $_SESSION = $this->session; return $request; } diff --git a/tests/system/Commands/BaseCommandTest.php b/tests/system/Commands/BaseCommandTest.php index cffb7963af44..47ca2a6f6a1b 100644 --- a/tests/system/Commands/BaseCommandTest.php +++ b/tests/system/Commands/BaseCommandTest.php @@ -36,14 +36,14 @@ public function testMagicIssetTrue(): void { $command = new AppInfo($this->logger, service('commands')); - $this->assertTrue(isset($command->group)); + $this->assertSame($command->group !== null, isset($command->group)); // @phpstan-ignore isset.property } public function testMagicIssetFalse(): void { $command = new AppInfo($this->logger, service('commands')); - $this->assertFalse(isset($command->foobar)); + $this->assertFalse(isset($command->foobar)); // @phpstan-ignore property.notFound } public function testMagicGet(): void @@ -57,6 +57,6 @@ public function testMagicGetMissing(): void { $command = new AppInfo($this->logger, service('commands')); - $this->assertNull($command->foobar); + $this->assertNull($command->foobar); // @phpstan-ignore property.notFound } } diff --git a/tests/system/Database/BaseConnectionTest.php b/tests/system/Database/BaseConnectionTest.php index be8f7d2642ad..dc598241c15c 100644 --- a/tests/system/Database/BaseConnectionTest.php +++ b/tests/system/Database/BaseConnectionTest.php @@ -169,14 +169,14 @@ public function testMagicIssetTrue(): void { $db = new MockConnection($this->options); - $this->assertTrue(isset($db->charset)); + $this->assertSame($db->charset !== null, isset($db->charset)); // @phpstan-ignore isset.property } public function testMagicIssetFalse(): void { $db = new MockConnection($this->options); - $this->assertFalse(isset($db->foobar)); + $this->assertFalse(isset($db->foobar)); // @phpstan-ignore property.notFound } public function testMagicGet(): void @@ -190,7 +190,7 @@ public function testMagicGetMissing(): void { $db = new MockConnection($this->options); - $this->assertNull($db->foobar); + $this->assertNull($db->foobar); // @phpstan-ignore property.notFound } /** diff --git a/tests/system/I18n/TimeDifferenceTest.php b/tests/system/I18n/TimeDifferenceTest.php index 4342d53f92ee..87607af54902 100644 --- a/tests/system/I18n/TimeDifferenceTest.php +++ b/tests/system/I18n/TimeDifferenceTest.php @@ -245,7 +245,7 @@ public function testGetterUTC(): void $this->assertSame(8, $diff->getDays()); $this->assertSame(8, $diff->days); $this->assertSame(-8, (int) round($diff->getDays(true))); - $this->assertNull($diff->nonsense); + $this->assertNull($diff->nonsense); // @phpstan-ignore property.notFound } public function testGetterDST(): void @@ -259,7 +259,7 @@ public function testGetterDST(): void // The raw value does not take Daylight Saving Time into account. $this->assertSame(-8, (int) round($diff->getDays(true))); - $this->assertNull($diff->nonsense); + $this->assertNull($diff->nonsense); // @phpstan-ignore property.notFound } public function testMagicIssetTrue(): void @@ -267,8 +267,8 @@ public function testMagicIssetTrue(): void $current = Time::parse('March 10, 2017', 'America/Chicago'); $diff = $current->difference('March 18, 2017', 'America/Chicago'); - $this->assertTrue(isset($diff->days)); - $this->assertFalse(isset($diff->nonsense)); + $this->assertTrue(isset($diff->days)); // @phpstan-ignore isset.property + $this->assertFalse(isset($diff->nonsense)); // @phpstan-ignore property.notFound } public function testMagicIssetFalse(): void @@ -276,6 +276,6 @@ public function testMagicIssetFalse(): void $current = Time::parse('March 10, 2017', 'America/Chicago'); $diff = $current->difference('March 18, 2017', 'America/Chicago'); - $this->assertFalse(isset($diff->nonsense)); + $this->assertFalse(isset($diff->nonsense)); // @phpstan-ignore property.notFound } } diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 76e5523f24c1..a9d0c530a37f 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,5 @@ -# total 2808 errors +# total 2800 errors + includes: - argument.type.neon - assign.propertyType.neon diff --git a/utils/phpstan-baseline/property.notFound.neon b/utils/phpstan-baseline/property.notFound.neon index 282a9234fddd..3d66f73b98bc 100644 --- a/utils/phpstan-baseline/property.notFound.neon +++ b/utils/phpstan-baseline/property.notFound.neon @@ -1,4 +1,4 @@ -# total 59 errors +# total 51 errors parameters: ignoreErrors: @@ -27,16 +27,6 @@ parameters: count: 1 path: ../../system/Session/Handlers/RedisHandler.php - - - message: '#^Access to an undefined property Tests\\Support\\Commands\\AppInfo\:\:\$foobar\.$#' - count: 2 - path: ../../tests/system/Commands/BaseCommandTest.php - - - - message: '#^Access to an undefined property CodeIgniter\\Test\\Mock\\MockConnection\:\:\$foobar\.$#' - count: 2 - path: ../../tests/system/Database/BaseConnectionTest.php - - message: '#^Access to an undefined property CodeIgniter\\Database\\BaseConnection\:\:\$mysqli\.$#' count: 1 @@ -102,11 +92,6 @@ parameters: count: 1 path: ../../tests/system/Encryption/Handlers/SodiumHandlerTest.php - - - message: '#^Access to an undefined property CodeIgniter\\I18n\\TimeDifference\:\:\$nonsense\.$#' - count: 4 - path: ../../tests/system/I18n/TimeDifferenceTest.php - - message: '#^Access to an undefined property CodeIgniter\\I18n\\TimeLegacy\:\:\$foobar\.$#' count: 1