diff --git a/Magento2/Helpers/Commenting/PHPDocFormattingValidator.php b/Magento2/Helpers/Commenting/PHPDocFormattingValidator.php index fb98db7c..745ec587 100644 --- a/Magento2/Helpers/Commenting/PHPDocFormattingValidator.php +++ b/Magento2/Helpers/Commenting/PHPDocFormattingValidator.php @@ -1,7 +1,7 @@ findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false) { + return; + } + + $positionComment = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $stackPtr); + + if ($positionComment === false) { + $phpcsFile->addWarning( + 'Copyright is missing', + $stackPtr, + self::WARNING_CODE + ); + return; + } + + $content = $phpcsFile->getTokens()[$positionComment]['content']; + $adobeCopyrightFound = preg_match(self::COPYRIGHT_ADOBE, $content); + + if (strpos($content, self::COPYRIGHT_MAGENTO_TEXT) !== false || $adobeCopyrightFound) { + return; + } + + $phpcsFile->addWarningOnLine( + 'Copyright is missing or has wrong format', + $phpcsFile->getTokens()[$positionComment]['line'], + self::WARNING_CODE + ); + } +} diff --git a/Magento2/Sniffs/Legacy/MageEntitySniff.php b/Magento2/Sniffs/Legacy/MageEntitySniff.php index 637c3b1c..de8b7dbf 100644 --- a/Magento2/Sniffs/Legacy/MageEntitySniff.php +++ b/Magento2/Sniffs/Legacy/MageEntitySniff.php @@ -1,6 +1,6 @@ + + diff --git a/Magento2/Tests/Legacy/CopyrightUnitTest.4.inc b/Magento2/Tests/Legacy/CopyrightUnitTest.4.inc new file mode 100644 index 00000000..1cadcad0 --- /dev/null +++ b/Magento2/Tests/Legacy/CopyrightUnitTest.4.inc @@ -0,0 +1,7 @@ + 1, + ]; + } + if ($testFile === 'CopyrightUnitTest.2.inc' || $testFile === 'CopyrightUnitTest.3.inc') { + return [ + 3 => 1, + ]; + } + + return []; + } +} diff --git a/Magento2/Tests/Legacy/DiConfigUnitTest.php b/Magento2/Tests/Legacy/DiConfigUnitTest.php index d5dad883..8f3c81f7 100644 --- a/Magento2/Tests/Legacy/DiConfigUnitTest.php +++ b/Magento2/Tests/Legacy/DiConfigUnitTest.php @@ -1,6 +1,6 @@ */Test/* *Test.php + + 5 + warning + 0 diff --git a/PHP_CodeSniffer/Tokenizers/GRAPHQL.php b/PHP_CodeSniffer/Tokenizers/GRAPHQL.php index 8dd5fcae..05c38d50 100644 --- a/PHP_CodeSniffer/Tokenizers/GRAPHQL.php +++ b/PHP_CodeSniffer/Tokenizers/GRAPHQL.php @@ -1,6 +1,6 @@