Skip to content

Commit c5aa1c8

Browse files
authored
Merge branch 'master' into issue2912
2 parents 8d3a959 + 3c28bf4 commit c5aa1c8

File tree

6 files changed

+72
-35
lines changed

6 files changed

+72
-35
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,15 @@ jobs:
250250

251251
- name: Coverage
252252
run: |
253-
./vendor/bin/phpunit --coverage-clover coverage-clover.xml
254-
composer global require scrutinizer/ocular
255-
~/.composer/vendor/bin/ocular code-coverage:upload --format=php-clover coverage-clover.xml
253+
./vendor/bin/phpunit --coverage-clover build/clover.xml
254+
255+
- name: Upload coverage results to Coveralls
256+
env:
257+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
258+
run: |
259+
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
260+
chmod +x php-coveralls.phar
261+
php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv
256262
257263
release:
258264
permissions:

.scrutinizer.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/PhpSpreadsheet/Shared/StringHelper.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,4 +722,19 @@ public static function convertPostToString(string $index, string $default = ''):
722722

723723
return $default;
724724
}
725+
726+
/**
727+
* Php introduced str_increment with Php8.3,
728+
* but didn't issue deprecation notices till 8.5.
729+
*
730+
* @codeCoverageIgnore
731+
*/
732+
public static function stringIncrement(string &$str): void
733+
{
734+
if (function_exists('str_increment')) {
735+
$str = str_increment($str); // @phpstan-ignore-line
736+
} else {
737+
++$str; // @phpstan-ignore-line
738+
}
739+
}
725740
}

src/PhpSpreadsheet/Writer/Html.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ public function generateSheetData(): string
571571
}
572572
++$column;
573573
/** @var string $colStr */
574-
++$colStr;
574+
StringHelper::stringIncrement($colStr);
575575
}
576576
$html .= $this->generateRow($sheet, $rowData, $row - 1, $cellType);
577577
}
@@ -941,7 +941,7 @@ private function buildCssPerSheet(Worksheet $sheet, array &$css): void
941941
if ($this->shouldGenerateColumn($sheet, $colStr)) {
942942
$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = self::DEFAULT_CELL_WIDTH_POINTS . 'pt';
943943
}
944-
++$colStr;
944+
StringHelper::stringIncrement($colStr);
945945
}
946946

947947
// col elements, loop through columnDimensions and set width

src/PhpSpreadsheet/Writer/Pdf/Dompdf.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public function save($filename, int $flags = 0): void
4444
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
4545

4646
// Create PDF
47+
$restoreHandler = false;
48+
if (PHP_VERSION_ID >= self::$temporaryVersionCheck) {
49+
// @codeCoverageIgnoreStart
50+
set_error_handler(self::specialErrorHandler(...));
51+
$restoreHandler = true;
52+
// @codeCoverageIgnoreEnd
53+
}
4754
$pdf = $this->createExternalWriterInstance();
4855
$pdf->setPaper($paperSize, $orientation);
4956

@@ -53,6 +60,27 @@ public function save($filename, int $flags = 0): void
5360
// Write to file
5461
fwrite($fileHandle, $pdf->output() ?? '');
5562

63+
if ($restoreHandler) {
64+
restore_error_handler(); // @codeCoverageIgnore
65+
}
5666
parent::restoreStateAfterSave();
5767
}
68+
69+
protected static int $temporaryVersionCheck = 80500;
70+
71+
/**
72+
* Temporary handler for Php8.5 waiting for Dompdf release.
73+
*
74+
* @codeCoverageIgnore
75+
*/
76+
public function specialErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
77+
{
78+
if ($errno === E_DEPRECATED) {
79+
if (preg_match('/canonical|imagedestroy/', $errstr) === 1) {
80+
return true;
81+
}
82+
}
83+
84+
return false; // continue error handling
85+
}
5886
}

tests/bootstrap.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
function phpunit10ErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
88
{
9+
if (strIncrement85(PHP_VERSION_ID, $errno, $errstr, $filename)) {
10+
return true; // message suppressed - stop error handling
11+
}
912
$x = error_reporting() & $errno;
1013
if (
1114
in_array(
@@ -31,6 +34,21 @@ function phpunit10ErrorHandler(int $errno, string $errstr, string $filename, int
3134
return false; // continue error handling
3235
}
3336

37+
function strIncrement85(int $version, int $errno, string $errstr, string $filename): bool
38+
{
39+
if ($version < 80500 || $errno !== E_DEPRECATED) {
40+
return false;
41+
}
42+
if (preg_match('/Increment on non-numeric string/', $errstr) === 1) {
43+
return true;
44+
}
45+
if (preg_match('/canonical/', $errstr) === 1 && preg_match('/mitoteam/', $filename) === 1) {
46+
return true;
47+
}
48+
49+
return false;
50+
}
51+
3452
if (!method_exists(PHPUnit\Framework\TestCase::class, 'setOutputCallback')) {
3553
set_error_handler('phpunit10ErrorHandler');
3654
}

0 commit comments

Comments
 (0)