From f0fc16b55910519ecaf6d49594184324c76c0dd3 Mon Sep 17 00:00:00 2001 From: Igor Melnikov <imelnikov@magento.com> Date: Tue, 22 Nov 2016 15:58:47 -0600 Subject: [PATCH] MAGETWO-61240: Fix \Magento\Sniffs\Translation\ConstantUsageSniff Fixing static test --- .../Magento/Sniffs/Translation/ConstantUsageSniff.php | 7 ++----- .../Magento/Sniffs/Translation/ConstantUsageSniffTest.php | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/dev/tests/static/framework/Magento/Sniffs/Translation/ConstantUsageSniff.php b/dev/tests/static/framework/Magento/Sniffs/Translation/ConstantUsageSniff.php index 9b4821caf7d..4f9082aa4eb 100644 --- a/dev/tests/static/framework/Magento/Sniffs/Translation/ConstantUsageSniff.php +++ b/dev/tests/static/framework/Magento/Sniffs/Translation/ConstantUsageSniff.php @@ -27,7 +27,7 @@ class ConstantUsageSniff implements \PHP_CodeSniffer_Sniff } /** - * Copied from \Generic_Sniffs_Files_LineLengthSniff + * Copied from \Generic_Sniffs_Files_LineLengthSniff, minor changes made * * {@inheritDoc} */ @@ -35,7 +35,7 @@ class ConstantUsageSniff implements \PHP_CodeSniffer_Sniff { $tokens = $phpcsFile->getTokens(); - // Make sure this is the first open tag. + // Make sure this is the first open tag $previousOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); if ($previousOpenTag !== false) { return; @@ -45,19 +45,16 @@ class ConstantUsageSniff implements \PHP_CodeSniffer_Sniff $currentLineContent = ''; $currentLine = 1; - $trim = (strlen($phpcsFile->eolChar) * -1); for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) { if ($tokens[$tokenCount]['line'] === $currentLine) { $currentLineContent .= $tokens[$tokenCount]['content']; } else { - $currentLineContent = substr($currentLineContent, 0, $trim); $this->checkIfFirstArgumentConstant($phpcsFile, ($tokenCount - 1), $currentLineContent); $currentLineContent = $tokens[$tokenCount]['content']; $currentLine++; } } - $currentLineContent = substr($currentLineContent, 0, $trim); $this->checkIfFirstArgumentConstant($phpcsFile, ($tokenCount - 1), $currentLineContent); } diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/Sniffs/Translation/ConstantUsageSniffTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/Sniffs/Translation/ConstantUsageSniffTest.php index addb3006752..a64d47054ed 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/Sniffs/Translation/ConstantUsageSniffTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/Sniffs/Translation/ConstantUsageSniffTest.php @@ -43,7 +43,6 @@ class ConstantUsageSniffTest extends \PHPUnit_Framework_TestCase $this->fileMock->expects($this->once()) ->method('getTokens') ->willReturn($tokens); - $this->fileMock->eolChar = 2; $this->fileMock->numTokens = count($tokens); $this->fileMock->expects($this->exactly($numIncorrectUsages)) ->method('addError') -- GitLab