-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Improve stream wrapper support #12396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2ab3d1e
708c809
e8a516f
198a7ea
9f03eba
ed968c0
27fac4b
d1081a3
4b5129b
21b7a7e
a23e7ce
40eb099
0cd95aa
598e88e
413dd88
d859488
7542d71
faeac42
aa70941
1430918
1baf8bd
2c9ed1f
d32e015
463cebe
32e6c08
d359604
6592d1d
95353bc
ea4e18b
59bdaec
dc204f7
6dd3cf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
use Composer\Semver\Semver; | ||
use Composer\Spdx\SpdxLicenses; | ||
use Composer\Util\PackageInfo; | ||
use Composer\Util\Platform; | ||
use DateTimeInterface; | ||
use Symfony\Component\Console\Completion\CompletionInput; | ||
use Symfony\Component\Console\Formatter\OutputFormatter; | ||
|
@@ -359,7 +360,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
$io->write($package->getName(), false); | ||
$path = $composer->getInstallationManager()->getInstallPath($package); | ||
if (is_string($path)) { | ||
$io->write(' ' . strtok(realpath($path), "\r\n")); | ||
$io->write(' ' . strtok(Platform::realpath($path), "\r\n")); | ||
} else { | ||
$io->write(' null'); | ||
} | ||
|
@@ -581,7 +582,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
if ($writePath) { | ||
$path = $composer->getInstallationManager()->getInstallPath($package); | ||
if (is_string($path)) { | ||
$packageViewData['path'] = strtok(realpath($path), "\r\n"); | ||
$packageViewData['path'] = strtok(Platform::realpath($path), "\r\n"); | ||
} else { | ||
$packageViewData['path'] = null; | ||
} | ||
|
@@ -903,7 +904,11 @@ protected function printMeta(CompletePackageInterface $package, array $versions, | |
if ($isInstalledPackage) { | ||
$path = $this->requireComposer()->getInstallationManager()->getInstallPath($package); | ||
if (is_string($path)) { | ||
$io->write('<info>path</info> : ' . realpath($path)); | ||
try { | ||
$io->write('<info>path</info> : ' . Platform::realpath($path)); | ||
} catch (\RuntimeException $exception) { | ||
$ 117E io->write('<info>path</info> : '); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This preserves current behaviour but isn't great IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I'd say that is probably ok to expect the realpath to work here and remove the catch. |
||
} | ||
} else { | ||
$io->write('<info>path</info> : null'); | ||
} | ||
|
@@ -1063,13 +1068,12 @@ protected function printPackageInfoAsJson(CompletePackageInterface $package, arr | |
|
||
if (!PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package)) { | ||
$path = $this->requireComposer()->getInstallationManager()->getInstallPath($package); | ||
$json['path'] = null; | ||
if (is_string($path)) { | ||
$path = realpath($path); | ||
if ($path !== false) { | ||
$json['path'] = $path; | ||
try { | ||
$json['path'] = Platform::realpath($path); | ||
} catch (\RuntimeException $exception) { | ||
} | ||
} else { | ||
$json['path'] = null; | ||
} | ||
|
||
if ($package->getReleaseDate() !== null) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,7 +199,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int | |
&& $input->hasParameterOption('-h', true) === false | ||
) { | ||
$dir = dirname(Platform::getCwd(true)); | ||
$home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/'); | ||
$home = Platform::realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one too I'd probably try/catch and use |
||
|
||
// abort when we reach the home dir or top of the filesystem | ||
while (dirname($dir) !== $dir && $dir !== $home) { | ||
|
@@ -288,7 +288,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int | |
} catch (ParsingException $e) { | ||
$details = $e->getDetails(); | ||
|
||
$file = realpath(Factory::getComposerFile()); | ||
$file = Platform::realpath(Factory::getComposerFile()); | ||
|
||
$line = null; | ||
if ($details && isset($details['line'])) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file_exists()
was just called (previous line) so we can assume that$dir
is a valid path, and omit the try/catch