Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Introduce Laravel-specific rules #6441

Closed
wants to merge 6 commits into from

Conversation

szepeviktor
Copy link
Contributor

Please be patient with me. This is the 1st time I use a computer :)

@szepeviktor szepeviktor changed the title Intruuoce Laravel-specific rules Introduce Laravel-specific rules Jun 24, 2022
@szepeviktor szepeviktor changed the title Introduce Laravel-specific rules feature: Introduce Laravel-specific rules Jun 24, 2022
public function getDefinition(): FixerDefinitionInterface
{
return new FixerDefinition(
'Annotations must respect the following order: @param, @return, and @throws.',
Copy link
Member

@keradus keradus Jun 24, 2022

Choose a reason for hiding this comment

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

I believe we should rather generalise phpdoc_order instead of making framework-specific rule. This will help to avoid having lot of logic duplicated or to allow user to use 2 almost identical rules.

I have a feeling that this could be extended for other proposed rules

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your comment.
Please tell me what to do with what. I don't know what these 3 classes do.
It is a copy-paste job from Laravel Pint. Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see! PhpdocOrderFixer: param -> throws -> return
PhpdocLaravelOrderFixer: param -> return -> throws

What do you mean by "generalise"?
Develop a 3rd class that contains common parts of these two??
FYI I do not write code daily, so $speed === 1 line/day 🐌

Copy link
Member

@keradus keradus Jun 25, 2022

Choose a reason for hiding this comment

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

In general, when we have a wish to do almost the same, but with a slight different outcome, to match different users expectations, we have one rule (single class), that we mark configurable. You may grep for ConfigurableFixerInterface to see examples.

Yet, if you are not original author of those fixers and you took it from another repo, I would suggest to incorporate original creator of it, to not violate his coderights/license.

I guess (I didn't checked deeply) that you copied them from laravel/pint repo, and if it is the case, I would prefer to wait for outcome of laravel/pint#50 before we move forward with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

Copy link
Member

Choose a reason for hiding this comment

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

Suggestion:

  • let's have smaller PRs that are focusing on single job only. I would suggest to simplify this PR to focus on one rule only, and then move to other rule when first one is merged
  • let's introduce configuration option to the fixer rather than duplicating it
  • we gonna need some new utests to cover new functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be to nice if a developer would jump in - I mostly do the thinking.

Copy link
Member

Choose a reason for hiding this comment

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

If you have someone from Laravel community to help, please let them know (i guess it will be them who would benefit from changes).
If not really, and you are not the one who can work on this PR, then I suggest to close it until someone eager to do it would arrive.

Copy link

Choose a reason for hiding this comment

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

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 92.352% when pulling bcecddc on szepeviktor:add/3Laravel into aa976c5 on FriendsOfPHP:master.

@keradus
Copy link
Member

keradus commented Jul 4, 2022

I'm happy to have those features incorporated into main repo.

Anyone, if you feel up to prepare PR with it, please go ahead!

Meanwhile, closing as discussed in #6441 (comment)

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

Successfully merging this pull request may close these issues.

None yet

4 participants