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
4 changes: 2 additions & 2 deletions system/CLI/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion system/CLI/Commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MySQLi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLite3/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== '')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalsn quick question. should the RHS of this conditional be checking === ''?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one... It's definitely a bug. It should be $this->password === ''

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my fault #9302

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be handled in a separate PR, so I'll hold off on the fix until this one is merged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming. I think this is good to be merged. Merging.

? new SQLite3($this->database)
: new SQLite3($this->database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $this->password);

Expand Down
2 changes: 1 addition & 1 deletion system/Test/FeatureTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ protected function populateGlobals(string $name, Request $request, ?array $param
);
}

$_SESSION = $this->session ?? [];
$_SESSION = $this->session;

return $request;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/system/Commands/BaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
6 changes: 3 additions & 3 deletions tests/system/Database/BaseConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/system/I18n/TimeDifferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -259,23 +259,23 @@ 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
{
$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
{
$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
}
}
3 changes: 2 additions & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# total 2808 errors
# total 2800 errors

includes:
- argument.type.neon
- assign.propertyType.neon
Expand Down
17 changes: 1 addition & 16 deletions utils/phpstan-baseline/property.notFound.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 59 errors
# total 51 errors

parameters:
ignoreErrors:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading