Skip to content

Commit

Permalink
Merge pull request #329 from FriendsOfCake/chore/maintainance
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
ADmad authored Nov 14, 2024
2 parents aaf5138 + 4d0e62b commit a79dcdc
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ trim_trailing_whitespace = true

[*.yml]
indent_size = 2

[*.neon]
indent_style = tab
7 changes: 7 additions & 0 deletions .github/codecov:.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
codecov:
require_ci_to_pass: no

coverage:
range: "90...100"

comment: false
31 changes: 17 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2']
prefer-lowest: ['']
php-version: ['8.1', '8.2', '8.3']
dependencies: ['highest']
include:
- php-version: '8.4'
dependencies: 'highest'
composer-options: '--ignore-platform-req=php'
- php-version: '8.1'
prefer-lowest: 'prefer-lowest'
dependencies: 'lowest'

steps:
- uses: actions/checkout@v4
Expand All @@ -42,27 +45,27 @@ jobs:
wkhtmltopdf --version
- name: Composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer install
fi
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: ${{ matrix.composer-options }}

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
if [[ ${{ matrix.php-version }} == '8.3' ]]; then
vendor/bin/phpunit --display-warnings --display-deprecations --display-incomplete --display-skipped --coverage-clover=coverage.xml
else
vendor/bin/phpunit
vendor/bin/phpunit --display-warnings --display-deprecations
fi
- name: Code Coverage Report
if: matrix.php-version == '8.1'
uses: codecov/codecov-action@v3
if: matrix.php-version == '8.3'
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

cs-stan:
uses: cakephp/.github/.github/workflows/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .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.10.37" installed="1.10.37" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.15.0" installed="5.15.0" location="./tools/psalm" copy="false"/>
<phar name="phpstan" version="2.0.1" installed="2.0.1" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
</phive>
16 changes: 9 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
parameters:
level: 6
checkMissingIterableValueType: false
bootstrapFiles:
- vendor/cakephp/cakephp/src/Core/Exception/CakeException.php
- tests/bootstrap.php
paths:
- src
level: 8
bootstrapFiles:
- vendor/cakephp/cakephp/src/Core/Exception/CakeException.php
- tests/bootstrap.php
paths:
- src
ignoreErrors:
-
identifier: missingType.iterableValue
11 changes: 0 additions & 11 deletions psalm-baseline.xml

This file was deleted.

4 changes: 3 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
Expand All @@ -32,5 +33,6 @@
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnsafeInstantiation errorLevel="info" />
<RiskyTruthyFalsyComparison errorLevel="info" />
</issueHandlers>
</psalm>
10 changes: 4 additions & 6 deletions src/Pdf/CakePdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ public function write(string $destination, bool $create = true, ?string $html =
}

$splFileInfo = $fileInfo->getPathInfo();
/** @phpstan-ignore-next-line */
if ($splFileInfo === null) {
throw new CakeException('Failed to retrieve path information');
}
Expand Down Expand Up @@ -378,7 +377,6 @@ public function engine(array|string|null $name = null): ?AbstractPdfEngine
$name = $name['className'];
}

/** @var class-string<\CakePdf\Pdf\Engine\AbstractPdfEngine>|null $engineClassName */
$engineClassName = App::className($name, 'Pdf/Engine', 'Engine');
if ($engineClassName === null) {
throw new CakeException(sprintf('Pdf engine "%s" not found', $name));
Expand Down Expand Up @@ -580,10 +578,10 @@ public function margin(
$right = $left;
}

$this->marginBottom($bottom);
$this->marginLeft($left);
$this->marginRight($right);
$this->marginTop($top);
$this->marginBottom($bottom); // @phpstan-ignore argument.type
$this->marginLeft($left); // @phpstan-ignore argument.type
$this->marginRight($right); // @phpstan-ignore argument.type
$this->marginTop($top); // @phpstan-ignore argument.type

return $this;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Pdf/Crypto/PdftkCrypto.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public function encrypt(string $data): string
];

$prochandle = proc_open($command, $descriptorspec, $pipes);
if ($prochandle === false) {
throw new CakeException('Unable to execute pdftk, proc_open() failed');
}

fwrite($pipes[0], $data);
fclose($pipes[0]);
Expand Down
4 changes: 4 additions & 0 deletions src/Pdf/Engine/TexToPdfEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ protected function _exec(string $cmd, string $input): array
$result = ['stdout' => '', 'stderr' => '', 'return' => ''];

$proc = proc_open($cmd, [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
if ($proc === false) {
throw new CakeException('Unable to execute latexpdf, proc_open() failed');
}

fwrite($pipes[0], $input);
fclose($pipes[0]);

Expand Down
8 changes: 4 additions & 4 deletions src/Pdf/Engine/WkHtmlToPdfEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ protected function _exec(string $cmd, string $input): array
$cwd = $this->getConfig('cwd');

$proc = proc_open($cmd, [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes, $cwd);
if ($proc === false) {
throw new CakeException('Unable to execute wkhtmltopdf, proc_open() failed');
}

fwrite($pipes[0], $input);
fclose($pipes[0]);

Expand Down Expand Up @@ -150,10 +154,6 @@ protected function _getCommand(): string
}
$command .= ' - -';

if ($this->_windowsEnvironment && PHP_MAJOR_VERSION < 8) {
$command = '"' . $command . '"';
}

return $command;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase/View/PdfViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
class PdfViewTest extends TestCase
{
protected PdfView $View;

/**
* setup callback
*
Expand Down

0 comments on commit a79dcdc

Please sign in to comment.