-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Support the use of PHP 8.0 "mixed" type #35572
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
Support the use of PHP 8.0 "mixed" type #35572
Conversation
The PHP "mixed" type is a union type including null, see: https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.mixed Therefore the type is never nullable, e.g. `?mixed $someParameter` is invalid and will generate a Fatal PHP Error: "Mixed types cannot be nullable, null is already part of the mixed type." This commit will fix mixed parameters.
Hi @pmzandbergen. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review. For more details, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests 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. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @pmzandbergen ! Thanks, |
Created a very simple example module @ https://github.com/pmzandbergen/some-module Simply add it to a vanilla Magento 2.4.4 installation and run
This is caused by Magento using |
Hi @pmzandbergen, |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
...nternal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/SampleMixedProxy.txt
Show resolved
Hide resolved
Fix failing static tests
@magento run Static Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
3 similar comments
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
✔️ QA Passed Preconditions: Manual testing scenario:
Before: ✖️ Getting error while compiling. After: ✔️ No error while compilation. Additionally tested:
|
Currently Magento does not compile when using the
mixed
type, neither as a parameter or return type. The generated Interceptor / Proxy / etc. classes try to make this union type nullable (?mixed
). This will result in a fatal PHP error since the union type already includesnull
, andnull
is not nullable.During compilation you will be encountered with the following error:
Type "mixed" cannot be nullable
This patch checks if the type is
mixed
before adding the nullable (?
) prefix.Resolved issues: