Skip to content

Commit 25dba2e

Browse files
jaroslavlibalmikehaertl
authored andcommitted
Fix deprecated string increment on non-numeric string in nextHandle() (PHP 8.3+)
On PHP 8.3+ the $char++ operation in nextHandle() triggers "Increment on non-numeric string is deprecated, use str_increment() instead". This breaks projects that escalate deprecations to exceptions when adding files without explicit handles (e.g. new Pdf([$a, $b])). Use str_increment() on PHP 8.3+ and fall back to $char++ on older versions, which the library still supports (php >= 8.1). The handle sequence (A, B, ..., Z, AA, ...) is unchanged.
1 parent f934183 commit 25dba2e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/Pdf.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,11 @@ protected function nextHandle(): string
758758
$i = $this->_handle++;
759759
$char = 'A';
760760
while ($i-- > 0) {
761-
$char++;
761+
if (function_exists('str_increment')) {
762+
$char = str_increment($char);
763+
} else {
764+
$char++;
765+
}
762766
}
763767

764768
return $char;

0 commit comments

Comments
 (0)