Merge branch 'master' into issue2912

This commit is contained in:
oleibman
2025-08-26 08:28:37 -07:00
committed by GitHub
6 changed files with 72 additions and 35 deletions
+9 -3
View File
@@ -250,9 +250,15 @@ jobs:
- name: Coverage
run: |
./vendor/bin/phpunit --coverage-clover coverage-clover.xml
composer global require scrutinizer/ocular
~/.composer/vendor/bin/ocular code-coverage:upload --format=php-clover coverage-clover.xml
./vendor/bin/phpunit --coverage-clover build/clover.xml
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
chmod +x php-coveralls.phar
php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv
release:
permissions:
-30
View File
@@ -1,30 +0,0 @@
checks:
php: true
coding_style:
php:
spaces:
before_parentheses:
closure_definition: true
around_operators:
concatenation: true
build:
nodes:
analysis:
image: default-bionic
environment:
php: 8.2
tests:
override:
- php-scrutinizer-run
tools:
external_code_coverage:
timeout: 600
build_failure_conditions:
- 'elements.rating(<= D).new.exists' # No new classes/methods with a rating of D or worse allowed
- 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity
- 'project.metric_change("scrutinizer.test_coverage", < 0)' # Code Coverage decreased from previous inspection
- 'patches.label("Unused Use Statements").new.exists' # No new unused imports patches allowed
@@ -722,4 +722,19 @@ class StringHelper
return $default;
}
/**
* Php introduced str_increment with Php8.3,
* but didn't issue deprecation notices till 8.5.
*
* @codeCoverageIgnore
*/
public static function stringIncrement(string &$str): void
{
if (function_exists('str_increment')) {
$str = str_increment($str); // @phpstan-ignore-line
} else {
++$str; // @phpstan-ignore-line
}
}
}
+2 -2
View File
@@ -571,7 +571,7 @@ class Html extends BaseWriter
}
++$column;
/** @var string $colStr */
++$colStr;
StringHelper::stringIncrement($colStr);
}
$html .= $this->generateRow($sheet, $rowData, $row - 1, $cellType);
}
@@ -941,7 +941,7 @@ class Html extends BaseWriter
if ($this->shouldGenerateColumn($sheet, $colStr)) {
$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = self::DEFAULT_CELL_WIDTH_POINTS . 'pt';
}
++$colStr;
StringHelper::stringIncrement($colStr);
}
// col elements, loop through columnDimensions and set width
+28
View File
@@ -44,6 +44,13 @@ class Dompdf extends Pdf
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
// Create PDF
$restoreHandler = false;
if (PHP_VERSION_ID >= self::$temporaryVersionCheck) {
// @codeCoverageIgnoreStart
set_error_handler(self::specialErrorHandler(...));
$restoreHandler = true;
// @codeCoverageIgnoreEnd
}
$pdf = $this->createExternalWriterInstance();
$pdf->setPaper($paperSize, $orientation);
@@ -53,6 +60,27 @@ class Dompdf extends Pdf
// Write to file
fwrite($fileHandle, $pdf->output() ?? '');
if ($restoreHandler) {
restore_error_handler(); // @codeCoverageIgnore
}
parent::restoreStateAfterSave();
}
protected static int $temporaryVersionCheck = 80500;
/**
* Temporary handler for Php8.5 waiting for Dompdf release.
*
* @codeCoverageIgnore
*/
public function specialErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
{
if ($errno === E_DEPRECATED) {
if (preg_match('/canonical|imagedestroy/', $errstr) === 1) {
return true;
}
}
return false; // continue error handling
}
}
+18
View File
@@ -6,6 +6,9 @@ setlocale(LC_ALL, 'en_US.utf8');
function phpunit10ErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
{
if (strIncrement85(PHP_VERSION_ID, $errno, $errstr, $filename)) {
return true; // message suppressed - stop error handling
}
$x = error_reporting() & $errno;
if (
in_array(
@@ -31,6 +34,21 @@ function phpunit10ErrorHandler(int $errno, string $errstr, string $filename, int
return false; // continue error handling
}
function strIncrement85(int $version, int $errno, string $errstr, string $filename): bool
{
if ($version < 80500 || $errno !== E_DEPRECATED) {
return false;
}
if (preg_match('/Increment on non-numeric string/', $errstr) === 1) {
return true;
}
if (preg_match('/canonical/', $errstr) === 1 && preg_match('/mitoteam/', $filename) === 1) {
return true;
}
return false;
}
if (!method_exists(PHPUnit\Framework\TestCase::class, 'setOutputCallback')) {
set_error_handler('phpunit10ErrorHandler');
}