Skip to content

Commit f24fa3a

Browse files
committed
Update errors to use writeError
1 parent 088acd7 commit f24fa3a

17 files changed

+37
-37
lines changed

src/Command/BuildCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public function execute(InputInterface $input, OutputInterface $output): int
9292
$this->container,
9393
);
9494
} catch (BundledPhpExtensionRefusal $bundledPhpExtensionRefusal) {
95-
$this->io->write('');
96-
$this->io->write('<comment>' . $bundledPhpExtensionRefusal->getMessage() . '</comment>');
95+
$this->io->writeError('');
96+
$this->io->writeError('<comment>' . $bundledPhpExtensionRefusal->getMessage() . '</comment>');
9797

9898
return self::INVALID;
9999
}
@@ -128,7 +128,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
128128
false,
129129
);
130130
} catch (ComposerRunFailed $composerRunFailed) {
131-
$this->io->write('<error>' . $composerRunFailed->getMessage() . '</error>');
131+
$this->io->writeError('<error>' . $composerRunFailed->getMessage() . '</error>');
132132

133133
return $composerRunFailed->getCode();
134134
}

src/Command/CommandHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,9 @@ public static function handlePackageNotFound(
365365
$requestedPackageName = substr($requestedPackageName, 4);
366366
}
367367

368-
$io->write('');
369-
$io->write(sprintf('<error>Could not install package: %s</error>', $requestedPackageName));
370-
$io->write($exception->getMessage());
368+
$io->writeError('');
369+
$io->writeError(sprintf('<error>Could not install package: %s</error>', $requestedPackageName));
370+
$io->writeError($exception->getMessage());
371371

372372
try {
373373
$matches = array_map(
@@ -382,7 +382,7 @@ static function (array $match) use ($io, $pieComposer): array {
382382
->extensionName()
383383
->name();
384384
} catch (Throwable $t) {
385-
$io->write(
385+
$io->writeError(
386386
sprintf(
387387
'Tried looking up extension name for %s, but failed: %s',
388388
$match['name'],
@@ -421,7 +421,7 @@ static function (array $match) use ($io): void {
421421
);
422422
}
423423
} catch (OutOfRangeException) {
424-
$io->write(
424+
$io->writeError(
425425
sprintf(
426426
'Tried searching for "%s", but nothing was found.',
427427
$requestedPackageName,

src/Command/DownloadCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ public function execute(InputInterface $input, OutputInterface $output): int
9494
$this->container,
9595
);
9696
} catch (BundledPhpExtensionRefusal $bundledPhpExtensionRefusal) {
97-
$this->io->write('');
98-
$this->io->write('<comment>' . $bundledPhpExtensionRefusal->getMessage() . '</comment>');
97+
$this->io->writeError('');
98+
$this->io->writeError('<comment>' . $bundledPhpExtensionRefusal->getMessage() . '</comment>');
9999

100100
return self::INVALID;
101101
}
@@ -112,7 +112,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
112112
false,
113113
);
114114
} catch (ComposerRunFailed $composerRunFailed) {
115-
$this->io->write('<error>' . $composerRunFailed->getMessage() . '</error>');
115+
$this->io->writeError('<error>' . $composerRunFailed->getMessage() . '</error>');
116116

117117
return $composerRunFailed->getCode();
118118
}

src/Command/InfoCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public function execute(InputInterface $input, OutputInterface $output): int
9898
$this->container,
9999
);
100100
} catch (BundledPhpExtensionRefusal $bundledPhpExtensionRefusal) {
101-
$this->io->write('');
102-
$this->io->write('<comment>' . $bundledPhpExtensionRefusal->getMessage() . '</comment>');
101+
$this->io->writeError('');
102+
$this->io->writeError('<comment>' . $bundledPhpExtensionRefusal->getMessage() . '</comment>');
103103

104104
return self::INVALID;
105105
}

src/Command/InstallCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ public function execute(InputInterface $input, OutputInterface $output): int
106106
$this->container,
107107
);
108108
} catch (BundledPhpExtensionRefusal $bundledPhpExtensionRefusal) {
109-
$this->io->write('');
110-
$this->io->write('<comment>' . $bundledPhpExtensionRefusal->getMessage() . '</comment>');
109+
$this->io->writeError('');
110+
$this->io->writeError('<comment>' . $bundledPhpExtensionRefusal->getMessage() . '</comment>');
111111

112112
return self::INVALID;
113113
}
@@ -142,7 +142,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
142142
true,
143143
);
144144
} catch (ComposerRunFailed $composerRunFailed) {
145-
$this->io->write('<error>' . $composerRunFailed->getMessage() . '</error>');
145+
$this->io->writeError('<error>' . $composerRunFailed->getMessage() . '</error>');
146146

147147
return $composerRunFailed->getCode();
148148
}

src/Command/InstallExtensionsForProjectCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
101101
if (ExtensionType::isValid($rootPackage->getType())) {
102102
$cwd = realpath(getcwd());
103103
if (! is_string($cwd) || $cwd === '') {
104-
$this->io->write('<error>Failed to determine current working directory.</error>');
104+
$this->io->writeError('<error>Failed to determine current working directory.</error>');
105105

106106
$restoreWorkingDir();
107107

@@ -124,7 +124,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
124124

125125
$allowNonInteractive = $input->hasOption(CommandHelper::OPTION_ALLOW_NON_INTERACTIVE_PROJECT_INSTALL) && $input->getOption(CommandHelper::OPTION_ALLOW_NON_INTERACTIVE_PROJECT_INSTALL);
126126
if (! Platform::isInteractive() && ! $allowNonInteractive) {
127-
$this->io->write(sprintf(
127+
$this->io->writeError(sprintf(
128128
'<warning>Aborting! You are not running in interactive mode, and --%s was not specified.</warning>',
129129
CommandHelper::OPTION_ALLOW_NON_INTERACTIVE_PROJECT_INSTALL,
130130
));
@@ -226,7 +226,7 @@ function (Link $link) use ($pieComposer, $phpEnabledExtensions, $installedPiePac
226226
$anyErrorsHappened = true;
227227

228228
// @todo Figure out if there is a way to improve this, safely
229-
$this->io->write(sprintf(
229+
$this->io->writeError(sprintf(
230230
"<warning>Multiple packages were found for %s:</warning>\n %s\n\n<warning>This means you cannot `pie install` this project interactively for now.</warning>",
231231
$extension->nameWithExtPrefix(),
232232
implode("\n ", array_column($matches, 'name')),

src/Command/SelfUpdateCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function configure(): void
8484
public function execute(InputInterface $input, OutputInterface $output): int
8585
{
8686
if (! PieVersion::isPharBuild()) {
87-
$this->io->write('<comment>Aborting! You are not running a PHAR, cannot self-update.</comment>');
87+
$this->io->writeError('<comment>Aborting! You are not running a PHAR, cannot self-update.</comment>');
8888

8989
return Command::FAILURE;
9090
}
@@ -131,7 +131,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
131131
try {
132132
$latestRelease = $fetchLatestPieRelease->latestReleaseMetadata($updateChannel);
133133
} catch (Throwable $throwable) {
134-
$this->io->write(sprintf('<error>%s</error>', $throwable->getMessage()));
134+
$this->io->writeError(sprintf('<error>%s</error>', $throwable->getMessage()));
135135

136136
return Command::FAILURE;
137137
}
@@ -165,13 +165,13 @@ public function execute(InputInterface $input, OutputInterface $output): int
165165
try {
166166
$verifyPiePhar->verify($latestRelease, $pharFilename, $this->io);
167167
} catch (FailedToVerifyRelease $failedToVerifyRelease) {
168-
$this->io->write(sprintf(
168+
$this->io->writeError(sprintf(
169169
'<error>❌ Failed to verify the pie.phar release %s: %s</error>',
170170
$latestRelease->tag,
171171
$failedToVerifyRelease->getMessage(),
172172
));
173173

174-
$this->io->write('This means I could not verify that the PHAR we tried to update to was authentic, so I am aborting the self-update.');
174+
$this->io->writeError('This means I could not verify that the PHAR we tried to update to was authentic, so I am aborting the self-update.');
175175
unlink($pharFilename->filePath);
176176

177177
return Command::FAILURE;

src/Command/SelfVerifyCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function configure(): void
4242
public function execute(InputInterface $input, OutputInterface $output): int
4343
{
4444
if (! PieVersion::isPharBuild()) {
45-
$this->io->write('<comment>Aborting! You are not running a PHAR, cannot self-verify.</comment>');
45+
$this->io->writeError('<comment>Aborting! You are not running a PHAR, cannot self-verify.</comment>');
4646

4747
return Command::FAILURE;
4848
}
@@ -54,7 +54,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
5454
try {
5555
$verifyPiePhar->verify($latestRelease, $pharFilename, $this->io);
5656
} catch (FailedToVerifyRelease $failedToVerifyRelease) {
57-
$this->io->write(sprintf(
57+
$this->io->writeError(sprintf(
5858
'<error>❌ Failed to verify the pie.phar release %s: %s</error>',
5959
$latestRelease->tag,
6060
$failedToVerifyRelease->getMessage(),

src/Command/UninstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
7676
$piePackage = $this->findPiePackageByPackageName($packageToRemove, $composer);
7777

7878
if ($piePackage === null) {
79-
$this->io->write('<error>No package found: ' . $packageToRemove . '</error>');
79+
$this->io->writeError('<error>No package found: ' . $packageToRemove . '</error>');
8080

8181
return 1;
8282
}

src/ComposerIntegration/Listeners/RemoveUnrelatedInstallOperations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __invoke(InstallerEvent $installerEvent): void
4747
$installerEvent->getTransaction()?->getOperations() ?? [],
4848
function (OperationInterface $operation) use ($pieOutput): bool {
4949
if (! $operation instanceof InstallOperation && ! $operation instanceof UninstallOperation) {
50-
$pieOutput->write(
50+
$pieOutput->writeError(
5151
sprintf(
5252
'Unexpected operation during installer: %s',
5353
$operation::class,
@@ -61,7 +61,7 @@ function (OperationInterface $operation) use ($pieOutput): bool {
6161
$isRequestedPiePackage = $this->composerRequest->requestedPackage->package === $operation->getPackage()->getName();
6262

6363
if (! $isRequestedPiePackage) {
64-
$pieOutput->write(
64+
$pieOutput->writeError(
6565
sprintf(
6666
'Filtering package %s from install operations, as it was not the requested package',
6767
$operation->getPackage()->getName(),

0 commit comments

Comments
 (0)