Skip to content

Commit d6c231c

Browse files
committed
Replace $this->filesystem->readFile by file_get_contents on DocsCommand to avoid composer compatibility issues
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
1 parent 2a97d81 commit d6c231c

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

src/Command/DocsCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\Filesystem\Path;
2525
use Symfony\Component\Process\Process;
2626

27+
use function Safe\file_get_contents;
2728
use function array_map;
2829
use function implode;
2930
use function ltrim;
@@ -131,7 +132,7 @@ private function createPhpDocumentorConfig(string $source, string $target, strin
131132
$guidePath = Path::makeRelative($source, $workingDirectory);
132133

133134
$defaultPackageName = array_key_first($psr4Namespaces) ?: '';
134-
$templateContents = $this->filesystem->readFile($templateFile);
135+
$templateContents = file_get_contents($templateFile);
135136

136137
$this->filesystem->dumpFile($configFile, strtr($templateContents, [
137138
'%%TITLE%%' => $this->getProjectDescription(),

tests/Command/DocsCommandTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ public function executeWillGeneratePhpDocumentorConfigAndRunProcess(): void
8383
{
8484
$this->filesystem->exists(Argument::any())->willReturn(true);
8585
// O template agora é resolvido via getConfigFile, então precisamos garantir que o mock aceite o caminho relativo
86-
$this->filesystem->readFile(Argument::that(
87-
// Aceita tanto caminho absoluto quanto relativo, pois getConfigFile pode resolver ambos
88-
fn($file): bool => str_contains((string) $file, 'resources/phpdocumentor.xml')
89-
))->willReturn('template_content');
9086
$this->filesystem->dumpFile(Argument::cetera())->shouldBeCalled();
9187

9288
$this->willRunProcessWithCallback(function (Process $process): bool {
@@ -106,7 +102,6 @@ public function executeWillGeneratePhpDocumentorConfigAndRunProcess(): void
106102
public function executeWillReturnFailureIfProcessFails(): void
107103
{
108104
$this->filesystem->exists(Argument::any())->willReturn(true);
109-
$this->filesystem->readFile(Argument::cetera())->willReturn('template_content');
110105
$this->filesystem->dumpFile(Argument::cetera())->shouldBeCalled();
111106

112107
$this->willRunProcessWithCallback(static fn(): bool => true, false);
@@ -123,7 +118,6 @@ public function executeWillCreateConfigDirectoryIfItDoesNotExist(): void
123118
$this->filesystem->exists(Argument::any())->willReturn(true);
124119
$this->filesystem->exists(getcwd() . '/tmp/cache/phpdoc')->willReturn(false);
125120

126-
$this->filesystem->readFile(Argument::cetera())->willReturn('template_content');
127121
$this->filesystem->mkdir(Argument::any())->shouldBeCalled();
128122
$this->filesystem->dumpFile(Argument::cetera())->shouldBeCalled();
129123

0 commit comments

Comments
 (0)