Skip to content

Remove old code for php versions we no longer support #39362

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

Open
ihor-sviziev opened this issue Nov 13, 2024 · 8 comments
Open

Remove old code for php versions we no longer support #39362

ihor-sviziev opened this issue Nov 13, 2024 · 8 comments
Assignees
Labels
Area: Framework Component: Framework/Code Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: dev in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@ihor-sviziev
Copy link
Contributor

In #39202, we did some cleanup, but it cleaned not all places.

It would be great to clean also

Originally posted by @ihor-sviziev in #39202 (comment)

Copy link

m2-assistant bot commented Nov 13, 2024

Hi @ihor-sviziev. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@github-project-automation github-project-automation bot moved this to Ready for Confirmation in Issue Confirmation and Triage Board Nov 13, 2024
@engcom-Bravo engcom-Bravo added Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it Reported on 2.4.x Indicates original Magento version for the Issue report. labels Nov 13, 2024
@engcom-Hotel engcom-Hotel self-assigned this Nov 13, 2024
Copy link

m2-assistant bot commented Nov 13, 2024

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

Hello @ihor-sviziev,

Thanks for the report and collaboration!

We are confirming this issue for further processing.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Framework/Code Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Area: Framework and removed Issue: ready for confirmation labels Nov 13, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-13349 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Nov 13, 2024

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@ihor-sviziev
Copy link
Contributor Author

I also noticed that we have some workarounds for bugs in PHP itself: https://github.com/search?q=repo%3Amagento%2Fmagento2%20bugs.php.net&type=code
Maybe worth fixing them as well

@SilinMykola
Copy link
Contributor

@magento I am working on this

@hostep
Copy link
Contributor

hostep commented Apr 15, 2025

I just happen to have stumbled upon this blog post: https://staabm.github.io/2024/11/14/phpstan-php-version-narrowing.html

If I try this out, by changing:

--- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon
@@ -2,13 +2,17 @@ parameters:
     checkExplicitMixedMissingReturn: true
     checkPhpDocMissingReturn: true
     reportUnmatchedIgnoredErrors: false
+    phpVersion:
+        min: 80200
+        max: 80499
     excludePaths:
         - %rootDir%/../../../lib/internal/Magento/Framework/ObjectManager/Test/Unit/*

Update: it turns out this change isn't needed, phpstan extracts the min & max php versions supported from the composer.json file, which is great!

Then upgrading phpstan to v2

And then running a check on one of the files that still use code for detecting older php versions, phpstan is indeed able to detect automatically code that can be cleaned up:

$ ./vendor/bin/phpstan analyse -c dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon --level=4 app/bootstrap.php
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ -------------------------------------------------------------------------------
  Line   bootstrap.php
 ------ -------------------------------------------------------------------------------
  17     Comparison operation "<" between int<80200, 80499> and 80100 is always false.
         🪪  smaller.alwaysFalse
  35     Comparison operation "<" between int<80200, 80499> and 80000 is always false.
         🪪  smaller.alwaysFalse
 ------ -------------------------------------------------------------------------------

This requires us to:

  • upgrade phpstan to 2.0, which currently is blocked by magento/magento-coding-standard which requires rector/rector 1.0, which requires phpstan 1.0, so this means magento/magento-coding-standard should first be updated to require rector/rector 2.0, which is already pending here.
  • increasing the default level phpstan runs on the magento codebase significantly from level 1 to level 4

I don't see any of this happening soon-ish, Adobe is very slow in updating their static analysis code, so this will probably take a few years until any of this happens, unless they surprise us ...

Anyway, leaving this behind for anyone who cares or is interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Framework/Code Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: dev in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

No branches or pull requests

6 participants