Skip to content

Conversation

meyerbaptiste
Copy link
Member

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

use BooleanFilterTrait;

const DOCTRINE_BOOLEAN_TYPES = [
public const DOCTRINE_BOOLEAN_TYPES = [
Copy link
Member

Choose a reason for hiding this comment

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

I'm -1 on this public const thing it's just noise IMO. Symfony is not using it for now?

Copy link
Member Author

Choose a reason for hiding this comment

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

We should now pay attention to the visibility of our constants and define them explicitly. It's by default in the PHP-CS-Fixer ruleset @PHP71Migration.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's by default in the PHP-CS-Fixer ruleset @PHP71Migration.

But we are already using both @PHP71Migration and @PHP71Migration:risky rulesets?

Copy link
Contributor

Choose a reason for hiding this comment

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

visibility_required [@PSR2, @Symfony, @PhpCsFixer, @PHP71Migration]

Visibility MUST be declared on all properties and methods; abstract and final MUST be declared before the visibility; static MUST be declared after the visibility.

Configuration options:

- elements (a subset of ['property', 'method', 'const']): the structural elements to fix (PHP >= 7.1 required for const); defaults to ['property', 'method']

So it's not enabled by default. If we're going to make this change, we must change that option.

Copy link
Member

@soyuka soyuka Mar 20, 2019

Choose a reason for hiding this comment

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

By default constants are public and it won't change, we should define them if they're not public IMO.

https://secure.php.net/manual/en/migration71.new-features.php#migration71.new-features.class-constant-visibility

Copy link
Member Author

@meyerbaptiste meyerbaptiste Mar 20, 2019

Choose a reason for hiding this comment

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

But we are already using both @PHP71Migration and @PHP71Migration:risky rulesets?

Yep but because of the alphabetical order in our configuration, the @Symfony ruleset, that uses the @PSR2 ruleset, has the advantage and uses the default configuration: method + property vs. method + property + const for the @PHP71Migration ruleset.

Copy link
Member Author

@meyerbaptiste meyerbaptiste Mar 20, 2019

Choose a reason for hiding this comment

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

By default constants are public and it won't change

By default methods are public but you define a visibility explicitly even if it is public.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, let's add the correct configuration for this rule then.

Copy link
Contributor

@teohhanhui teohhanhui Mar 20, 2019

Choose a reason for hiding this comment

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

Yep but because of the alphabetical order in our configuration, the @Symfony ruleset has the advantage

That is indeed unexpected, but might as well since I don't think we would ever find a "correct" order. 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

I just updated the .php_cs.dist file.

@teohhanhui
Copy link
Contributor

teohhanhui commented Mar 20, 2019

Anyway, I suspect this PR should target 2.4 first (you could open a separate PR for master after this one is merged into master, as needed), to reduce future merge conflicts.

@meyerbaptiste meyerbaptiste changed the base branch from master to 2.4 March 20, 2019 15:07
@meyerbaptiste meyerbaptiste changed the base branch from 2.4 to master March 20, 2019 15:07
@meyerbaptiste meyerbaptiste changed the base branch from master to 2.4 March 20, 2019 15:44
@meyerbaptiste
Copy link
Member Author

Base branch changed.

@dunglas dunglas merged commit f6e4c59 into api-platform:2.4 Mar 20, 2019
@dunglas
Copy link
Member

dunglas commented Mar 20, 2019

Thanks @meyerbaptiste

@meyerbaptiste meyerbaptiste deleted the quality_fixes branch March 20, 2019 23:15
antograssiot added a commit to antograssiot/core that referenced this pull request Mar 25, 2019
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.

4 participants