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

Add doctrine/conding-standard as phpcs rule #210

Merged
merged 12 commits into from
Nov 8, 2020

Conversation

DanielBadura
Copy link
Contributor

This PR aims to get a coding standard into the project to improve readability and maintainability. I chose doctrine/coding-standard but if wanted we can switch the cs rules or require slevomat/coding-standard or squizlabs/php_codesniffer directly. Also adding / removing rules should be no problem.

At the moment I only installed the package and let phpcbf auto fix the issues that could be fixed. But there are plenty more cs issues to work on.

But before i work more on this i would get your opinion on this topic @Ocramius @maglnet :)
I would also add it to the CI and maybe remove the scrutinizer config.

@Ocramius
Copy link
Collaborator

If the diff is really all there is to it, it seems like we're already quite in line with it anyway :-)

@DanielBadura
Copy link
Contributor Author

No the diff is only that stuff that could be auto fixed. There is alot more todo. I will add the CI job as a next step :)

@DanielBadura
Copy link
Contributor Author

Well I added a config file now and added phpcs to the CI. Now i got some more autofixes and some tests are crashing now. And alot of issues are still open in phpcs. So it'll be alot of work. But for tomorrow :D

…ector::recordFunctionParameterTypesUsage due to phpcbf autofix to an earlyout that let to false types
@DanielBadura
Copy link
Contributor Author

Tests are fixed now. It was just a little thing.. 🥳
But there are still many cs fixes open.

@DanielBadura
Copy link
Contributor Author

@Ocramius this patch is almost ready. There are still 3 warnings open. I dont really know how to solve this with the line length and the arrays since i cannot create a newline with only one value in the array. :D

@Ocramius
Copy link
Collaborator

We could disable that rule: it ain't vital

@DanielBadura DanielBadura marked this pull request as ready for review October 19, 2020 09:45
@DanielBadura
Copy link
Contributor Author

Okay now the patch is ready for review. I excluded now the file too long cs.
So now the pipeline should run green besides of appveyor and scrutinizer. I removed the scrutinizer config but its is still running on this PR. So I think this is like appveyor as a config in GitHub?

One bigger change is made here. JsonLoader::getData is now a static method which returns the data directly instead of initiating the JsonLoader with the file path and getting the data separately.

@Ocramius
Copy link
Collaborator

So now the pipeline should run green besides of appveyor and scrutinizer. I removed the scrutinizer config but its is still running on this PR. So I think this is like appveyor as a config in GitHub?

Yep, we need @maglnet to hop in and shut them down in the repo settings :D

Copy link
Collaborator

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM, but the rename of GuesserInterface to Guesser, as well as the exception names, is a BC break that requires a new major release.

IMO fine, but we'd have to rename 2.2.0 to 3.0.0.

There are also many non-final symbols for which public and protected API changed, so that is also a BC break.

@maglnet I need your review on this, but from a coding perspective it is fine (besides minor comments).

If all is fine, I'd rename the milestone to 3.0.0 and move on from there.


/**
* @internal
Copy link
Collaborator

Choose a reason for hiding this comment

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

'bit of a BC break, but IMO acceptable, since this isn't really a library

)
&& $node->class instanceof Node\Name
if (
(! ($node instanceof Node\Expr\StaticCall)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This conditional got much harder to read: a simpler way to change this is to reverse it with a single ! in front of the original version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this psalm could not get the type right. Now the condition is split in two and is with this IMHO definitely more readable than before. WDYT?

@Ocramius Ocramius added this to the 3.0.0 milestone Oct 19, 2020
@Ocramius Ocramius added bc break dependencies Pull requests that update a dependency file enhancement help wanted labels Oct 19, 2020
@Ocramius Ocramius requested a review from maglnet October 19, 2020 12:44
@DanielBadura
Copy link
Contributor Author

I could also revert some of BC's if this helps :)

@Ocramius
Copy link
Collaborator

IMO they make sense, and the upgrade would be painless for 99.9% of users out there (if we go for 3.0.0): it's just a decision that the repo owner has to take.

@Ocramius Ocramius mentioned this pull request Oct 19, 2020
…m cannot interfere the type correctly, psalm things its a property check on a interface; Interfaces cannot have properties (see https://psalm.dev/028)
@maglnet
Copy link
Owner

maglnet commented Oct 29, 2020

I'm sorry, currently I cannot relly invest time in OSS, sad but true 🙈

I'm totally fine with BC breaking changes for a 3.0.0 release since this does not really affect the CLI API, which is the API for nearly all users of this package.

@Ocramius @DanielBadura
If I understand it correctly: I now disabled AppVeyor and Scruitinizer for this Repository.
Do I need to trigger a new CI-job?

@DanielBadura
Copy link
Contributor Author

No problem at all!

As far as i know: Disabling AppVeyor & Scrutinizer should be all. No need to add a new CI-Job.
But im not so familiar with GitHub's CI Settings.

@Ocramius
Copy link
Collaborator

@maglnet no worries, it is what it is :-)

@DanielBadura
Copy link
Contributor Author

@Ocramius is here something missing that i could take care of?

@Ocramius
Copy link
Collaborator

Ocramius commented Nov 8, 2020

I'm fine with it, will keep this in the next major, and we roll with that 👍

@Ocramius Ocramius merged commit 427cfc3 into maglnet:master Nov 8, 2020
@Ocramius
Copy link
Collaborator

Ocramius commented Nov 8, 2020

Thanks, @DanielBadura!

@DanielBadura DanielBadura deleted the add-php-cs branch November 30, 2020 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bc break dependencies Pull requests that update a dependency file enhancement help wanted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants