Skip to content

Fix phpcs issues #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
5 changes: 4 additions & 1 deletion Magento2/Tests/Eslint/AbstractEslintTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@
abstract class AbstractEslintTestCase extends TestCase
{
/**
* Assert that file contains a specific error.
*
* @param string $testFile
* @param array $expectedMessages
*/
protected function assertFileContainsError(string $testFile, array $expectedMessages): void
{
// phpcs:disable
exec(
'npm run eslint -- Magento2/Tests/Eslint/' . $testFile,
$output
);

foreach ($expectedMessages as $message) {
$this->assertStringContainsString($message, implode(' ',$output));
$this->assertStringContainsString($message, implode(' ', $output));
}
}
}
2 changes: 1 addition & 1 deletion Magento2/Tests/Eslint/ClickEventShorthandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public function testExecute(): void
['Instead of .blur(fn) use .on("blur", fn). Instead of .blur() use .trigger("blur")']
);
}
}
}
2 changes: 1 addition & 1 deletion Magento2/Tests/Eslint/DelegateUndelegateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public function testExecute(): void
['jQuery $.delegate and $.undelegate are deprecated, use $.on and $.off instead']
);
}
}
}
2 changes: 1 addition & 1 deletion Magento2/Tests/Eslint/EventShorthandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public function testExecute(): void
['jQuery.load() was removed, use .on("load", fn) instead']
);
}
}
}
2 changes: 1 addition & 1 deletion Magento2/Tests/Eslint/SizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public function testExecute(): void
['jQuery.size() removed, use jQuery.length']
);
}
}
}
2 changes: 1 addition & 1 deletion Magento2/Tests/Eslint/TrimTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public function testExecute(): void
['jQuery.trim is deprecated; use String.prototype.trim']
);
}
}
}
3 changes: 3 additions & 0 deletions Magento2/Tests/Legacy/InstallUpgradeUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

class InstallUpgradeUnitTest extends AbstractSniffUnitTest
{
/**
* @var string[]
*/
private $wrongFileNames = [
'data-install-.inc',
'data-upgrade-.inc',
Expand Down
3 changes: 1 addition & 2 deletions Magento2/Tests/Legacy/PhtmlTemplateUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public function getWarningList($testFile = '')
39 => 1
];
}
if ($testFile === 'PhtmlTemplateUnitTest.3.phtml')
{
if ($testFile === 'PhtmlTemplateUnitTest.3.phtml') {
return [
9 => 1,
20 => 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento2\Tests\Legacy\_files\RestrictedCodeUnitTest\Magento\Framework\Model\ResourceModel;

use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;

/**
* This is NOT actually a test, but a file that must be ignored by RestrictedCodeSniff
Expand All @@ -15,20 +15,23 @@
*/
class IteratorDummyFile extends AbstractSniffUnitTest
{
protected function shouldSkipTest()
protected function shouldSkipTest(): bool
{
return true;
}

protected function getErrorList() {
protected function getErrorList(): array
{
return [];
}

protected function getWarningList() {
protected function getWarningList(): array
{
return [];
}

private function withProtectedClass() {
private function withProtectedClass(): Zend_Db_Expr
{
return new \Zend_Db_Expr();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function dataForbiddenAbstractPrivateMethods()
];
}


/**
* Verify that the sniff throws an error for abstract private methods in traits for PHP 7.4
* and doesn't for PHP 8.0.
Expand Down Expand Up @@ -91,7 +90,6 @@ public function dataNewTraitAbstractPrivateMethods()
];
}


/**
* Verify the sniff does not throw false positives for valid code.
*
Expand Down Expand Up @@ -128,7 +126,6 @@ public function dataNoFalsePositives()
return $cases;
}


/**
* Verify no notices are thrown at all.
*
Expand Down
2 changes: 1 addition & 1 deletion Magento2/Tests/PHPCompatibility/BaseSniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BaseSniffTest extends TestCase
*
* @var string
*/
const STANDARD_NAME = 'Magento2';
private const STANDARD_NAME = 'Magento2';

/**
* The PHP_CodeSniffer object used for testing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public function dataChangedIntToBoolParamType()
];
}


/**
* Verify no false positives are thrown for valid code.
*
Expand Down Expand Up @@ -98,7 +97,6 @@ public function dataNoFalsePositives()
return $data;
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public function dataForbiddenFinalPrivateMethods()
];
}


/**
* Verify the sniff does not throw false positives for valid code.
*
Expand Down Expand Up @@ -91,7 +90,6 @@ public function dataNoFalsePositives()
return $cases;
}


/**
* Verify no notices are thrown at all.
*
Expand Down
2 changes: 0 additions & 2 deletions Magento2/Tests/PHPCompatibility/NewAttributesUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function dataNewAttributes()
return $data;
}


/**
* Verify the sniff does not throw false positives for valid code.
*
Expand Down Expand Up @@ -142,7 +141,6 @@ public function dataNoFalsePositives()
return $data;
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Magento2\Tests\PHPCompatibility;


/**
* Test the NewInterpolatedStringDereferencing sniff.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Magento2\Tests\PHPCompatibility;


/**
* Test the NewMagicClassConstant sniff.
*
Expand Down Expand Up @@ -63,7 +62,6 @@ public function dataNewMagicClassConstant()
];
}


/**
* Verify that no false positives are thrown for valid code.
*
Expand Down Expand Up @@ -96,7 +94,6 @@ public function dataNoFalsePositives()
];
}


/**
* Test correctly identifying the magic class constant when used on instantiated objects.
*
Expand Down Expand Up @@ -136,7 +133,6 @@ public function dataNewMagicClassConstantOnObject()
];
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Magento2\Tests\PHPCompatibility;


/**
* Test the NewMagicConstantDereferencing sniff.
*
Expand Down Expand Up @@ -60,7 +59,6 @@ public function dataNewMagicConstantDereferencing()
];
}


/**
* Verify the sniff does not throw false positives for valid code, nor for code which is still invalid.
*
Expand Down Expand Up @@ -99,7 +97,6 @@ public function dataNoFalsePositives()
];
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function dataNestedStaticAccess()
];
}


/**
* Verify that class constant dereferencing emits an error in PHP 7.4.
*
Expand Down Expand Up @@ -100,7 +99,6 @@ public function dataClassConstantDereferencing()
];
}


/**
* Verify the sniff doesn't throw false positives.
*
Expand Down Expand Up @@ -133,7 +131,6 @@ public function dataNoFalsePositives()
];
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function dataNewNonCapturingCatch()
];
}


/**
* Verify no false positives are thrown for valid code.
*
Expand Down Expand Up @@ -89,7 +88,6 @@ public function dataNoFalsePositives()
];
}


/**
* Verify no notices are thrown at all.
*
Expand Down
3 changes: 0 additions & 3 deletions Magento2/Tests/PHPCompatibility/NewTrailingCommaUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function dataTrailingComma()
];
}


/**
* Test correctly identifying trailing comma's in closure use lists.
*
Expand Down Expand Up @@ -90,7 +89,6 @@ public function dataTrailingCommaClosureUse()
];
}


/**
* Verify the sniff does not throw false positives for valid code.
*
Expand Down Expand Up @@ -127,7 +125,6 @@ public function dataNoFalsePositives()
return $data;
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public function dataRemovedAssertStringAssertion()
];
}


/**
* Verify there are no false positives on code this sniff should ignore.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Magento2\Tests\PHPCompatibility;


/**
* Test the RemovedCallingDestructAfterConstructorExit sniff.
*
Expand Down Expand Up @@ -66,7 +65,6 @@ public function dataRemovedCallingDestructAfterConstructorExit()
];
}


/**
* Verify the sniff does not throw false positives for valid code.
*
Expand Down Expand Up @@ -107,7 +105,6 @@ public function dataNoFalsePositives()
return $cases;
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function dataRemovedGetDefinedFunctionsExcludeDisabledFalse()
];
}


/**
* Verify the sniff does not throw false positives for valid code.
*
Expand All @@ -68,7 +67,6 @@ public function testNoFalsePositives()
}
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function dataRemovedOptionalBeforeRequiredParam()
];
}


/**
* Verify the sniff does not throw false positives for valid code.
*
Expand Down Expand Up @@ -103,7 +102,6 @@ public function dataNoFalsePositives()
return $cases;
}


/**
* Verify no notices are thrown at all.
*
Expand Down
Loading