Skip to content

Commit fc091fc

Browse files
JanTvrdikdg
authored andcommitted
Fix PHP 8.5 deprecation: null as array offset in -o option handler
PHP 8.5 deprecated using null as an array offset. When running `-o console` without a filename, $file was null and used as array key in $outputFiles[$file], triggering E_DEPRECATED which the strict error handler converted to a fatal error. Changed the default from null to empty string '' and updated the corresponding null checks to check for empty string instead.
1 parent dc02e78 commit fc091fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Runner/CliTester.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ private function loadOptions(): CommandLine
136136
'--cider' => [],
137137
'--coverage-src' => [CommandLine::RealPath => true, CommandLine::Repeatable => true],
138138
'-o' => [CommandLine::Repeatable => true, CommandLine::Normalizer => function ($arg) use (&$outputFiles) {
139-
[$format, $file] = explode(':', $arg, 2) + [1 => null];
139+
[$format, $file] = explode(':', $arg, 2) + [1 => ''];
140140

141141
if (isset($outputFiles[$file])) {
142142
throw new \Exception(
143-
$file === null
143+
$file === ''
144144
? 'Option -o <format> without file name parameter can be used only once.'
145145
: "Cannot specify output by -o into file '$file' more then once.",
146146
);
147-
} elseif ($file === null) {
147+
} elseif ($file === '') {
148148
$this->stdoutFormat = $format;
149149
}
150150

0 commit comments

Comments
 (0)