Skip to content

Use default native_constant_invocation rule for PhpCsFixer:risky ruleset#5469

Closed
mvorisek wants to merge 2 commits intoPHP-CS-Fixer:2.18from
mvorisek:patch-3
Closed

Use default native_constant_invocation rule for PhpCsFixer:risky ruleset#5469
mvorisek wants to merge 2 commits intoPHP-CS-Fixer:2.18from
mvorisek:patch-3

Conversation

@mvorisek
Copy link
Copy Markdown
Contributor

@mvorisek mvorisek commented Jan 26, 2021

as in Symfony:risky, fix todo

2nd commit is generated - pure CS fix

@mvorisek mvorisek changed the title native_constant_invocation = true for CSFixer ruleset as in Symfony Use default native_constant_invocation rule for PhpCsFixer:risky ruleset Jan 26, 2021
@mvorisek mvorisek force-pushed the patch-3 branch 2 times, most recently from 1598838 to bcf21d4 Compare January 26, 2021 23:48
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 27, 2021

Coverage Status

Coverage increased (+0.2%) to 92.104% when pulling ac94edb on mvorisek:patch-3 into ea98c01 on FriendsOfPHP:2.18.

Copy link
Copy Markdown
Member

@keradus keradus left a comment

Choose a reason for hiding this comment

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

as commented

'@Symfony:risky' => true,
'comment_to_phpdoc' => true,
'final_internal_class' => true,
// @TODO: consider switching to `true`, like in @Symfony
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the decision for this action was not yet done.
merging this PR as-is will cause a lot of conflicts between 2.x <> 3.x and lead to conflicts on PRs too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In Symfony:risky ruleset this was changed in 2.x. Thus I propose to change PhpCsFixer:risky ruleset in 2.x as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understood that intention from PR title,

unfortunately, your comment does not address my concerns

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can I help addressing your concerns? You want this change in 2.x or 3.x only?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Due to amount of conflicts it gonna create for us, syncing between v2<>v3 and all open PRs, I don't see big value of having this change merged right now.
What would be the benefit overcoming the downsides?

Copy link
Copy Markdown
Contributor Author

@mvorisek mvorisek Apr 19, 2021

Choose a reason for hiding this comment

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

For these reasons, I opened this PR into v2. I belive, FQCN are important as they can be optimized at compile time and a reason why it is already default in the Symfony ruleset.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it does not solve the concern for conflicts for all open PRs.

Let's reject the PR for now and re-evaluate this change after we decrease amount of open PRs or stop v2 support

@mvorisek
Copy link
Copy Markdown
Contributor Author

mvorisek commented Apr 30, 2021

@keradus why close? The same as we optimize Zend optimized functions to use FQCN, the same we must optimize core php constants. PhpCsFixer ruleset should be not "weaker" than Symfony.

@mvorisek
Copy link
Copy Markdown
Contributor Author

@keradus can I please get your reaction on this? I think constants should be really FQN, like functions.

@SpacePossum
Copy link
Copy Markdown
Contributor

You can read here why @keradus closed the PR.

For the project we've to consider the sparse time maintainers have and try to keep away from big conflicts. This is than weighted against the possible upsides of the changes.

PhpCsFixer ruleset should be not "weaker" than Symfony

The ruleset PhpCsFixer really is the internal set for this project, not a SF++ or something. There really are no rules to it. Everyone is free to use it, but it is what it is, so no BC promise, no boards, no docs, no mailing lists, just an internal set for this project :)

I think constants should be really FQN, like functions.

You can configure it for you own projects, it is not the reason why the PR is merged or not.

@mvorisek
Copy link
Copy Markdown
Contributor Author

mvorisek commented May 25, 2021

I understand the concerns, but conflicts can be solved easily by applying CS fixer to both branches prior merging easily.

See https://3v4l.org/VcUv2/vld#output and https://3v4l.org/npt1J/vld#output opcodes generated. Using FQ constant names is important for performance as if not used absolutely, constant names are resolved on every access (not even once per file load!) which causes unneeded overhead.

Here is a functional benchmark: https://3v4l.org/7E3Af and https://3v4l.org/26W95 . Please reconsider this once again. Even if php performance will improve 10x, this overhead will probably stay fixed as php engine can not optimize it more. And it will be consistent with functions, which are already FQ/fixed.

The 2nd benchmark shows large improvement as the constants can be resolved on compile time which is very helpful for internal php optimizations and JIT.

@mvorisek mvorisek deleted the patch-3 branch April 9, 2023 09:58
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