From f99972e0d1ff1cdea8f5ee2f0288d23c90c7a36c Mon Sep 17 00:00:00 2001 From: Matthias Zeis Date: Thu, 18 Apr 2019 18:59:56 +0200 Subject: [PATCH 1/2] #86: Fix AbstractApiSniff for classes without comment --- Magento2/Sniffs/Classes/AbstractApiSniff.php | 3 +++ ...ApiUnitTest.inc => AbstractApiUnitTest.1.inc} | 1 - Magento2/Tests/Classes/AbstractApiUnitTest.2.inc | 6 ++++++ Magento2/Tests/Classes/AbstractApiUnitTest.php | 16 +++++++++++----- 4 files changed, 20 insertions(+), 6 deletions(-) rename Magento2/Tests/Classes/{AbstractApiUnitTest.inc => AbstractApiUnitTest.1.inc} (99%) create mode 100644 Magento2/Tests/Classes/AbstractApiUnitTest.2.inc diff --git a/Magento2/Sniffs/Classes/AbstractApiSniff.php b/Magento2/Sniffs/Classes/AbstractApiSniff.php index ac5836d8..13947186 100644 --- a/Magento2/Sniffs/Classes/AbstractApiSniff.php +++ b/Magento2/Sniffs/Classes/AbstractApiSniff.php @@ -48,6 +48,9 @@ public function process(File $phpcsFile, $stackPtr) } $commentStartPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr - 1, 0); + if ($commentStartPtr === false) { + return; + } $commentCloserPtr = $tokens[$commentStartPtr]['comment_closer']; for ($i = $commentStartPtr; $i <= $commentCloserPtr; $i++) { diff --git a/Magento2/Tests/Classes/AbstractApiUnitTest.inc b/Magento2/Tests/Classes/AbstractApiUnitTest.1.inc similarity index 99% rename from Magento2/Tests/Classes/AbstractApiUnitTest.inc rename to Magento2/Tests/Classes/AbstractApiUnitTest.1.inc index 92d5edee..178611fb 100644 --- a/Magento2/Tests/Classes/AbstractApiUnitTest.inc +++ b/Magento2/Tests/Classes/AbstractApiUnitTest.1.inc @@ -28,7 +28,6 @@ class FooBar implements FooInterface } - /** * Class Bar */ diff --git a/Magento2/Tests/Classes/AbstractApiUnitTest.2.inc b/Magento2/Tests/Classes/AbstractApiUnitTest.2.inc new file mode 100644 index 00000000..5cd3d5b0 --- /dev/null +++ b/Magento2/Tests/Classes/AbstractApiUnitTest.2.inc @@ -0,0 +1,6 @@ + 1, - 23 => 1 - ]; + if ($testFile === 'AbstractApiUnitTest.1.inc') { + return [ + 14 => 1, + 23 => 1 + ]; + } + + return []; + + } } From d3041b112c6dcb1b151b977429b9338ae737f559 Mon Sep 17 00:00:00 2001 From: Matthias Zeis Date: Thu, 18 Apr 2019 19:11:39 +0200 Subject: [PATCH 2/2] Fix coding standard errors --- Magento2/Tests/Classes/AbstractApiUnitTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Magento2/Tests/Classes/AbstractApiUnitTest.php b/Magento2/Tests/Classes/AbstractApiUnitTest.php index 5176b375..d1c6eebe 100644 --- a/Magento2/Tests/Classes/AbstractApiUnitTest.php +++ b/Magento2/Tests/Classes/AbstractApiUnitTest.php @@ -33,7 +33,5 @@ public function getWarningList($testFile = '') } return []; - - } }