QuestionQ39

VerifiedEnforce coding standards

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

The Architect creates:

  • A new Composer package under the AwesomeAgency\CodingStandard\ namespace
  • The ruleset.xml file extending the Magento 2 Coding Standard

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

Explanation

A PHPCS rule is a sniff. A custom sniff implements PHP_CodeSniffer\Sniffs\Sniff and performs its token-level validation in the process() method; the ruleset selects and configures sniffs rather than implementing rule logic through a Ruleset subclass.

Learn more

Community Discussion

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