-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for providing command/hook information via php8 Attribute…
…s. (#4821) * Support command authoring with PHP Attributes in addition to annotations. * Revert composer changes and instead prepare php8 tests a bit more. * Update linter spec * Improve docs * Convert a method to use AC and DR namespace aliases. * Two lines for two use statements per psr2. sigh. * woops - dont change composer files. * Use class constant * Factor Bootstrap levels into a value class for completion in Bootstrap Attribute * Add Kernel Attribute with ExpectedValues * Various fixes * revert composer.* and PHPCS * No AttributeInterface and use NoArgumentsBase * Param -> Argument * Test Union type and #[DefaultFields] * Move NoArgumentsBase into Drush * Remove unneeded PHP8 CI alias * Add docs for xkcd attributes implementation
- Loading branch information
Showing
39 changed files
with
664 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ | |
<rule ref="PSR2"/> | ||
|
||
<arg name="warning-severity" value="0"/> | ||
<arg value="s" /> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] | ||
class Argument extends \Consolidation\AnnotatedCommand\Attributes\Argument | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
use Consolidation\AnnotatedCommand\Parser\CommandInfo; | ||
use Drush\Boot\DrupalBoot; | ||
use Drush\Boot\DrupalBootLevels; | ||
use JetBrains\PhpStorm\ExpectedValues; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class Bootstrap | ||
{ | ||
/** | ||
* @param $level | ||
* The level to bootstrap to. | ||
*/ | ||
public function __construct( | ||
#[ExpectedValues(valuesFromClass: DrupalBootLevels::class)] public string $level, | ||
) { | ||
} | ||
|
||
public static function handle(\ReflectionAttribute $attribute, CommandInfo $commandInfo) | ||
{ | ||
$args = $attribute->getArguments(); | ||
$commandInfo->addAnnotation('bootstrap', $args['level']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class Command extends \Consolidation\AnnotatedCommand\Attributes\Command | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class DefaultFields extends \Consolidation\AnnotatedCommand\Attributes\DefaultFields | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class DefaultTableFields extends \Consolidation\AnnotatedCommand\Attributes\DefaultTableFields | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class FieldLabels extends \Consolidation\AnnotatedCommand\Attributes\FieldLabels | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class FilterDefaultField extends \Consolidation\AnnotatedCommand\Attributes\FilterDefaultField | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class Help extends \Consolidation\AnnotatedCommand\Attributes\Help | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class Hook extends \Consolidation\AnnotatedCommand\Attributes\Hook | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
use Consolidation\AnnotatedCommand\Parser\CommandInfo; | ||
use Drush\Boot\DrupalBoot; | ||
use Drush\Boot\DrupalBootLevels; | ||
use Drush\Boot\Kernels; | ||
use JetBrains\PhpStorm\ExpectedValues; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class Kernel | ||
{ | ||
/** | ||
* @param $kernel | ||
* The kernel name. | ||
*/ | ||
public function __construct( | ||
#[ExpectedValues(valuesFromClass: Kernels::class)] public string $kernel, | ||
) { | ||
} | ||
|
||
public static function handle(\ReflectionAttribute $attribute, CommandInfo $commandInfo) | ||
{ | ||
$args = $attribute->getArguments(); | ||
$commandInfo->addAnnotation('kernel', $args['kernel']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
class Misc extends \Consolidation\AnnotatedCommand\Attributes\Misc | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Consolidation\AnnotatedCommand\Attributes\AttributeInterface; | ||
use Consolidation\AnnotatedCommand\Parser\CommandInfo; | ||
|
||
abstract class NoArgumentsBase | ||
{ | ||
protected const NAME = 'annotation-name'; | ||
|
||
public static function handle(\ReflectionAttribute $attribute, CommandInfo $commandInfo) | ||
{ | ||
$commandInfo->addAnnotation(static::NAME, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drush\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] | ||
class Option extends \Consolidation\AnnotatedCommand\Attributes\Option | ||
{ | ||
} |
Oops, something went wrong.