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

[5.3] Drone: Adding check for PHP version #38471

Closed
wants to merge 25 commits into from

Conversation

Hackwar
Copy link
Member

@Hackwar Hackwar commented Aug 16, 2022

Right now we actually aren't checking the compatibility of our code for a certain PHP version statically. This PR should change that.

@Hackwar
Copy link
Member Author

Hackwar commented Aug 18, 2022

When PRs #38528 and #38527 are merged, the hard errors would be solved in our codebase. The issues left would be several warnings and 3 errors regarding soft reserved keywords which we are using. Those issues couldn't be solved and should be part of the exclusion list.

@Hackwar Hackwar marked this pull request as ready for review August 18, 2022 20:28
@Hackwar Hackwar requested a review from rdeutz as a code owner August 18, 2022 20:28
@HLeithner
Copy link
Member

@Hackwar what can we do here? clean the error or mark as exception for phpcs?

@Hackwar
Copy link
Member Author

Hackwar commented Sep 6, 2022

Most of these should be fixed. Some would have to be marked as exclusions. Will look at that soon.

@joomla-cms-bot joomla-cms-bot added the Language Change This is for Translators label Sep 6, 2022
@Hackwar Hackwar changed the base branch from 4.2-dev to 4.3-dev September 7, 2022 07:40
@Hackwar
Copy link
Member Author

Hackwar commented Oct 24, 2022

I've split this PR up into 5 PRs, see above. When those are merged and they are upmerged into this branch, that should leave only the code to introduce the version check in phpcs. I don't think it is usefull to solve the conflicts before those are merged, since each will introduce new conflicts...

Copy link

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

Left some inline notes at the request of @Hackwar. Hope it helps.

composer.json Outdated Show resolved Hide resolved
Comment on lines +29 to +48
<rule ref="PHPCompatibility.Keywords.ForbiddenNamesAsDeclared">
<exclude-pattern type="relative">libraries/src/Object/CMSObject\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/String/PunycodeHelper\.php</exclude-pattern>
<exclude-pattern type="relative">tests/Unit/Libraries/Cms/Object/CMSObjectTest\.php</exclude-pattern>
</rule>

<rule ref="PHPCompatibility.Constants.NewConstants.password_argon2idFound">
<exclude-pattern type="relative">libraries/src/Authentication/Password/Argon2idHandler\.php</exclude-pattern>
</rule>

<rule ref="PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue">
<exclude-pattern type="relative">libraries/src/Date/Date\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/Application/CliApplication\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/Application/ConsoleApplication\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/Document/HtmlDocument\.php</exclude-pattern>
</rule>

<rule ref="PHPCompatibility.FunctionNameRestrictions.NewMagicMethods">
<exclude-pattern type="relative">administrator/components/com_finder/src/Indexer/Result\.php</exclude-pattern>
</rule>
Copy link

Choose a reason for hiding this comment

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

Please be aware that these excludes will exclude the issues for the complete file, which may hide new issues being introduced in the future.

If you want more selective "ignores", you can use the PHPCS native inline ignore annotations in the files themselves, typically ignoring only one particular line or a small group of lines.
This will more effectively prevent people from accidentally introducing new issues.

@@ -21,6 +21,32 @@

Copy link

Choose a reason for hiding this comment

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

☝🏻 As a general remark - I see top-level exclude-patterns in this config file, but no <file> include ? That also may make the type="relative" directives unstable as it is unclear what this should be relative to...

Comment on lines +24 to +26
<rule ref="PHPCompatibilityJoomla">
<exclude-pattern type="relative">libraries/src/Encrypt/AES/Mcrypt\.php</exclude-pattern>
</rule>
Copy link

Choose a reason for hiding this comment

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

Suggested change
<rule ref="PHPCompatibilityJoomla">
<exclude-pattern type="relative">libraries/src/Encrypt/AES/Mcrypt\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibilityJoomla">
<include-pattern>*\.php$</include-pattern>
<exclude-pattern type="relative">libraries/src/Encrypt/AES/Mcrypt\.php</exclude-pattern>
</rule>

PHPCS will scan PHP, JS and CSS files by default. As there is no top-level extensions setting included in the ruleset to change this, you may want to ensure that the PHPCompatibility sniffs are only run against PHP files.

Copy link

Choose a reason for hiding this comment

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

Also: as the Mcrypt file is excluded completely - is that a polyfill for the Mcrypt extension ? And if so, should the PHPCompatibilityJoomla ruleset be updated to exclude errors and warnings from the polyfilled functionality completely ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The Mcrypt file is a wrapper and basically currently broken in 4.x. We are working on removing it...

@joomla-cms-bot joomla-cms-bot added PR-5.0-dev and removed Language Change This is for Translators labels Mar 8, 2023
Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com>
@Quy Quy removed the PR-4.3-dev label Mar 8, 2023
@HLeithner HLeithner changed the title [4.3] Drone: Adding check for PHP version [5.0] Drone: Adding check for PHP version Mar 8, 2023
@Hackwar Hackwar added the Feature label Apr 6, 2023
@Hackwar Hackwar closed this Apr 18, 2023
@Hackwar Hackwar reopened this Apr 18, 2023
@HLeithner HLeithner changed the base branch from 5.0-dev to 5.1-dev September 30, 2023 22:51
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.1-dev.

@HLeithner HLeithner changed the base branch from 5.1-dev to 5.2-dev April 24, 2024 09:09
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.2-dev.

@HLeithner HLeithner changed the title [5.0] Drone: Adding check for PHP version [5.2] Drone: Adding check for PHP version Apr 24, 2024
@brianteeman
Copy link
Contributor

Is anything happening with this? It has not been touched for over a year and it is unclear if anything will ever happen. It refers to it being partialy split into 5 pr but some of those have been closed as abandoned.

@Hackwar Hackwar marked this pull request as draft July 17, 2024 17:53
@HLeithner HLeithner changed the base branch from 5.2-dev to 5.3-dev September 2, 2024 08:53
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.3-dev.

@HLeithner HLeithner changed the title [5.2] Drone: Adding check for PHP version [5.3] Drone: Adding check for PHP version Sep 2, 2024
@Hackwar Hackwar removed the PR-5.2-dev label Sep 3, 2024
@rdeutz rdeutz closed this Sep 18, 2024
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.

8 participants