magento / marketplace-eqp

Magento 1.x Coding Standard
http://docs.magento.com/marketplace/user_guide/Resources/pdf/Extension_Quality_Program_Overview.pdf
MIT License
224 stars 68 forks source link

The method parameter $subject is never used #107

Closed treestonemedia closed 5 years ago

treestonemedia commented 5 years ago

Here is my di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <type name="Magento\Payment\Model\MethodList">
        <plugin name="methodlist" type="Treestonemedia\PurchaseOrder\Plugin\Payment\Available" sortOrder="1" />
    </type>
    <preference for="Treestonemedia\PurchaseOrder\Api\Requests\PurchaseOrderInterface" type="Treestonemedia\PurchaseOrder\Model\ApiRequest\PurchaseOrder"/>
</config>

And here is my method public function afterGetAvailableMethods($subject, $result)

The $subject variable is getting passed in by Magento's MethodList

When I run the code sniffer, I get a warning The method parameter $subject is never used

I know, I can just assign a dummy usage to that method to pass the test - but i'd rather if the sniffer can pick these up on it's own. Looking on SO, there are plenty of people reporting the same issue but none provide a solution that actually works.

lenaorobei commented 5 years ago

Hello @treestonemedia. Thanks for pointing that out. Looks like CodeSniffer is not a good choice for this particular rule because it cannot analyse class dependencies. We will consider options for removing this rule in future Unified Magento Coding Standard releases and using another more appropriate tool for this check.

lenaorobei commented 5 years ago

Closing this issue because this repo now contains sniffs for Magento 1.x code only. Please refer to magento/magento-coding-standard for Magento 2.x coding standard.

This rule was removed in magento/magento-coding-standard in order to eliminate false-positive findings.