-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
[make:command] lets use attributes if possible #822
Changes from all commits
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 |
---|---|---|
|
@@ -2,18 +2,29 @@ | |
|
||
namespace <?= $namespace; ?>; | ||
|
||
<?php if ($use_attributes && $use_command_attribute): ?> | ||
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. Do we need to check both? 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. I think we could drop Thinking we drop 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. Ah, you're right about the |
||
use Symfony\Component\Console\Attribute\AsCommand; | ||
<?php endif; ?> | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
<?php if ($use_attributes && $use_command_attribute): ?> | ||
#[AsCommand( | ||
name: '<?= $command_name; ?>', | ||
description: 'Add a short description for your command', | ||
)] | ||
<?php endif; ?> | ||
class <?= $class_name; ?> extends Command | ||
{ | ||
<?php if (!$use_attributes || !$use_command_attribute): ?> | ||
protected static $defaultName = '<?= $command_name; ?>'; | ||
protected static $defaultDescription = 'Add a short description for your command'; | ||
|
||
<?php endif; ?> | ||
protected function configure() | ||
{ | ||
$this | ||
|
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.
Under a different PR, I think we can add a helper to the
PhpCompatUtil
to eliminate having to check the PHP version before callingclass_exists()
. But the complexity required to make that happen is beyond the scope of this PR.https://bugs.php.net/bug.php?id=80938 explains why this must be done like this.