Fix coding standards
[MAILPOET-3732]
This commit is contained in:
@@ -12,8 +12,6 @@ use PHP_CodeSniffer\Sniffs\Sniff;
|
|||||||
use PHP_CodeSniffer\Util\Tokens;
|
use PHP_CodeSniffer\Util\Tokens;
|
||||||
|
|
||||||
class FunctionDeclarationSniff implements Sniff {
|
class FunctionDeclarationSniff implements Sniff {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of tokenizers this sniff supports.
|
* A list of tokenizers this sniff supports.
|
||||||
*
|
*
|
||||||
@@ -214,7 +212,7 @@ class FunctionDeclarationSniff implements Sniff {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function processArgumentList($phpcsFile, $stackPtr, $indent, $type='function') {
|
public function processArgumentList($phpcsFile, $stackPtr, $indent, $type = 'function') {
|
||||||
$tokens = $phpcsFile->getTokens();
|
$tokens = $phpcsFile->getTokens();
|
||||||
|
|
||||||
// We need to work out how far indented the function
|
// We need to work out how far indented the function
|
||||||
@@ -302,7 +300,8 @@ class FunctionDeclarationSniff implements Sniff {
|
|||||||
// We changed lines, so this should be a whitespace indent token.
|
// We changed lines, so this should be a whitespace indent token.
|
||||||
if ($tokens[$i]['code'] !== T_WHITESPACE) {
|
if ($tokens[$i]['code'] !== T_WHITESPACE) {
|
||||||
$foundIndent = 0;
|
$foundIndent = 0;
|
||||||
} else if ($tokens[$i]['line'] !== $tokens[($i + 1)]['line']) {
|
} else {
|
||||||
|
if ($tokens[$i]['line'] !== $tokens[($i + 1)]['line']) {
|
||||||
// This is an empty line, so don't check the indent.
|
// This is an empty line, so don't check the indent.
|
||||||
$foundIndent = $expectedIndent;
|
$foundIndent = $expectedIndent;
|
||||||
|
|
||||||
@@ -314,6 +313,7 @@ class FunctionDeclarationSniff implements Sniff {
|
|||||||
} else {
|
} else {
|
||||||
$foundIndent = $tokens[$i]['length'];
|
$foundIndent = $tokens[$i]['length'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($expectedIndent !== $foundIndent) {
|
if ($expectedIndent !== $foundIndent) {
|
||||||
$error = 'Multi-line ' . $type . ' declaration not indented correctly; expected %s spaces but found %s';
|
$error = 'Multi-line ' . $type . ' declaration not indented correctly; expected %s spaces but found %s';
|
||||||
|
@@ -105,14 +105,15 @@ class ShortcodesTest extends \MailPoetTest {
|
|||||||
$shortcode = ['[some:shortcode arg1="val1" arg2="val2"]']; // WP style arguments
|
$shortcode = ['[some:shortcode arg1="val1" arg2="val2"]']; // WP style arguments
|
||||||
$result = $shortcodesObject->process($shortcode);
|
$result = $shortcodesObject->process($shortcode);
|
||||||
expect($result[0])->false();
|
expect($result[0])->false();
|
||||||
add_filter('mailpoet_newsletter_shortcode', function(
|
add_filter(
|
||||||
$shortcode, $newsletter, $subscriber, $queue, $content, $arguments
|
'mailpoet_newsletter_shortcode',
|
||||||
) {
|
function($shortcode, $newsletter, $subscriber, $queue, $content, $arguments) {
|
||||||
expect($arguments)->count(2);
|
expect($arguments)->count(2);
|
||||||
expect($arguments['arg1'])->equals('val1');
|
expect($arguments['arg1'])->equals('val1');
|
||||||
expect($arguments['arg2'])->equals('val2');
|
expect($arguments['arg2'])->equals('val2');
|
||||||
if (strpos($shortcode, '[some:shortcode') === 0) return 'success';
|
if (strpos($shortcode, '[some:shortcode') === 0) return 'success';
|
||||||
}, 10, 6);
|
}, 10, 6
|
||||||
|
);
|
||||||
$result = $shortcodesObject->process($shortcode);
|
$result = $shortcodesObject->process($shortcode);
|
||||||
expect($result[0])->equals('success');
|
expect($result[0])->equals('success');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user