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

Upgrade slevomat/coding-standard to v6 #144

Merged
merged 8 commits into from Dec 7, 2019
Merged

Upgrade slevomat/coding-standard to v6 #144

merged 8 commits into from Dec 7, 2019

Conversation

simPod
Copy link
Contributor

@simPod simPod commented Dec 5, 2019

This aggregates:

Things to note:

  • There are few traversableTypehints listed for type hints related sniffs. Originally, there was only Doctrine Collection.
  • Spaces are not required before block control structures now, it's status quo. It's possible to enforce it by disabling excludes for BlockControlStructureSpacing sniff if desired.

Disable TypeHintDeclaration
Enable
- ParameterTypeHint
- PropertyTypeHint
- ReturnTypeHint
- UselessFunctionDocComment
ostrolucky
ostrolucky previously approved these changes Dec 5, 2019
@lcobucci
Copy link
Member

lcobucci commented Dec 5, 2019

As I mentioned to @simPod I'll be taking a look at this to ensure we enforce typed properties on PHP 7.4+

@alcaeus
Copy link
Member

alcaeus commented Dec 5, 2019

As I mentioned to @simPod I'll be taking a look at this to ensure we enforce typed properties on PHP 7.4+

Can you elaborate? Will this enforce typed properties if phpcs is run on PHP 7.4, or if the library supports PHP ^7.4?

alcaeus
alcaeus previously approved these changes Dec 5, 2019
@@ -122,6 +122,7 @@ public function throwWhenInvalid() : void
public function trySwitchSpace() : void
{
try {
$var = 1;
Copy link
Member

Choose a reason for hiding this comment

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

This kinda snuck in: not a problem for me as long as it doesn't remove newlines before control structures, but seems unrelated

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 just ensured the settings for space before block control structures is not modified from current behaviour. The test for it was missing.

Ocramius
Ocramius previously approved these changes Dec 5, 2019
carusogabriel
carusogabriel previously approved these changes Dec 5, 2019
@kukulich
Copy link
Contributor

kukulich commented Dec 5, 2019

@lcobucci @alcaeus

https://github.com/slevomat/coding-standard/blob/master/SlevomatCodingStandard/Sniffs/TypeHints/PropertyTypeHintSniff.php#L50

That's the default value but it can be changed in configuration: 9578c54#diff-1d794c8c2cf3bf4d562ddaea8be99bb0R349

@alcaeus
Copy link
Member

alcaeus commented Dec 5, 2019

Thanks @kukulich! Just wanted to make sure it remains optional.

@carusogabriel
Copy link
Contributor

Let's wait to merge this one, we want to perform some functional tests across our repos to see if everything is okay 👍

@alcaeus
Copy link
Member

alcaeus commented Dec 5, 2019

@carusogabriel here's ODM: https://gist.github.com/alcaeus/29f2c69ca1444260ea2b976221942c5c

I haven't gone through them, but there are probably some more changes we'll have to take care of. I just made sure that phpcs runs.

@simPod
Copy link
Contributor Author

simPod commented Dec 5, 2019

@alcaeus
Copy link
Member

alcaeus commented Dec 5, 2019

@lcobucci can we please split out the patch for PHP 7.4? I have my doubts about the methodology and would rather not have it block this PR. Thanks!

@alcaeus
Copy link
Member

alcaeus commented Dec 5, 2019

@simPod thanks for the hint, totally missed those. Gist is updated - most are BlockControlSpacing with a few missing parameter type hints where we either need to add documentation or update the exclude list. At first glance, it looks good 👍

@lcobucci
Copy link
Member

lcobucci commented Dec 5, 2019

I have my doubts about the methodology and would rather not have it block this PR. Thanks!

What are your doubts? Could we look at them and discuss before that?

@kukulich
Copy link
Contributor

kukulich commented Dec 5, 2019

I think that false for native type hints for properties is current state before Slevomat CS 6.0

@lcobucci
Copy link
Member

lcobucci commented Dec 5, 2019

Okay, I'm back from my meeting and will try to clarify why having enableNativeTypeHint=false is a no-go from me.

The fact we don't have projects requiring PHP 7.4 is a different story (which is sad to me but I understand the reasons) but despite that this is a library used by other folks and it shouts to everybody (trend setting as @Ocramius keeps saying): ALWAYS DECLARE THE FREAKING TYPES.

The whole Makefile + git patch approach was the easiest way to ensure this message is still propagated (making sure that anyone can checkout this project and run make to test things properly), otherwise build fails on PHP 7.4 (without enableNativeTypeHint=false) for obvious reasons.

@alcaeus
Copy link
Member

alcaeus commented Dec 5, 2019

@lcobucci please document the process of maintaining the patch file for contributors and maintainers and I'm good with it. As is, a contributor would have to try and figure out how to fix the build, and I as maintainer would have to guess if I wanted to help them: this isn't how this stuff should be built. As previously stated, I can live with the setting being enabled depending on the PHP versions (especially since this is consistent with other settings) as long as the proper documentation is in place.

@lcobucci
Copy link
Member

lcobucci commented Dec 5, 2019

@alcaeus that's completely fair to ask, I'll handle that 👍

@kukulich
Copy link
Contributor

kukulich commented Dec 5, 2019

@lcobucci I think this PR is about upgrading Slevomat CS and false is compatible with previous behaviour. So it may be better to change the option in different PR

@ostrolucky
Copy link
Member

ostrolucky commented Dec 5, 2019

All 7.4 builds will be red for PRs targetting our maintained branches (PHP >= 7.2 support), this is why it's bad. But like I said, let's talk about this on different place

@lcobucci
Copy link
Member

lcobucci commented Dec 5, 2019

All 7.4 builds will be red for PRs targetting our maintained branches

They won't because it would be a new major release and adjusting code/config to the new version is part of the upgrade.

@alcaeus
Copy link
Member

alcaeus commented Dec 5, 2019

All 7.4 builds will be red for PRs targetting our maintained branches (PHP >= 7.2 support), this is why it's bad. But like I said, let's talk about this on different place

To add on to what Luis said, most of our maintained branches run phpcs on the minimum required PHP version (as they should), not on PHP 7.4.

@lcobucci lcobucci dismissed stale reviews from carusogabriel and themself via 56d128f December 5, 2019 23:05
@lcobucci
Copy link
Member

lcobucci commented Dec 5, 2019

@alcaeus documentation added and make targets are now a bit more resilient.

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

LGTM. The compatibility patch tooling is neat, thank you for that!

@Ocramius Ocramius merged commit 9056d24 into doctrine:master Dec 7, 2019
@Ocramius Ocramius self-assigned this Dec 7, 2019
@simPod simPod deleted the upgrade-slevomatcs branch December 7, 2019 09:41
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

7 participants