Skip to content
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

Crash when Root Composer.json has no name #578

Open
Hanmac opened this issue Sep 19, 2023 · 1 comment
Open

Crash when Root Composer.json has no name #578

Hanmac opened this issue Sep 19, 2023 · 1 comment

Comments

@Hanmac
Copy link

Hanmac commented Sep 19, 2023

Describe the bug

Some Projects doesn't have a name themselves:

PHP Fatal error:  Uncaught Error: Typed property ComposerUnused\ComposerUnused\Composer\Config::$name must not be accessed before initialization in /var/www/vendor/icanhazstring/composer-unused/src/Composer/Config.php:26
Stack trace:
#0 /var/www/vendor/icanhazstring/composer-unused/src/Composer/PackageFactory.php(16): ComposerUnused\ComposerUnused\Composer\Config->getName()
#1 /var/www/vendor/icanhazstring/composer-unused/src/Console/Command/UnusedCommand.php(150): ComposerUnused\ComposerUnused\Composer\PackageFactory->fromConfig(Object(ComposerUnused\ComposerUnused\Composer\Config))
#2 /var/www/vendor/symfony/console/Command/Command.php(298): ComposerUnused\ComposerUnused\Console\Command\UnusedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/vendor/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(ComposerUnused\ComposerUnused\Console\Command\UnusedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/vendor/icanhazstring/composer-unused/bin/composer-unused(48): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#7 /var/www/vendor/icanhazstring/composer-unused/bin/composer-unused(49): {closure}(Array)
#8 /var/www/vendor/bin/composer-unused(119): include('/var/www/suppli...')
#9 {main}
  thrown in /var/www/vendor/icanhazstring/composer-unused/src/Composer/Config.php on line 26

while composer does this:

#composer why symfony/form
__root__                                 dev-master requires  symfony/form (5.4.*)

imo unused could also use this as default value

@icanhazstring
Copy link
Member

It was fixed recently with a better error message.

But you are right, we could silently fall back to root as a name. But then your configuration also has to reference that name to add additional files to it.

But I can think about that. Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants