magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Change variables and functions scope from private to protected #216

Closed matutetandil closed 3 years ago

matutetandil commented 4 years ago

This involves any Magento 2 version.

I know that there is a desition made based on design to have all variables and methods within core classes to be private (I already read a ticket related). This is great if you don't need to override a class and just adding after or before plugins. But sometimes, when you need to override the hole method (even when you use around) or add some new functionality you may need to use variables and functions of the class you are overriding, and all of them are private, so you must redefine those functions and variables, and that's not a good practice, but is the only way to do it.

Changing the private to protected, will improve this and will make Magento more scalable.

sivaschenko commented 3 years ago

Hi @matutetandil thanks for the report! Extending the framework classes can lead to backward compatibility problems during upgrades. It is highly recommended to use aggregation instead of extending. As you've mentioned plugins can be used to extend and customize the implementation.

If there is a use case where the existing Magento extension capabilities are not applicable - this case should be reviewed and fixed separately.

Closing this proposition as it conflicts with the current Magento development principles.

Do not hesitate to contact me on slack in case of any comments/questions