-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Don't make XML paths private. #29951
Comments
Hi @brideo. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. Please, add a comment to assign the issue:
🕙 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, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
you can access to path by self::XML_PATH_ instead static:XML_PATH |
@brideo means that the const declaration should be public as it's a constant defining an xml path which can be of use to other modules to fetch configuration values. Right now you can't use the const outside of this class and you have to redefine it in your own module, which can be annoying. I agree that all consts which define an xml path to a configuration should be public so we can easily access those from other modules. |
I am running 2.4.0, which doesn't work because of this exact issue. I assume it can be closed because of #28981 which is this is a duplicate of. |
Actually no sorry I'm wrong, I just looked through the commits. Why are we choosing to make constants unaccessible? They're useful for third party vendors, in fact I always thought it was best practise to access these values using constants? |
Hi @ihor-sviziev. Thank you for working on this issue.
|
Hi @brideo, Example: in some api marked class we’ll add a public constant and you as extension developer will start using it, also you would expect that your code should work fine on earlier magento versions, as you’re using the only the api classes. Unfortunately it will not work as the constant wasn’t present in earlier magento versions. For newly created classes we should use public instead of private. I hope I clearly described why it’s done in this way and we can close this issue. |
Hi @brideo, Also based on your suggestion I rule proposal for magento coding standards magento/magento-coding-standard#197. |
Summary (*)
I don't believe constants should be private as other implementations sometimes need to use them rather than redefining.
Examples (*)
Proposed solution
self::
rather thanstatic::
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: