Skip to content

Commit

Permalink
Do not (try to) create a directory when the target contains "://"
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 26, 2023
1 parent f156462 commit 2e574dd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChangeLog-9.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
### Fixed

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

## [9.2.26] - 2023-03-06

Expand Down
4 changes: 3 additions & 1 deletion src/Report/Clover.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string
$buffer = $xmlDocument->saveXML();

if ($target !== null) {
Filesystem::createDirectory(dirname($target));
if (!strpos($target, '://') !== false) {
Filesystem::createDirectory(dirname($target));
}

if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);
Expand Down
4 changes: 3 additions & 1 deletion src/Report/Cobertura.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ public function process(CodeCoverage $coverage, ?string $target = null): string
$buffer = $document->saveXML();

if ($target !== null) {
Filesystem::createDirectory(dirname($target));
if (!strpos($target, '://') !== false) {
Filesystem::createDirectory(dirname($target));
}

if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);
Expand Down
4 changes: 3 additions & 1 deletion src/Report/Crap4j.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string
$buffer = $document->saveXML();

if ($target !== null) {
Filesystem::createDirectory(dirname($target));
if (!strpos($target, '://') !== false) {
Filesystem::createDirectory(dirname($target));
}

if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);
Expand Down
4 changes: 3 additions & 1 deletion src/Report/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public function process(CodeCoverage $coverage, ?string $target = null): string
return \unserialize(<<<'END_OF_COVERAGE_SERIALIZATION'" . PHP_EOL . serialize($coverage) . PHP_EOL . 'END_OF_COVERAGE_SERIALIZATION' . PHP_EOL . ');';

if ($target !== null) {
Filesystem::createDirectory(dirname($target));
if (!strpos($target, '://') !== false) {
Filesystem::createDirectory(dirname($target));
}

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

0 comments on commit 2e574dd

Please sign in to comment.