Loading coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php +8 −3 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ class OptionsTSniff implements Sniff // We only search within the #options array. $arrayToken = $phpcsFile->findNext(T_ARRAY, ($stackPtr + 1)); $statementEnd = $tokens[$arrayToken]['parenthesis_closer']; $nestestParenthesis = $tokens[$arrayToken]['nested_parenthesis']; $nestestParenthesis[$tokens[$arrayToken]['parenthesis_opener']] = $tokens[$arrayToken]['parenthesis_closer']; // Go through the array by examining stuff after "=>". $arrow = $phpcsFile->findNext(T_DOUBLE_ARROW, ($stackPtr + 1), $statementEnd, false, null, true); Loading @@ -76,6 +78,9 @@ class OptionsTSniff implements Sniff if ($tokens[$arrayValue]['code'] === T_CONSTANT_ENCAPSED_STRING && is_numeric(substr($tokens[$arrayValue]['content'], 1, -1)) === false && strlen($tokens[$arrayValue]['content']) > 5 // Make sure that we don't check stuff in nested arrays within // t() for example. && $tokens[$arrayValue]['nested_parenthesis'] === $nestestParenthesis ) { // We need to make sure that the string is the one and only part // of the array value. Loading @@ -87,7 +92,7 @@ class OptionsTSniff implements Sniff } $arrow = $phpcsFile->findNext(T_DOUBLE_ARROW, ($arrow + 1), $statementEnd, false, null, true); } }//end while }//end process() Loading coder_sniffer/DrupalPractice/Test/General/OptionsTUnitTest.inc +9 −0 Original line number Diff line number Diff line Loading @@ -14,3 +14,12 @@ $form['number_display'] = array( 'four' => 'four', ), ); $form['display']['show_thumbnail'] = array( '#title' => t('Show Thumbnail', array(), array('context' => 'test')), '#type' => 'radios', '#options' => array( '1' => t('Yes', array(), array('context' => 'test')), '0' => t('No', array(), array('context' => 'test')), ), ); Loading
coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php +8 −3 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ class OptionsTSniff implements Sniff // We only search within the #options array. $arrayToken = $phpcsFile->findNext(T_ARRAY, ($stackPtr + 1)); $statementEnd = $tokens[$arrayToken]['parenthesis_closer']; $nestestParenthesis = $tokens[$arrayToken]['nested_parenthesis']; $nestestParenthesis[$tokens[$arrayToken]['parenthesis_opener']] = $tokens[$arrayToken]['parenthesis_closer']; // Go through the array by examining stuff after "=>". $arrow = $phpcsFile->findNext(T_DOUBLE_ARROW, ($stackPtr + 1), $statementEnd, false, null, true); Loading @@ -76,6 +78,9 @@ class OptionsTSniff implements Sniff if ($tokens[$arrayValue]['code'] === T_CONSTANT_ENCAPSED_STRING && is_numeric(substr($tokens[$arrayValue]['content'], 1, -1)) === false && strlen($tokens[$arrayValue]['content']) > 5 // Make sure that we don't check stuff in nested arrays within // t() for example. && $tokens[$arrayValue]['nested_parenthesis'] === $nestestParenthesis ) { // We need to make sure that the string is the one and only part // of the array value. Loading @@ -87,7 +92,7 @@ class OptionsTSniff implements Sniff } $arrow = $phpcsFile->findNext(T_DOUBLE_ARROW, ($arrow + 1), $statementEnd, false, null, true); } }//end while }//end process() Loading
coder_sniffer/DrupalPractice/Test/General/OptionsTUnitTest.inc +9 −0 Original line number Diff line number Diff line Loading @@ -14,3 +14,12 @@ $form['number_display'] = array( 'four' => 'four', ), ); $form['display']['show_thumbnail'] = array( '#title' => t('Show Thumbnail', array(), array('context' => 'test')), '#type' => 'radios', '#options' => array( '1' => t('Yes', array(), array('context' => 'test')), '0' => t('No', array(), array('context' => 'test')), ), );