Skip to content

Commit 0d6cb3c

Browse files
Merge pull request #61 from magento-commerce/imported-magento-magento-coding-standard-267
[Imported] AC-666: Create phpcs static check for CopyrightTest for php files
2 parents 9b4da0c + a2864d2 commit 0d6cb3c

File tree

112 files changed

+246
-103
lines changed

Some content is hidden

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

112 files changed

+246
-103
lines changed

Magento2/Helpers/Commenting/PHPDocFormattingValidator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

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

Magento2/Sniffs/Classes/AbstractApiSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Classes;

Magento2/Sniffs/Classes/DiscouragedDependenciesSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Classes;

Magento2/Sniffs/CodeAnalysis/EmptyBlockSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\CodeAnalysis;

Magento2/Sniffs/Commenting/ClassAndInterfacePHPDocFormattingSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

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

Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
26
namespace Magento2\Sniffs\Commenting;
37

48
use PHP_CodeSniffer\Files\File;

Magento2/Sniffs/Commenting/ConstantsPHPDocFormattingSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Commenting;

Magento2/Sniffs/Exceptions/DirectThrowSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Exceptions;

Magento2/Sniffs/Exceptions/ThrowCatchSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

Magento2/Sniffs/Exceptions/TryProcessSystemResourcesSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Exceptions;

Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Functions;

Magento2/Sniffs/Functions/StaticFunctionSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Functions;

Magento2/Sniffs/GraphQL/AbstractGraphQLSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\GraphQL;

Magento2/Sniffs/GraphQL/ValidArgumentNameSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

Magento2/Sniffs/GraphQL/ValidEnumValueSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

Magento2/Sniffs/GraphQL/ValidFieldNameSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\GraphQL;

Magento2/Sniffs/GraphQL/ValidTopLevelFieldNameSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\GraphQL;

Magento2/Sniffs/GraphQL/ValidTypeNameSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\GraphQL;

Magento2/Sniffs/Legacy/AbstractBlockSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
declare(strict_types = 1);
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types = 1);
7+
8+
namespace Magento2\Sniffs\Legacy;
9+
10+
use PHP_CodeSniffer\Files\File;
11+
use PHP_CodeSniffer\Sniffs\Sniff;
12+
13+
class CopyrightSniff implements Sniff
14+
{
15+
private const WARNING_CODE = 'FoundCopyrightMissingOrWrongFormat';
16+
17+
private const COPYRIGHT_MAGENTO_TEXT = 'Copyright © Magento, Inc. All rights reserved.';
18+
private const COPYRIGHT_ADOBE = '/Copyright \d+ Adobe/';
19+
20+
/**
21+
* @inheritdoc
22+
*/
23+
public function register()
24+
{
25+
return [T_OPEN_TAG];
26+
}
27+
28+
/**
29+
* @inheritDoc
30+
*/
31+
public function process(File $phpcsFile, $stackPtr)
32+
{
33+
if ($phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false) {
34+
return;
35+
}
36+
37+
$positionComment = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $stackPtr);
38+
39+
if ($positionComment === false) {
40+
$phpcsFile->addWarning(
41+
'Copyright is missing',
42+
$stackPtr,
43+
self::WARNING_CODE
44+
);
45+
return;
46+
}
47+
48+
$content = $phpcsFile->getTokens()[$positionComment]['content'];
49+
$adobeCopyrightFound = preg_match(self::COPYRIGHT_ADOBE, $content);
50+
51+
if (strpos($content, self::COPYRIGHT_MAGENTO_TEXT) !== false || $adobeCopyrightFound) {
52+
return;
53+
}
54+
55+
$phpcsFile->addWarningOnLine(
56+
'Copyright is missing or has wrong format',
57+
$phpcsFile->getTokens()[$positionComment]['line'],
58+
self::WARNING_CODE
59+
);
60+
}
61+
}

Magento2/Sniffs/Legacy/MageEntitySniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Legacy;

Magento2/Sniffs/Methods/DeprecatedModelMethodSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Methods;

Magento2/Sniffs/Namespaces/ImportsFromTestNamespaceSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Namespaces;

Magento2/Sniffs/NamingConvention/InterfaceNameSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\NamingConvention;

Magento2/Sniffs/PHP/FinalImplementationSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\PHP;

Magento2/Sniffs/PHP/GotoSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\PHP;

Magento2/Sniffs/PHP/ReturnValueCheckSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\PHP;

Magento2/Sniffs/PHP/VarSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\PHP;

Magento2/Sniffs/Performance/ForeachArrayMergeSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Performance;

Magento2/Sniffs/SQL/RawQuerySniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\SQL;

Magento2/Sniffs/Security/IncludeFileSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Security;

Magento2/Sniffs/Security/InsecureFunctionSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Security;

Magento2/Sniffs/Security/LanguageConstructSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Security;

Magento2/Sniffs/Security/SuperglobalSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Security;

Magento2/Sniffs/Security/XssTemplateSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Security;

Magento2/Sniffs/Strings/ExecutableRegExSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Strings;

Magento2/Sniffs/Strings/StringConcatSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Strings;

Magento2/Sniffs/Templates/ThisInTemplateSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Templates;

Magento2/Sniffs/Whitespace/MultipleEmptyLinesSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Whitespace;

Magento2/Tests/Classes/AbstractApiUnitTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Tests\Classes;

Magento2/Tests/Classes/DiscouragedDependenciesUnitTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Tests\Classes;

Magento2/Tests/CodeAnalysis/EmptyBlockUnitTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Tests\CodeAnalysis;

0 commit comments

Comments
 (0)