Skip to content

Commit

Permalink
Restore using php:// and socket:// streams with --log-events-text and…
Browse files Browse the repository at this point in the history
… --log-events-verbose-text

This can/should be refactored to avoid code duplication and is missing tests.
  • Loading branch information
sebastianbergmann committed Jan 3, 2024
1 parent 2b221e0 commit 067790a
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions src/TextUI/Configuration/Cli/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use function is_numeric;
use function realpath;
use function sprintf;
use function str_starts_with;
use PHPUnit\Runner\TestSuiteSorter;
use SebastianBergmann\CliParser\Exception as CliParserException;
use SebastianBergmann\CliParser\Parser as CliParser;
Expand Down Expand Up @@ -804,29 +805,37 @@ public function fromParameters(array $parameters): Configuration
break;

case '--log-events-text':
$logEventsText = realpath($option[1]);

if (!$logEventsText) {
throw new Exception(
sprintf(
'The path "%s" specified for the --log-events-text option could not be resolved',
$option[1],
),
);
if (str_starts_with($option[1], 'php://') || str_starts_with($option[1], 'socket://')) {
$logEventsText = $option[1];
} else {
$logEventsText = realpath($option[1]);

if (!$logEventsText) {
throw new Exception(
sprintf(
'The path "%s" specified for the --log-events-text option could not be resolved',
$option[1],
),
);
}
}

break;

case '--log-events-verbose-text':
$logEventsVerboseText = realpath($option[1]);

if (!$logEventsVerboseText) {
throw new Exception(
sprintf(
'The path "%s" specified for the --log-events-verbose-text option could not be resolved',
$option[1],
),
);
if (str_starts_with($option[1], 'php://') || str_starts_with($option[1], 'socket://')) {
$logEventsVerboseText = $option[1];
} else {
$logEventsVerboseText = realpath($option[1]);

if (!$logEventsVerboseText) {
throw new Exception(
sprintf(
'The path "%s" specified for the --log-events-verbose-text option could not be resolved',
$option[1],
),
);
}
}

break;
Expand Down

0 comments on commit 067790a

Please sign in to comment.