Skip to content

Commit 3610044

Browse files
authored
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 7 deletions
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

Lines changed: 6 additions & 7 deletions
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

Lines changed: 6 additions & 7 deletions
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

Lines changed: 6 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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
}

0 commit comments

Comments
 (0)