Skip to content

Commit aef1174

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into psr-control-structure-spacing
2 parents 8878552 + f5cf74f commit aef1174

File tree

128 files changed

+1359
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1359
-592
lines changed

.github/workflows/php.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
php-version:
16-
- "7.4"
17-
- "8.0"
1816
- "8.1"
17+
- "8.2"
18+
- "8.3"
1919
dependencies:
2020
- "lowest"
2121
- "highest"
22-
exclude:
23-
- php-version: "8.1"
24-
dependencies: "lowest"
2522
name: Tests with PHP ${{ matrix.php-version }} and ${{ matrix.dependencies }} dependencies
2623

2724
steps:
@@ -93,4 +90,4 @@ jobs:
9390
run: composer install
9491

9592
- name: Run rector
96-
run: vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php --autoload-file vendor/phpcompatibility/php-compatibility/PHPCSAliases.php
93+
run: vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php --autoload-file vendor/magento/php-compatibility-fork/PHPCSAliases.php

Magento2/Helpers/Assert.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2023 Adobe
5+
* All Rights Reserved.
66
*/
77

88
declare(strict_types=1);

Magento2/Helpers/Commenting/PHPDocFormattingValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2019 Adobe
5+
* All Rights Reserved.
66
*/
77
namespace Magento2\Helpers\Commenting;
88

Magento2/Helpers/Tokenizer/AbstractTokenizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2021 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Helpers\Tokenizer;
77

Magento2/Helpers/Tokenizer/Parameter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2021 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Helpers\Tokenizer;
77

Magento2/Helpers/Tokenizer/Variable.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2021 Adobe
4+
* All Rights Reserved.
55
*/
6-
76
namespace Magento2\Helpers\Tokenizer;
87

98
/**

Magento2/Rector/Src/AddArrayAccessInterfaceReturnTypes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use PhpParser\Node;
1111
use PhpParser\Node\Stmt\Class_;
12-
use Rector\Core\Rector\AbstractRector;
12+
use Rector\Rector\AbstractRector;
1313
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1414
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1515

Magento2/Rector/Src/ReplaceMbStrposNullLimit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use PhpParser\Node;
1111
use PhpParser\Node\Expr\FuncCall;
1212
use PhpParser\Node\Scalar\LNumber;
13-
use Rector\Core\Rector\AbstractRector;
13+
use Rector\Rector\AbstractRector;
1414
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1515
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1616

Magento2/Rector/Src/ReplaceNewDateTimeNull.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use PhpParser\Node;
1111
use PhpParser\Node\Expr\New_;
1212
use PhpParser\Node\Scalar\String_;
13-
use Rector\Core\Rector\AbstractRector;
13+
use Rector\Rector\AbstractRector;
1414
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1515
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1616

Magento2/Rector/Src/ReplacePregSplitNullLimit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use PhpParser\Node;
1111
use PhpParser\Node\Expr\ConstFetch;
1212
use PhpParser\Node\Expr\FuncCall;
13-
use Rector\Core\Rector\AbstractRector;
13+
use Rector\Rector\AbstractRector;
1414
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1515
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1616

Magento2/Sniffs/Annotation/AnnotationFormatValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2021 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

Magento2/Sniffs/Annotation/MethodAnnotationStructureSniff.php

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2021 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -51,13 +51,34 @@ public function register()
5151
public function process(File $phpcsFile, $stackPtr)
5252
{
5353
$tokens = $phpcsFile->getTokens();
54-
$commentStartPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, ($stackPtr), 0);
55-
$commentEndPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, ($stackPtr), 0);
56-
if (!$commentStartPtr) {
57-
$phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments');
54+
$commentEndPtr = $stackPtr;
55+
$tokensToFind = [
56+
\T_SEMICOLON,
57+
\T_OPEN_CURLY_BRACKET,
58+
\T_CLOSE_CURLY_BRACKET,
59+
\T_ATTRIBUTE_END,
60+
\T_DOC_COMMENT_CLOSE_TAG
61+
];
62+
63+
do {
64+
$commentEndPtr = $phpcsFile->findPrevious($tokensToFind, $commentEndPtr - 1);
65+
if (
66+
$commentEndPtr !== false
67+
&& $tokens[$commentEndPtr]['code'] === \T_ATTRIBUTE_END
68+
&& isset($tokens[$commentEndPtr]['attribute_opener'])
69+
) {
70+
$commentEndPtr = $tokens[$commentEndPtr]['attribute_opener'];
71+
}
72+
} while ($commentEndPtr !== false && !in_array($tokens[$commentEndPtr]['code'], $tokensToFind, true));
73+
74+
if ($commentEndPtr === false || $tokens[$commentEndPtr]['code'] !== \T_DOC_COMMENT_CLOSE_TAG) {
75+
$phpcsFile->addError('Comment block is missing', $stackPtr, 'NoCommentBlock');
5876
return;
5977
}
6078

79+
$commentStartPtr = $tokens[$commentEndPtr]['comment_opener']
80+
?? $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $commentEndPtr - 1);
81+
6182
if ($this->PHPDocFormattingValidator->hasDeprecatedWellFormatted($commentStartPtr, $tokens) !== true) {
6283
$phpcsFile->addWarning(
6384
'Motivation behind the added @deprecated tag MUST be explained. '

Magento2/Sniffs/Annotation/MethodArgumentsSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2021 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

Magento2/Sniffs/Classes/AbstractApiSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Sniffs\Classes;
77

Magento2/Sniffs/Classes/DiscouragedDependenciesSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Sniffs\Classes;
77

Magento2/Sniffs/CodeAnalysis/EmptyBlockSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Sniffs\CodeAnalysis;
77

Magento2/Sniffs/Commenting/ClassAndInterfacePHPDocFormattingSniff.php

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2019 Adobe
5+
* All Rights Reserved.
66
*/
77
namespace Magento2\Sniffs\Commenting;
88

@@ -63,15 +63,30 @@ public function process(File $phpcsFile, $stackPtr)
6363
return;
6464
}
6565

66+
$commentCloserPtr = $tokens[$commentStartPtr]['comment_closer'];
67+
6668
if ($this->PHPDocFormattingValidator->providesMeaning($namePtr, $commentStartPtr, $tokens) !== true) {
67-
$phpcsFile->addWarning(
69+
$fix = $phpcsFile->addFixableWarning(
6870
sprintf(
6971
'%s description must contain meaningful information beyond what its name provides or be removed.',
7072
ucfirst($tokens[$stackPtr]['content'])
7173
),
7274
$stackPtr,
7375
'InvalidDescription'
7476
);
77+
78+
if ($fix) {
79+
for ($i = $commentStartPtr; $i <= $commentCloserPtr; $i++) {
80+
$phpcsFile->fixer->replaceToken($i, '');
81+
}
82+
83+
if (
84+
$tokens[$commentStartPtr - 1]['code'] === T_WHITESPACE
85+
&& $tokens[$commentCloserPtr + 1]['code'] === T_WHITESPACE
86+
) {
87+
$phpcsFile->fixer->replaceToken($commentCloserPtr + 1, '');
88+
}
89+
}
7590
}
7691

7792
if ($this->PHPDocFormattingValidator->hasDeprecatedWellFormatted($commentStartPtr, $tokens) !== true) {
@@ -105,11 +120,35 @@ private function validateTags(File $phpcsFile, $commentStartPtr, $tokens)
105120
}
106121

107122
if (in_array($tokens[$i]['content'], $this->forbiddenTags) === true) {
108-
$phpcsFile->addWarning(
123+
$fix = $phpcsFile->addFixableWarning(
109124
sprintf('Tag %s MUST NOT be used.', $tokens[$i]['content']),
110125
$i,
111126
'ForbiddenTags'
112127
);
128+
129+
if ($fix) {
130+
for ($j = $i - 1; $j > $commentStartPtr; $j--) {
131+
if (!in_array($tokens[$j]['code'], [T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE], true)) {
132+
break;
133+
}
134+
135+
if ($tokens[$j]['code'] === T_DOC_COMMENT_WHITESPACE && $tokens[$j]['content'] === "\n") {
136+
break;
137+
}
138+
139+
$phpcsFile->fixer->replaceToken($j, '');
140+
}
141+
142+
$phpcsFile->fixer->replaceToken($i, '');
143+
144+
for ($j = $i + 1; $j < $commentCloserPtr; $j++) {
145+
$phpcsFile->fixer->replaceToken($j, '');
146+
147+
if ($tokens[$j]['code'] === T_DOC_COMMENT_WHITESPACE && $tokens[$j]['content'] === "\n") {
148+
break;
149+
}
150+
}
151+
}
113152
}
114153
}
115154

Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -32,6 +32,7 @@ class ClassPropertyPHPDocFormattingSniff extends AbstractVariableSniff
3232
T_NULLABLE,
3333
T_BITWISE_AND,
3434
T_TYPE_UNION,
35+
T_READONLY,
3536
];
3637

3738
/**

Magento2/Sniffs/Commenting/ConstantsPHPDocFormattingSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Sniffs\Commenting;
77

Magento2/Sniffs/Exceptions/DirectThrowSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Sniffs\Exceptions;
77

Magento2/Sniffs/Exceptions/ThrowCatchSniff.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
6-
76
namespace Magento2\Sniffs\Exceptions;
87

98
use function array_slice;

Magento2/Sniffs/Exceptions/TryProcessSystemResourcesSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Sniffs\Exceptions;
77

Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Sniffs\Functions;
77

@@ -104,6 +104,7 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
104104
'^parsekit_compile_string$' => null,
105105
'^pathinfo$' => 'Magento\Framework\Filesystem\Io\File::getPathInfo',
106106
'^pcntl_.*$' => null,
107+
'^posix_isatty$' => 'stream_isatty',
107108
'^posix_.*$' => null,
108109
'^pfpro_.*$' => null,
109110
'^pfsockopen$' => null,

Magento2/Sniffs/Functions/FunctionsDeprecatedWithoutArgumentSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2021 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

Magento2/Sniffs/Functions/StaticFunctionSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento2\Sniffs\Functions;
77

0 commit comments

Comments
 (0)