Skip to content

Commit

Permalink
Merge branch '2.x' into 2.next
Browse files Browse the repository at this point in the history
# Conflicts:
#	.phive/phars.xml
  • Loading branch information
LordSimal committed Nov 17, 2024
2 parents 56a8b8e + 7d67bb7 commit 0efcee1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.11.11" installed="1.11.11" location="./tools/phpstan" copy="false"/>
<phar name="phpstan" version="2.0.1" installed="2.0.1" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.25.0" installed="5.25.0" location="./tools/psalm" copy="false"/>
</phive>
7 changes: 7 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
includes:
- phpstan-baseline.neon

parameters:
paths:
- src
- tests/TestCase
level: 5
level: 8
bootstrapFiles:
- tests/bootstrap.php
- tests/bootstrap.php
ignoreErrors:
-
identifier: missingType.iterableValue
9 changes: 3 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@">
<files psalm-version="5.14.1@b9d355e0829c397b9b3b47d0c0ed042a8a70284d">
<file src="src/Sql/SqlBase.php">
<ForbiddenCode occurrences="1">
<code>shell_exec("$test $command")</code>
<ForbiddenCode>
<code><![CDATA[shell_exec("$test $command")]]></code>
</ForbiddenCode>
<PossiblyNullArgument occurrences="1">
<code>shell_exec("$test $command")</code>
</PossiblyNullArgument>
</file>
</files>
5 changes: 5 additions & 0 deletions src/Command/DumpSqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public function execute(Arguments $args, ConsoleIo $io): int
if ($gzip) {
if (function_exists('gzencode')) {
$result = gzencode($result, 9);
if (!$result) {

Check failure on line 92 in src/Command/DumpSqlCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

RiskyTruthyFalsyComparison

src/Command/DumpSqlCommand.php:92:21: RiskyTruthyFalsyComparison: Operand of type false|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
$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!');

Expand Down
2 changes: 1 addition & 1 deletion src/Sql/SqlBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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") ?: ''));

Check failure on line 69 in src/Sql/SqlBase.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

RiskyTruthyFalsyComparison

src/Sql/SqlBase.php:69:35: RiskyTruthyFalsyComparison: Operand of type false|null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
}
}
6 changes: 5 additions & 1 deletion tests/TestCase/Command/DumpSqlCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0efcee1

Please sign in to comment.