storyblok-php-client icon indicating copy to clipboard operation
storyblok-php-client copied to clipboard

Adding Rector: Dead Code, Code quality, Coding Style, Type Declarations, Early return

Open roberto-butti opened this issue 9 months ago • 2 comments

Introducing Rector and updating the code for:

  • Dead Code;
  • Code quality;
  • Coding Style;
  • Type Declarations
  • Early return
  • Updating old PHP code (in order to use at least the PHP 7.3 , at the moment the oldest PHP version supported by Storyblok PHP client)

The configurarion:

->withPhpSets(php73: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
earlyReturn: true

);

Running all tests are still green

roberto-butti avatar May 06 '24 05:05 roberto-butti

Hi @RicLeP i see your comments, thank you! So are you suggesting to avoid yoda style, so i can set in the PHP cs fixer configuration :

    'yoda_style' => [
        'always_move_variable' => false,
        'equal' => false,
        'identical' => false,
        'less_and_greater' => false,
    ],

What do you think ?

roberto-butti avatar May 08 '24 17:05 roberto-butti

It’s a code style choice so not essential, however I think it’s usually recommended, but go with what you feel it best. :)

RicLeP avatar May 15 '24 08:05 RicLeP

Since PSR-12 its not recommended to use yoda style due to less readability of the code. However i prefer yoda style as well :)

silasjoisten avatar Oct 09 '24 13:10 silasjoisten