QuestionQ22

VerifiedStore Operations and Admin

An Architect agrees to enhance company coding standards and discourage the use of Helper classes in code by adding a new PHPCS check.

The Architect creates:

  • A new Composer package in the AwesomeAgency\CodingStandard\ namespace
  • A ruleset.xml file that extends the Magento 2 Coding Standard

What should the Architect do to implement the new code rule?

Explanation

A PHP_CodeSniffer rule is implemented as a sniff. The sniff belongs in the custom standard’s Sniff namespace, implements PHP_CodeSniffer\Sniffs\Sniff, and inspects registered tokens through its process() method to report violations such as prohibited Helper-class usage. A ruleset configures and includes sniffs; it is not itself the implementation of a rule.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!