Skip to content

Commit 5dd6771

Browse files
authored
Merge pull request #30 from kbond/deprecate-docblocks
Deprecate `ConfigureWithDocblocks` on PHP 8
2 parents dedbab2 + 04f4309 commit 5dd6771

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ class CreateUserCommand extends Command
267267

268268
### `ConfigureWithDocblocks`
269269

270+
> **Note**
271+
> This trait is deprecated when using with PHP 8+ and will be removed in 2.0.
272+
> Use [`ConfigureWithAttributes`](#configurewithattributes) instead.
273+
270274
Use this trait to allow your command to be configured by your command class' docblock.
271275
`phpdocumentor/reflection-docblock` is required for this feature
272276
(`composer install phpdocumentor/reflection-docblock`).

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"require": {
1515
"php": ">=7.4",
1616
"symfony/console": "^4.4|^5.0|^6.0",
17+
"symfony/deprecation-contracts": "^2.2|^3.0",
1718
"symfony/polyfill-php80": "^1.15",
1819
"symfony/string": "^5.0|^6.0",
1920
"zenstruck/callback": "^1.4.2"

src/Configuration/DocblockConfiguration.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Symfony\Component\Console\Command\Command;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputOption;
10+
use Zenstruck\Console\ConfigureWithAttributes;
11+
use Zenstruck\Console\ConfigureWithDocblocks;
1012

1113
use function Symfony\Component\String\u;
1214

@@ -38,6 +40,10 @@ private function __construct(string $class)
3840
{
3941
$this->class = new \ReflectionClass($class);
4042
$this->docblock = self::factory()->create($this->class->getDocComment() ?: ' '); // hack to allow empty docblock
43+
44+
if (\PHP_VERSION_ID >= 80000) {
45+
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);
46+
}
4147
}
4248

4349
/**

tests/Unit/AttributesConfigureTest.php renamed to tests/Unit/ConfigureWithAttributesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @requires PHP 8
1919
*/
20-
final class AttributesConfigureTest extends TestCase
20+
final class ConfigureWithAttributesTest extends TestCase
2121
{
2222
/**
2323
* @test
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
/**
1111
* @author Kevin Bond <kevinbond@gmail.com>
12+
*
13+
* @group legacy
1214
*/
13-
final class DocblockConfigureTest extends TestCase
15+
final class ConfigureWithDocblocksTest extends TestCase
1416
{
1517
/**
1618
* @test

0 commit comments

Comments
 (0)