Skip to content

[WIP] Apply Doctrine CS #968

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

Closed
wants to merge 1 commit into from
Closed

[WIP] Apply Doctrine CS #968

wants to merge 1 commit into from

Conversation

Majkl578
Copy link
Contributor

Initial import of Doctrine CS.

@goetas Excluded some rules you mentioned before that you don't like.

Also excluded BC-breaking rules since the code base is currently a bit messy, a lot of inconsistent/missing parameter/return types. :(

Only applied to src/ to give you some look at the result, and to have something to discuss/improve later on.

@goetas
Copy link
Collaborator

goetas commented Jun 19, 2018

  • Is there a way to disable the = alignment?
  • Why remove the @author annotation?
  • not fun of use function call_user_func imports, IDE are not that smart yet
  • not fun of single line type comments /** @var GraphNavigatorInterface */

*/
public function dispatch($eventName, string $class, string $format, Event $event): void;
public function dispatch(string $eventName, string $class, string $format, Event $event): void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch, this is a bug! :)

Copy link
Contributor Author

@Majkl578 Majkl578 Jun 19, 2018

Choose a reason for hiding this comment

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

There is more of missing types, some break more things so I would probably not touch types in first iteration and do them separately, then add proper docblocks for properties etc. (this one is especially in extremely bad shape in Serializer).
Then we can also consider PHPStan.

@Majkl578
Copy link
Contributor Author

Is there a way to disable the = alignment?

yes

Why remove the @author annotation?

It's totally useless and very often outdated, Git already provides more accurate information.
See doctrine/coding-standard#9 (comment) + doctrine/coding-standard#9 (comment)

@Majkl578
Copy link
Contributor Author

Also please decide the following:

  • yoda conditions: enforce or forbid
  • assignments in conditions: allow or not

@goetas
Copy link
Collaborator

goetas commented Jun 19, 2018

How to run the comment to apply the rules? is it documented somewhere?

@Majkl578
Copy link
Contributor Author

Majkl578 commented Jun 19, 2018

https://www.doctrine-project.org/projects/doctrine-coding-standard/en/latest/reference/index.html#composer-project-dependency

Since the project has (would) phpcs.xml.dist, it's enough to simply run:

  • vendor/bin/phpcs to validate CS
  • vendor/bin/phpcbf to fix fixable errors according to CS

@goetas
Copy link
Collaborator

goetas commented Jun 19, 2018

will try, tnx!

@goetas
Copy link
Collaborator

goetas commented Jul 16, 2018

implemented in #971

@goetas goetas closed this Jul 16, 2018
@Majkl578 Majkl578 deleted the cs branch July 16, 2018 15:18
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.

2 participants