diff --git a/.phive/phars.xml b/.phive/phars.xml
index 01e1351..320716d 100644
--- a/.phive/phars.xml
+++ b/.phive/phars.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
new file mode 100644
index 0000000..a0704cc
--- /dev/null
+++ b/phpstan-baseline.neon
@@ -0,0 +1,7 @@
+parameters:
+ ignoreErrors:
+ -
+ message: '#^Property CakeDumpSql\\Error\\VersionMismatchException\:\:\$message has no type specified\.$#'
+ identifier: missingType.property
+ count: 1
+ path: src/Error/VersionMismatchException.php
diff --git a/phpstan.neon b/phpstan.neon
index 4af7d9e..cd4f009 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,7 +1,13 @@
+includes:
+ - phpstan-baseline.neon
+
parameters:
paths:
- src
- tests/TestCase
- level: 5
+ level: 8
bootstrapFiles:
- - tests/bootstrap.php
\ No newline at end of file
+ - tests/bootstrap.php
+ ignoreErrors:
+ -
+ identifier: missingType.iterableValue
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 99f9081..d77e5a1 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -1,11 +1,8 @@
-
+
-
- shell_exec("$test $command")
+
+
-
- shell_exec("$test $command")
-
diff --git a/src/Command/DumpSqlCommand.php b/src/Command/DumpSqlCommand.php
index eb2c6a0..ad23cf6 100644
--- a/src/Command/DumpSqlCommand.php
+++ b/src/Command/DumpSqlCommand.php
@@ -89,6 +89,11 @@ public function execute(Arguments $args, ConsoleIo $io): int
if ($gzip) {
if (function_exists('gzencode')) {
$result = gzencode($result, 9);
+ if (!$result) {
+ $io->err('Failed to gzip the dump!');
+
+ return self::CODE_ERROR;
+ }
} else {
$io->err('Your PHP installation does not have zlib support to create a gzip file!');
diff --git a/src/Sql/SqlBase.php b/src/Sql/SqlBase.php
index 2d9598b..03786fc 100644
--- a/src/Sql/SqlBase.php
+++ b/src/Sql/SqlBase.php
@@ -66,6 +66,6 @@ protected function checkBinary(string $command): bool
$windows = str_starts_with(PHP_OS, 'WIN');
$test = $windows ? 'where' : 'command -v';
- return is_executable(trim(shell_exec("$test $command")));
+ return is_executable(trim(shell_exec("$test $command") ?: ''));
}
}
diff --git a/tests/TestCase/Command/DumpSqlCommandTest.php b/tests/TestCase/Command/DumpSqlCommandTest.php
index a79ffe3..507cc2d 100644
--- a/tests/TestCase/Command/DumpSqlCommandTest.php
+++ b/tests/TestCase/Command/DumpSqlCommandTest.php
@@ -92,8 +92,12 @@ public function testCommandGzipped(): void
$postsTable->save($entity);
$this->exec('dump_sql --gzip');
- $result = $this->_out->messages();
+ $result = $this->_out?->messages() ?? [];
$sql = gzdecode($result[0]);
+ if (!$sql) {
+ $this->fail('Failed to decode gzipped output');
+ }
+
if ($this->isDBType(Sqlite::class)) {
$this->assertStringContainsString('CREATE TABLE IF NOT EXISTS "posts"', $sql);
$this->assertStringContainsString('INSERT INTO posts VALUES(', $sql);