Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PropertiesLineBreakSniff.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Sniffs\Less;
7 
8 use PHP_CodeSniffer\Sniffs\Sniff;
9 use PHP_CodeSniffer\Files\File;
10 
19 class PropertiesLineBreakSniff implements Sniff
20 {
27 
31  public function register()
32  {
33  return [T_SEMICOLON];
34  }
35 
39  public function process(File $phpcsFile, $stackPtr)
40  {
41  $tokens = $phpcsFile->getTokens();
42 
43  $prevPtr = $phpcsFile->findPrevious(T_SEMICOLON, ($stackPtr - 1));
44  if (false === $prevPtr) {
45  return;
46  }
47 
48  if ($tokens[$prevPtr]['line'] === $tokens[$stackPtr]['line']) {
49  $error = 'Each property must be on a line by itself';
50  $phpcsFile->addError($error, $stackPtr, 'SameLine');
51  }
52  }
53 }
$tokens
Definition: cards_list.phtml:9