Skip to content

Commit 2e574dd

Browse files
Do not (try to) create a directory when the target contains "://"
1 parent f156462 commit 2e574dd

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

ChangeLog-9.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
1111
### Fixed
1212

1313
* Static analysis cache keys do not include configuration settings that affect source code parsing
14+
* The Clover, Cobertura, Crap4j, and PHP report writers no longer create a `php:` directory when they should write to `php://stdout`, for instance
1415

1516
## [9.2.26] - 2023-03-06
1617

src/Report/Clover.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string
243243
$buffer = $xmlDocument->saveXML();
244244

245245
if ($target !== null) {
246-
Filesystem::createDirectory(dirname($target));
246+
if (!strpos($target, '://') !== false) {
247+
Filesystem::createDirectory(dirname($target));
248+
}
247249

248250
if (@file_put_contents($target, $buffer) === false) {
249251
throw new WriteOperationFailedException($target);

src/Report/Cobertura.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ public function process(CodeCoverage $coverage, ?string $target = null): string
294294
$buffer = $document->saveXML();
295295

296296
if ($target !== null) {
297-
Filesystem::createDirectory(dirname($target));
297+
if (!strpos($target, '://') !== false) {
298+
Filesystem::createDirectory(dirname($target));
299+
}
298300

299301
if (@file_put_contents($target, $buffer) === false) {
300302
throw new WriteOperationFailedException($target);

src/Report/Crap4j.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string
124124
$buffer = $document->saveXML();
125125

126126
if ($target !== null) {
127-
Filesystem::createDirectory(dirname($target));
127+
if (!strpos($target, '://') !== false) {
128+
Filesystem::createDirectory(dirname($target));
129+
}
128130

129131
if (@file_put_contents($target, $buffer) === false) {
130132
throw new WriteOperationFailedException($target);

src/Report/PHP.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public function process(CodeCoverage $coverage, ?string $target = null): string
2424
return \unserialize(<<<'END_OF_COVERAGE_SERIALIZATION'" . PHP_EOL . serialize($coverage) . PHP_EOL . 'END_OF_COVERAGE_SERIALIZATION' . PHP_EOL . ');';
2525

2626
if ($target !== null) {
27-
Filesystem::createDirectory(dirname($target));
27+
if (!strpos($target, '://') !== false) {
28+
Filesystem::createDirectory(dirname($target));
29+
}
2830

2931
if (@file_put_contents($target, $buffer) === false) {
3032
throw new WriteOperationFailedException($target);

0 commit comments

Comments
 (0)