Skip to content

Commit

Permalink
[minor] deprecate ConfigureWithDocblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Jul 12, 2022
1 parent edc10ea commit 04f4309
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ class CreateUserCommand extends Command

### `ConfigureWithDocblocks`

> **Note**
> This trait is deprecated when using with PHP 8+ and will be removed in 2.0.
> Use [`ConfigureWithAttributes`](#configurewithattributes) instead.
Use this trait to allow your command to be configured by your command class' docblock.
`phpdocumentor/reflection-docblock` is required for this feature
(`composer install phpdocumentor/reflection-docblock`).
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"require": {
"php": ">=7.4",
"symfony/console": "^4.4|^5.0|^6.0",
"symfony/deprecation-contracts": "^2.2|^3.0",
"symfony/polyfill-php80": "^1.15",
"symfony/string": "^5.0|^6.0",
"zenstruck/callback": "^1.4.2"
Expand Down
6 changes: 6 additions & 0 deletions src/Configuration/DocblockConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Zenstruck\Console\ConfigureWithAttributes;
use Zenstruck\Console\ConfigureWithDocblocks;

use function Symfony\Component\String\u;

Expand Down Expand Up @@ -38,6 +40,10 @@ private function __construct(string $class)
{
$this->class = new \ReflectionClass($class);
$this->docblock = self::factory()->create($this->class->getDocComment() ?: ' '); // hack to allow empty docblock

if (\PHP_VERSION_ID >= 80000) {
trigger_deprecation('zenstruck/console-extra', '1.1', 'The %s trait is deprecated and will be removed in 2.0. Use %s instead.', ConfigureWithDocblocks::class, ConfigureWithAttributes::class);
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/ConfigureWithDocblocksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* @author Kevin Bond <kevinbond@gmail.com>
*
* @group legacy
*/
final class ConfigureWithDocblocksTest extends TestCase
{
Expand Down

0 comments on commit 04f4309

Please sign in to comment.