77
88final class CamelCaseRouteNameSniff implements Sniff
99{
10- private const CAMEL_CASE_PATTERN = '/^[^-_\s]++$/ ' ;
11-
1210 public const CODE_NOT_CAMEL_CASE_ROUTE_NAME = 'NotCamelCaseRouteName ' ;
1311
12+ private const PATTERN_CAMEL_CASE = '/^[^-_\s]++$/ ' ;
13+
1414 /** @inheritDoc */
1515 public function register (): array
1616 {
1717 return [\T_STRING ];
1818 }
1919
2020 /** @inheritDoc */
21- public function process (File $ phpcsFile , $ stackPtr ): void
21+ public function process (File $ phpcsFile , $ stringPointer ): void
2222 {
2323 $ tokens = $ phpcsFile ->getTokens ();
24- $ currentToken = $ tokens [$ stackPtr ];
24+ $ currentToken = $ tokens [$ stringPointer ];
2525
2626 if ($ currentToken ['content ' ] !== 'name ' ) {
2727 return ;
2828 }
2929
30- $ this ->processRouteName ($ phpcsFile , $ stackPtr , $ tokens );
30+ $ this ->processRouteName ($ phpcsFile , $ stringPointer , $ tokens );
3131 }
3232
3333 /**
3434 * Finds the route name and tests it against the camel case pattern.
3535 * If an issue is found, it adds an error.
3636 * @param array<string, int, array<string>> $tokens
3737 **/
38- public function processRouteName (File $ phpcsFile , int $ stackPtr , array $ tokens ): void
38+ public function processRouteName (File $ phpcsFile , int $ stackPointer , array $ tokens ): void
3939 {
40- $ routeNameLocation = $ phpcsFile ->findNext (\T_CONSTANT_ENCAPSED_STRING , $ stackPtr );
40+ $ routeNameLocation = $ phpcsFile ->findNext (\T_CONSTANT_ENCAPSED_STRING , $ stackPointer );
4141 $ routeName = $ tokens [$ routeNameLocation ]['content ' ];
4242
4343 if (!$ this ->isCamelCase ($ routeName )) {
@@ -58,7 +58,7 @@ private function isCamelCase(string $routeName): bool
5858 $ parts = explode ('. ' , $ routeName );
5959
6060 foreach ($ parts as $ part ) {
61- if (preg_match (self ::CAMEL_CASE_PATTERN , $ part ) !== 1 ) {
61+ if (preg_match (self ::PATTERN_CAMEL_CASE , $ part ) !== 1 ) {
6262 return false ;
6363 }
6464 }
0 commit comments