enriquepiatti / Magicento

PHPStorm plugin for Magento developers
115 stars 35 forks source link

Magicento even shows a rewrite conflict when the modules have a clear ordering using <depend> #151

Open audaki opened 9 years ago

audaki commented 9 years ago

Magicento even shows a rewrite conflict when the modules have a clear ordering using

Example

module A_Catalog rewrites and extends Mage_Catalog_Model_Product, so we have:

# app/code/community/A/Catalog/Model/Product.php
A_Catalog_Model_Product extends Mage_Catalog_Model_Product

and

# app/code/community/A/Catalog/etc/config.xml
<rewrite><catalog_product>A_Catalog_Model_Product</catalog_product></rewrite>

But now we write module B_Catalog, so we depend on A_Catalog in module.xml:

# app/etc/modules/B_Catalog.xml
<modules><B_Catalog>[...]<depends><A_Catalog></depends></B_Catalog></modules>

Due to this depends we have a clear ordering of XML config merging. So the rewrite in config is not a conflict, it is a guaranteed overwrite:

# app/code/community/B/Catalog/etc/config.xml
<rewrite><catalog_product>B_Catalog_Model_Product</catalog_product></rewrite>

And you can also see this in the model, that we actually extend the model of module A_Catalog

# app/code/community/B/Catalog/Model/Product.php
B_Catalog_Model_Product extends A_Catalog_Model_Product

Why is this a problem? There is no way to mark this rewrite as intentional with any phpdoc or alike, so every coder has to ignore dozens of those "rewrite conflicts". I'd suggest that in the case of modules where one depends on the other those rewrites are not marked as conflict.

rgds, Kira

enriquepiatti commented 9 years ago

You can mark the class as solved very easily, just use ALT+M > Add to solved rewrite conflict list and Magicento won't warn about that.

audaki commented 9 years ago

I know that that's possible, but if you have a big project where you have dozens of those rewrites and dozens of coders everyone has to do that again... So that's a lot of work for a bigger team. and in the described case the rewrites are not in a conflict, since they are well ordered, that's kinda a bug

enriquepiatti commented 9 years ago

Yes you are right, I will add code to make the rewrite conflicts detector a bit smarter. Thanks !!