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

test: check to have DataProviders code agnostic of PHP version #7575

Merged
merged 8 commits into from Dec 24, 2023
Merged

Conversation

keradus
Copy link
Member

@keradus keradus commented Dec 16, 2023

depends on PRs raised few mins ago

@keradus keradus marked this pull request as ready for review December 16, 2023 01:16
@keradus keradus enabled auto-merge (squash) December 16, 2023 01:17
@coveralls
Copy link

coveralls commented Dec 16, 2023

Coverage Status

coverage: 94.795%. remained the same
when pulling 3a65f9c on dx_cond
into 968e789 on master.

@kubawerlos
Copy link
Contributor

Isn't it an overkill? I was thinking of simply checking for:

                    [T_STRING, 'PHP_VERSION_ID'],
                    [T_STRING, 'PHP_MAJOR_VERSION'],
                    [T_STRING, 'PHP_MINOR_VERSION'],
                    [T_STRING, 'PHP_RELEASE_VERSION'],
                    [T_STRING, 'phpversion'],

in any test file, as all those should be handled via @requires, right?

Copy link
Contributor

@kubawerlos kubawerlos left a comment

Choose a reason for hiding this comment

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

Can we have it similar (#7580) to how we check preg_ functions calls?

@keradus
Copy link
Member Author

keradus commented Dec 16, 2023

We do not want preg_ at all (except of one file - Preg.php), because we have our Preg class.

For PHP_ in tests, I do not want to have it in data providers, but I'm OK to have it anywhere else. I think your approach is forbidding to use it anywhere else.
I would even consider to extend my approach to look not only within provide* class, but also within if conditions. Then, things like tests/FixerDefinition/VersionSpecificationTest.php won't need to be an exception

# Conflicts:
#	tests/AutoReview/ProjectCodeTest.php
@kubawerlos
Copy link
Contributor

kubawerlos commented Dec 16, 2023

Then, things like tests/FixerDefinition/VersionSpecificationTest.php won't need to be an exception

Aren't those 2 classes the only places we want to allow PHP version awareness? IMHO in all other places defined should be enough.

@keradus
Copy link
Member Author

keradus commented Dec 16, 2023

I do not understand the part of defined in context of discussion about where to use PHP_* constants.

I see no reason to prevent usage of PHP_* outside of data providers (or more explicitly - conditions inside them).

@kubawerlos
Copy link
Contributor

kubawerlos commented Dec 16, 2023

I do not understand the part of defined in context of discussion about where to use PHP_* constants.

Any if (PHP_VERSION_*) could/should be replaced with if (defined('T_*').

I see no reason to prevent usage of PHP_* outside of data providers (or more explicitly - conditions inside them).

I look at it from the other side - I see no reason to allow using PHP_* in tests.

@keradus
Copy link
Member Author

keradus commented Dec 16, 2023

Then, let's extract all if(PHP_ and if(defined cleanups to #7581 , have it merged and see how many cases we have remaining, if any.

@keradus keradus changed the title tets: check to have DataProviders code agnostic of PHP version test: check to have DataProviders code agnostic of PHP version Dec 17, 2023
@keradus keradus merged commit d49b02d into master Dec 24, 2023
50 checks passed
@keradus keradus deleted the dx_cond branch December 24, 2023 14:18
danog pushed a commit to zoonru/PHP-CS-Fixer that referenced this pull request Feb 2, 2024
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.

None yet

3 participants