Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squiz/ValidClassName: bug fix - improve comment handling
Noticed while working on something else. If there would be a comment between the OO keyword and the declared name, the sniff could throw false positives with unhelpful error messages, like: ``` 193 | ERROR | Class name "/*comment*/" is not in PascalCase format (Squiz.Classes.ValidClassName.NotCamelCaps) 194 | ERROR | Trait name "//comment" is not in PascalCase format (Squiz.Classes.ValidClassName.NotCamelCaps) 196 | ERROR | Interface name "// phpcs:ignore Stnd.Cat.SniffName -- just testing" is not in PascalCase format | | (Squiz.Classes.ValidClassName.NotCamelCaps) 199 | ERROR | Class name "CommentsShouldBeIgnoredValid/*comment*/" is not in PascalCase format (Squiz.Classes.ValidClassName.NotCamelCaps) 200 | ERROR | Interface name "annotations_should_be_ignored_InvalidName" is not in PascalCase format (Squiz.Classes.ValidClassName.NotCamelCaps) ``` Fixed now by: 1. Ignoring any comments between the OO keyword and the name. 2. Not including comments directly following a name in the name to be evaluated. Includes tests. Includes minor error message precision fix - the error will now be thrown on the name which is being flagged as invalid, not on the OO keyword.
- Loading branch information