Skip to content

Commit c3a3776

Browse files
committed
fix - errors displayed when running with php 8.5
1 parent 03e510d commit c3a3776

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

fmt.stub.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0\n");
66
exit(255);
77
}
8+
9+
// When fmt.stub.php is executed as a CLI script, any runtime warnings/deprecations
10+
// would corrupt the formatter output (and break tests that compare stdout).
11+
// Keep the library behavior unchanged when this file is included by other PHP code.
12+
if (
13+
PHP_SAPI === 'cli' &&
14+
isset($_SERVER['SCRIPT_FILENAME']) &&
15+
@realpath($_SERVER['SCRIPT_FILENAME']) === @realpath(__FILE__)
16+
) {
17+
@ini_set('display_errors', '0');
18+
@ini_set('display_startup_errors', '0');
19+
}
820
}
921

1022
namespace Symfony\Component\Console\Formatter {
@@ -1623,15 +1635,15 @@ abstract public function candidate($source, $foundTokens);
16231635

16241636
abstract public function format($source);
16251637

1626-
protected function each(array &$ar) {
1627-
$k = key($ar);
1628-
if ($k === null) {
1629-
return false;
1630-
}
1631-
$v = current($ar);
1632-
next($ar);
1633-
return [$k, $v];
1634-
}
1638+
protected function each(array &$ar) {
1639+
$k = key($ar);
1640+
if ($k === null) {
1641+
return false;
1642+
}
1643+
$v = current($ar);
1644+
next($ar);
1645+
return [$k, $v];
1646+
}
16351647

16361648
protected function alignPlaceholders($origPlaceholder, $contextCounter) {
16371649
for ($j = 0; $j <= $contextCounter; ++$j) {
@@ -8493,7 +8505,7 @@ public function format($source) {
84938505
$quote_stack = !$quote_stack;
84948506
break;
84958507

8496-
case T_STRING;
8508+
case T_STRING:
84978509
case T_LNUMBER:
84988510
case T_DNUMBER:
84998511
case T_CONSTANT_ENCAPSED_STRING:

0 commit comments

Comments
 (0)