Skip to content

Commit 3610044

Browse files
authoredDec 17, 2021
Merge pull request magento#139 from magento-commerce/fix-phpcs-issues
Fix phpcs issues
2 parents 5559687 + 3c281c3 commit 3610044

33 files changed

+57
-83
lines changed
 

‎.github/workflows/php.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ jobs:
5454
run: vendor/bin/phpunit
5555

5656
- name: Run code style suite
57-
run: vendor/bin/phpcs --standard=Magento2 Magento2/Helpers Magento2/Sniffs Magento2Framework/Sniffs
57+
run: vendor/bin/phpcs --standard=Magento2 Magento2/Helpers Magento2/Sniffs Magento2/Rector Magento2Framework/Sniffs
5858

5959
- name: Run framework suite
60-
run: vendor/bin/phpcs --standard=Magento2Framework Magento2/Helpers Magento2/Sniffs Magento2Framework/Sniffs
60+
run: vendor/bin/phpcs --standard=Magento2Framework Magento2/Helpers Magento2/Sniffs Magento2/Rector Magento2Framework/Sniffs
6161
js:
6262
runs-on: ubuntu-latest
6363
name: Javascript tests

‎Magento2/Rector/Src/AddArrayAccessInterfaceReturnTypes.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@
1010
use PhpParser\Node;
1111
use PhpParser\Node\Stmt\Class_;
1212
use Rector\Core\Rector\AbstractRector;
13-
use Symplify\RuleDocGenerator\Exception\PoorDocumentationException;
1413
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1514
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1615

17-
final class AddArrayAccessInterfaceReturnTypes extends AbstractRector
16+
class AddArrayAccessInterfaceReturnTypes extends AbstractRector
1817
{
1918
/**
20-
* @return array<class-string<Node>>
19+
* @inheritDoc
2120
*/
2221
public function getNodeTypes(): array
2322
{
2423
return [Class_::class];
2524
}
2625

2726
/**
28-
* @param Class_ $node
27+
* @inheritDoc
2928
*/
3029
public function refactor(Node $node): ?Node
3130
{
@@ -52,13 +51,13 @@ public function refactor(Node $node): ?Node
5251
}
5352

5453
/**
55-
* @return RuleDefinition
56-
* @throws PoorDocumentationException
54+
* @inheritDoc
5755
*/
5856
public function getRuleDefinition(): RuleDefinition
5957
{
6058
return new RuleDefinition(
61-
'Add return types specified by ArrayAccess interface', [
59+
'Add return types specified by ArrayAccess interface',
60+
[
6261
new CodeSample(
6362
'public function offsetSet($offset, $value)',
6463
'public function offsetSet($offset, $value): void'

‎Magento2/Rector/Src/ReplaceMbStrposNullLimit.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111
use PhpParser\Node\Expr\FuncCall;
1212
use PhpParser\Node\Scalar\LNumber;
1313
use Rector\Core\Rector\AbstractRector;
14-
use Symplify\RuleDocGenerator\Exception\PoorDocumentationException;
1514
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1615
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1716

18-
final class ReplaceMbStrposNullLimit extends AbstractRector
17+
class ReplaceMbStrposNullLimit extends AbstractRector
1918
{
2019
/**
21-
* @return array<class-string<Node>>
20+
* @inheritDoc
2221
*/
2322
public function getNodeTypes(): array
2423
{
2524
return [FuncCall::class];
2625
}
2726

2827
/**
29-
* @param FuncCall $node
28+
* @inheritDoc
3029
*/
3130
public function refactor(Node $node): ?Node
3231
{
@@ -43,13 +42,13 @@ public function refactor(Node $node): ?Node
4342
}
4443

4544
/**
46-
* @return RuleDefinition
47-
* @throws PoorDocumentationException
45+
* @inheritDoc
4846
*/
4947
public function getRuleDefinition(): RuleDefinition
5048
{
5149
return new RuleDefinition(
52-
'Change mb_strpos offset from null to 0', [
50+
'Change mb_strpos offset from null to 0',
51+
[
5352
new CodeSample(
5453
'mb_strpos("pattern", "subject", null, "encoding");',
5554
'mb_strpos("pattern", "subject", 0, "encoding");'

‎Magento2/Rector/Src/ReplaceNewDateTimeNull.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111
use PhpParser\Node\Expr\New_;
1212
use PhpParser\Node\Scalar\String_;
1313
use Rector\Core\Rector\AbstractRector;
14-
use Symplify\RuleDocGenerator\Exception\PoorDocumentationException;
1514
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1615
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1716

18-
final class ReplaceNewDateTimeNull extends AbstractRector
17+
class ReplaceNewDateTimeNull extends AbstractRector
1918
{
2019
/**
21-
* @return array<class-string<Node>>
20+
* @inheritDoc
2221
*/
2322
public function getNodeTypes(): array
2423
{
2524
return [New_::class];
2625
}
2726

2827
/**
29-
* @param New_ $node
28+
* @inheritDoc
3029
*/
3130
public function refactor(Node $node): ?Node
3231
{
@@ -43,13 +42,13 @@ public function refactor(Node $node): ?Node
4342
}
4443

4544
/**
46-
* @return RuleDefinition
47-
* @throws PoorDocumentationException
45+
* @inheritDoc
4846
*/
4947
public function getRuleDefinition(): RuleDefinition
5048
{
5149
return new RuleDefinition(
52-
'Change DateTime datetime input from null to "now"', [
50+
'Change DateTime datetime input from null to "now"',
51+
[
5352
new CodeSample(
5453
'new DateTime(null, new DateTimeZone("GMT"));',
5554
'new DateTime("now", new DateTimeZone("GMT"));'

‎Magento2/Rector/Src/ReplacePregSplitNullLimit.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111
use PhpParser\Node\Expr\FuncCall;
1212
use PhpParser\Node\Scalar\LNumber;
1313
use Rector\Core\Rector\AbstractRector;
14-
use Symplify\RuleDocGenerator\Exception\PoorDocumentationException;
1514
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1615
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1716

18-
final class ReplacePregSplitNullLimit extends AbstractRector
17+
class ReplacePregSplitNullLimit extends AbstractRector
1918
{
2019
/**
21-
* @return array<class-string<Node>>
20+
* @inheritDoc
2221
*/
2322
public function getNodeTypes(): array
2423
{
2524
return [FuncCall::class];
2625
}
2726

2827
/**
29-
* @param FuncCall $node
28+
* @inheritDoc
3029
*/
3130
public function refactor(Node $node): ?Node
3231
{
@@ -43,13 +42,13 @@ public function refactor(Node $node): ?Node
4342
}
4443

4544
/**
46-
* @return RuleDefinition
47-
* @throws PoorDocumentationException
45+
* @inheritDoc
4846
*/
4947
public function getRuleDefinition(): RuleDefinition
5048
{
5149
return new RuleDefinition(
52-
'Change preg_split limit from null to -1', [
50+
'Change preg_split limit from null to -1',
51+
[
5352
new CodeSample(
5453
'preg_split("pattern", "subject", null, 0);',
5554
'preg_split("pattern", "subject", -1, 0);'

‎Magento2/Rector/Tests/AddArrayAccessInterfaceReturnTypes/AddArrayAccessInterfaceReturnTypesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
1212
use Symplify\SmartFileSystem\SmartFileInfo;
1313

14-
final class AddArrayAccessInterfaceReturnTypesTest extends AbstractRectorTestCase
14+
class AddArrayAccessInterfaceReturnTypesTest extends AbstractRectorTestCase
1515
{
1616
/**
1717
* @dataProvider provideData()

‎Magento2/Rector/Tests/ReplaceMbStrposNullLimit/ReplaceMbStrposNullLimitTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
1212
use Symplify\SmartFileSystem\SmartFileInfo;
1313

14-
final class ReplaceMbStrposNullLimitTest extends AbstractRectorTestCase
14+
class ReplaceMbStrposNullLimitTest extends AbstractRectorTestCase
1515
{
1616
/**
1717
* @dataProvider provideData()
@@ -29,6 +29,9 @@ public function provideData(): Iterator
2929
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
3030
}
3131

32+
/**
33+
* @return string
34+
*/
3235
public function provideConfigFilePath(): string
3336
{
3437
return __DIR__ . '/config/configured_rule.php';

‎Magento2/Rector/Tests/ReplaceNewDateTimeNull/ReplaceNewDateTimeNullTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
1212
use Symplify\SmartFileSystem\SmartFileInfo;
1313

14-
final class ReplaceNewDateTimeNullTest extends AbstractRectorTestCase
14+
class ReplaceNewDateTimeNullTest extends AbstractRectorTestCase
1515
{
1616
/**
1717
* @dataProvider provideData()

‎Magento2/Rector/Tests/ReplacePregSplitNullLimit/ReplacePregSplitNullLimitTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
1212
use Symplify\SmartFileSystem\SmartFileInfo;
1313

14-
final class ReplacePregSplitNullLimitTest extends AbstractRectorTestCase
14+
class ReplacePregSplitNullLimitTest extends AbstractRectorTestCase
1515
{
1616
/**
1717
* @dataProvider provideData()

‎Magento2/Tests/Eslint/AbstractEslintTestCase.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@
1717
abstract class AbstractEslintTestCase extends TestCase
1818
{
1919
/**
20+
* Assert that file contains a specific error.
21+
*
2022
* @param string $testFile
2123
* @param array $expectedMessages
2224
*/
2325
protected function assertFileContainsError(string $testFile, array $expectedMessages): void
2426
{
27+
// phpcs:disable
2528
exec(
2629
'npm run eslint -- Magento2/Tests/Eslint/' . $testFile,
2730
$output
2831
);
2932

3033
foreach ($expectedMessages as $message) {
31-
$this->assertStringContainsString($message, implode(' ',$output));
34+
$this->assertStringContainsString($message, implode(' ', $output));
3235
}
3336
}
3437
}

‎Magento2/Tests/Eslint/DelegateUndelegateTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ public function testExecute(): void
2121
['jQuery $.delegate and $.undelegate are deprecated, use $.on and $.off instead']
2222
);
2323
}
24-
}
24+
}

‎Magento2/Tests/Eslint/SizeTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ public function testExecute(): void
2121
['jQuery.size() removed, use jQuery.length']
2222
);
2323
}
24-
}
24+
}

‎Magento2/Tests/Eslint/TrimTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ public function testExecute(): void
2121
['jQuery.trim is deprecated; use String.prototype.trim']
2222
);
2323
}
24-
}
24+
}

‎Magento2/Tests/Legacy/InstallUpgradeUnitTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
class InstallUpgradeUnitTest extends AbstractSniffUnitTest
1414
{
15+
/**
16+
* @var string[]
17+
*/
1518
private $wrongFileNames = [
1619
'data-install-.inc',
1720
'data-upgrade-.inc',

‎Magento2/Tests/Legacy/PhtmlTemplateUnitTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public function getWarningList($testFile = '')
6767
39 => 1
6868
];
6969
}
70-
if ($testFile === 'PhtmlTemplateUnitTest.3.phtml')
71-
{
70+
if ($testFile === 'PhtmlTemplateUnitTest.3.phtml') {
7271
return [
7372
9 => 1,
7473
20 => 1,
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
3-
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
4-
52
/**
63
* Copyright © Magento, Inc. All rights reserved.
74
* See COPYING.txt for license details.
85
*/
6+
namespace Magento2\Tests\Legacy\_files\RestrictedCodeUnitTest\Magento\Framework\Model\ResourceModel;
7+
8+
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
99

1010
/**
1111
* This is NOT actually a test, but a file that must be ignored by RestrictedCodeSniff
@@ -15,20 +15,23 @@
1515
*/
1616
class IteratorDummyFile extends AbstractSniffUnitTest
1717
{
18-
protected function shouldSkipTest()
18+
protected function shouldSkipTest(): bool
1919
{
2020
return true;
2121
}
2222

23-
protected function getErrorList() {
23+
protected function getErrorList(): array
24+
{
2425
return [];
2526
}
2627

27-
protected function getWarningList() {
28+
protected function getWarningList(): array
29+
{
2830
return [];
2931
}
3032

31-
private function withProtectedClass() {
33+
private function withProtectedClass(): Zend_Db_Expr
34+
{
3235
return new \Zend_Db_Expr();
3336
}
3437
}

‎Magento2/Tests/PHPCompatibility/AbstractPrivateMethodsUnitTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public function dataForbiddenAbstractPrivateMethods()
5656
];
5757
}
5858

59-
6059
/**
6160
* Verify that the sniff throws an error for abstract private methods in traits for PHP 7.4
6261
* and doesn't for PHP 8.0.
@@ -91,7 +90,6 @@ public function dataNewTraitAbstractPrivateMethods()
9190
];
9291
}
9392

94-
9593
/**
9694
* Verify the sniff does not throw false positives for valid code.
9795
*
@@ -128,7 +126,6 @@ public function dataNoFalsePositives()
128126
return $cases;
129127
}
130128

131-
132129
/**
133130
* Verify no notices are thrown at all.
134131
*

‎Magento2/Tests/PHPCompatibility/BaseSniffTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class BaseSniffTest extends TestCase
3939
*
4040
* @var string
4141
*/
42-
const STANDARD_NAME = 'Magento2';
42+
private const STANDARD_NAME = 'Magento2';
4343

4444
/**
4545
* The PHP_CodeSniffer object used for testing.

‎Magento2/Tests/PHPCompatibility/ChangedIntToBoolParamTypeUnitTest.php

-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public function dataChangedIntToBoolParamType()
6363
];
6464
}
6565

66-
6766
/**
6867
* Verify no false positives are thrown for valid code.
6968
*
@@ -98,7 +97,6 @@ public function dataNoFalsePositives()
9897
return $data;
9998
}
10099

101-
102100
/**
103101
* Verify no notices are thrown at all.
104102
*

0 commit comments

Comments
 (0)
Please sign in to comment.