storyblok / storyblok-php-client

Storyblok - PHP Client
https://www.storyblok.com
MIT License
33 stars 37 forks source link

Proof of Concept for introducing Rector #84

Closed roberto-butti closed 1 year ago

roberto-butti commented 1 year ago

In order to improve the quality of the php-client we introduce in the past:

Today I want to introduce another powerful tool that helps in the refactoring process and helps the developer that wants to create a Pull Request to have a first-level Automated Code Review (checking dead code, using the functionalities provided by the supported PHP versions, early return, type declaration and many more).

The PHP package is rector/rector and as the first release the configuration is quite basic:

        LevelSetList::UP_TO_PHP_73,
        SetList::DEAD_CODE,

Once we introduced and merged this, we can progressivaly add new rules (with specific and dedicated Pull Requests for achieving for example this configuration:

        LevelSetList::UP_TO_PHP_73,
        SetList::CODE_QUALITY,
        SetList::DEAD_CODE,
        SetList::EARLY_RETURN,
        SetList::TYPE_DECLARATION,
        SetList::PRIVATIZATION,

This is also very useful for when we will decide to drop the support for PHP 7.3. The tool is useful not just for being sure that the code works after dropping an old release, but it helps us to upgrade the code to use all the new features of the new versions supported (refactoring old code just beacuse we needed them because of the PHP 7.3 supports).

For checking:

vendor/bin/rector -n

For applying refactor:

vendor/bin/rector
joaokamun commented 1 year ago

@roberto-butti I think we can add Rector for V3.

roberto-butti commented 1 year ago

@roberto-butti I think we can add Rector for V3.

totally agree 👍💯

roberto-butti commented 1 year ago

Will add for V3