Skip to content

Conversation

loginesta
Copy link
Contributor

@loginesta loginesta commented Sep 28, 2021

https://jira.corp.magento.com/browse/AC-674 Create phpcs static check for ObsoleteAclTest

$xml = simplexml_load_string($this->getFormattedXML($phpcsFile));
$foundElements = $xml->xpath('/config/acl/*[boolean(./children) or boolean(./title)]');
foreach ($foundElements as $element) {
if (!$this->elementIsCurrentlySniffedLine($element, $stackPtr)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better approach now is to return at the beginning of process id $stackPtr is not 0, this way, you'll only enter in the XML file once and won't need to use elementIsCurrentlySniffedLine. Take a look at WidgetXMLSniff.php

<children default_policy="deny"/>
<acl>
<children>
<title value="foo"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy this file into a new one and put the attribute value in a new line, to check that it will get errors in weird formatted XML files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a new line inside the same file following your recommendation. I tested it and it works correctly as it matches the pattern provided.

jcuerdo
jcuerdo previously approved these changes Sep 29, 2021
<type>warning</type>
</rule>
<rule ref="Magento2.Legacy.ObsoleteAcl">
<include-pattern>*\/widget.xml$</include-pattern>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should include the config.xml here.

@loginesta
Copy link
Contributor Author

@magento import pr to magento-commerce/magento-coding-standard

@m2-github-services
Copy link
Contributor

@loginesta the Pull Request is successfully imported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

6 participants