diff --git a/Magento2/Sniffs/GraphQL/ValidTypeNameSniff.php b/Magento2/Sniffs/GraphQL/ValidTypeNameSniff.php index 602225fe..83e38ed5 100644 --- a/Magento2/Sniffs/GraphQL/ValidTypeNameSniff.php +++ b/Magento2/Sniffs/GraphQL/ValidTypeNameSniff.php @@ -32,7 +32,10 @@ public function process(File $phpcsFile, $stackPtr) //compose entity name by making use of the next strings that we find until we hit a non-string token $name = ''; for ($i=$stackPtr+1; $tokens[$i]['code'] === T_STRING; ++$i) { - $name .= $tokens[$i]['content']; + /** + * @see \PHP_CodeSniffer\Tokenizers\GRAPHQL::tokenize Removing EOL character artificially added to token + */ + $name .= rtrim($tokens[$i]['content']); } $valid = Common::isCamelCaps($name, true, true, false); diff --git a/Magento2/Tests/GraphQL/ValidTypeNameUnitTest.graphqls b/Magento2/Tests/GraphQL/ValidTypeNameUnitTest.graphqls index 1fba0386..848b77d1 100644 --- a/Magento2/Tests/GraphQL/ValidTypeNameUnitTest.graphqls +++ b/Magento2/Tests/GraphQL/ValidTypeNameUnitTest.graphqls @@ -1,5 +1,7 @@ # Valid type names. type ValidCamelCaseType {} +type ValidCamelCaseTypeNewLineBrace +{} interface ValidCamelCaseInterface {} enum ValidCamelCaseEnum {} diff --git a/Magento2/Tests/GraphQL/ValidTypeNameUnitTest.php b/Magento2/Tests/GraphQL/ValidTypeNameUnitTest.php index b1fd29b9..3948537a 100644 --- a/Magento2/Tests/GraphQL/ValidTypeNameUnitTest.php +++ b/Magento2/Tests/GraphQL/ValidTypeNameUnitTest.php @@ -23,21 +23,21 @@ class ValidTypeNameUnitTest extends AbstractGraphQLSniffUnitTestCase protected function getErrorList() { return [ - 7 => 1, - 8 => 1, 9 => 1, 10 => 1, 11 => 1, 12 => 1, - 15 => 1, - 16 => 1, + 13 => 1, + 14 => 1, 17 => 1, - 21 => 1, + 18 => 1, + 19 => 1, 23 => 1, 25 => 1, - 35 => 1, - 39 => 1, - 43 => 1, + 27 => 1, + 37 => 1, + 41 => 1, + 45 => 1, ]; }