Skip to content

Commit 33e84cb

Browse files
committed
update_to_5.0.md: increasing stricness; optimization example
1 parent 873508f commit 33e84cb

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

docs/update_and_migration/from_4.6/update_to_5.0.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -415,16 +415,6 @@ use Rector\Symfony\Set\SensiolabsSetList;
415415
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
416416
SensiolabsSetList::ANNOTATIONS_TO_ATTRIBUTES,
417417
]
418-
);
419-
```
420-
421-
But you can also go faster with bigger [rule sets in the modern way](https://getrector.com/documentation/set-lists) like in the following example:
422-
423-
```php
424-
->withSets(
425-
[
426-
IbexaSetList::IBEXA_50->value // rule set for upgrading to Ibexa DXP 5.0
427-
]
428418
)
429419
->withPhpSets()
430420
->withComposerBased(twig: true, symfony: true)
@@ -445,6 +435,36 @@ But you can also go faster with bigger [rule sets in the modern way](https://get
445435
);
446436
```
447437

438+
TODO: Among other things, the type hinting strictness has been increased.
439+
440+
TODO: `AsCommand` attribute; Rector doesn't move `parent::__construct('app:test');` into `AsCommand`?
441+
442+
In the following example, you can see optimization thanks to the following features:
443+
444+
- [Constructor parameter promoted as properties](https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion) (available since PHP 8.0)
445+
- [`AsCommand` attribute to register a command](https://symfony.com/doc/7.2/console.html#console_registering-the-command) (available since Symfony 6.2)
446+
447+
```diff
448+
+#[AsCommand(name: 'app:test', description: 'Command to test something.')]
449+
class TestCommand extends Command
450+
{
451+
- private Repository $repository;
452+
-
453+
- public function __construct(Repository $repository)
454+
+ public function __construct(private readonly Repository $repository)
455+
{
456+
- $this->repository = $repository;
457+
- parent::__construct('app:test');
458+
}
459+
-
460+
- protected function configure()
461+
- {
462+
- $this->setDescription('Command to test something.');
463+
- }
464+
465+
protected function execute(InputInterface $input, OutputInterface $output): int
466+
```
467+
448468
#### Update field type identifiers
449469

450470
Several field type identifiers have changed.

0 commit comments

Comments
 (0)