-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
Workaround for constructor signature change in Symfony/Process #2766
Conversation
try { | ||
$process = new Process($command); | ||
} catch (\TypeError $e) { | ||
$process = new Process([$command]); | ||
} |
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.
Safer would be:
try { | |
$process = new Process($command); | |
} catch (\TypeError $e) { | |
$process = new Process([$command]); | |
} | |
$process = Process::fromShellCommandline($command); |
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.
I will try that out.. If that works, that'll be a lot less fugly!
Thanks for the suggestion, @stloyd!
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.
Alas, it doesn't seem to work in the context of composer create-project
, because it seems that method isn't present yet in symfony/process
2.8.x, as used by Composer.
It breaks with this error:
…
…
120 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
> Bolt\ComposerScripts\ProjectEventHandler::postUpdate
! [NOTE] Running composer "post-update-cmd" scripts
PHP Fatal error: Uncaught Error: Call to undefined method Symfony\Component\Process\Process::fromShellCommandline() in /Users/bob/Sites/Bolt/playground/vendor/bolt/core/bin/composer-script/Script.php:39
Stack trace:
#0 /Users/bob/Sites/Bolt/playground/vendor/bolt/core/bin/composer-script/PostUpdateScript.php(13): Bolt\ComposerScripts\Script::run('php vendor/bobd...')
#1 /Users/bob/Sites/Bolt/playground/vendor/bolt/core/bin/composer-script/ProjectEventHandler.php(44): Bolt\ComposerScripts\PostUpdateScript::execute()
#2 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(377): Bolt\ComposerScripts\ProjectEventHandler::postUpdate(Object(Composer\Script\Event))
#3 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(236): Composer\EventDispatcher\EventDispatcher->executeEventPhpScript('Bolt\\ComposerSc...', 'postUpdate', Object(Composer\Script\Event))
#4 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(117): Composer\EventDispatcher\EventDispatc in /Users/bob/Sites/Bolt/playground/vendor/bolt/core/bin/composer-script/Script.php on line 39
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.
👍
The important part of this PR is:
This was fun to figure out! (not)