Skip to content

Welcome to RectorPHP - #307

Open
roberto-butti wants to merge 5 commits into
ash-jc-allen:masterfrom
roberto-butti:rector
Open

Welcome to RectorPHP#307
roberto-butti wants to merge 5 commits into
ash-jc-allen:masterfrom
roberto-butti:rector

Conversation

@roberto-butti

Copy link
Copy Markdown
  • added rector
  • added ruleset for laravel
  • using set code quality and dead code

@ash-jc-allen ash-jc-allen left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @roberto-butti, huge thank you for this PR! I've just left a few small questions 😄

Comment thread rector.php
__DIR__ . '/tests',
])
// uncomment to reach your current PHP version
//->withPhpSets(php80: true)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in assuming that we'd set the current PHP version as 8.1 here since that's the minimum version required for the package? 🙂

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tried it, but it raised some other issues we need to address. So, to keep this specific PR small, I started with two simple rulesets. One of the great things of Rector is that you can introduce it in a project with just a few rules and then add more rules later, with a kind of "progressive" approach

Comment thread src/Classes/Builder.php
$shortURL = new ShortURL($data);

if ($this->beforeCreateCallback) {
if ($this->beforeCreateCallback instanceof \Closure) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to make up my mind about whether I like this change. The beforeCreateCallback property can only be null or an instance of Closure. So I'm not sure how much value the additional instanceof check is adding other than making it more explicit.

But if there's a good reason for it, I'm more than happy to be persuaded that this will be a beneficial change 😄

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a more strict check.
This is introduced by the rulesetCodeQuality i set in the rector.php config.
The CodeQuality ruleset includes the two applied rules: FlipTypeControlToUseExclusiveTypeRector https://getrector.com/rule-detail/flip-type-control-to-use-exclusive-type-rector and ExplicitBoolCompareRector https://getrector.com/rule-detail/explicit-bool-compare-rector.

If you want to be more granular in the configuration, to control rules and not generic ruleset, you can use withRules instead of withPreparedSets

@lloricode

Copy link
Copy Markdown

1+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants