55namespace PHPCR \Util \CND \Parser ;
66
77use PHPCR \Util \CND \Exception \ParserException ;
8+ use PHPCR \Util \CND \Scanner \GenericToken ;
89use PHPCR \Util \CND \Scanner \GenericToken as Token ;
910use PHPCR \Util \CND \Scanner \TokenQueue ;
1011
@@ -29,12 +30,8 @@ abstract class AbstractParser
2930 * Check the next token without consuming it and return true if it matches the given type and data.
3031 * If the data is not provided (equal to null) then only the token type is checked.
3132 * Return false otherwise.
32- *
33- * @param int $type The expected token type
34- * @param string|null $data The expected data or null
35- * @param bool $ignoreCase whether to do string comparisons case insensitive or sensitive
3633 */
37- protected function checkToken ($ type , string $ data = null , bool $ ignoreCase = false ): bool
34+ protected function checkToken (int $ type , string $ data = null , bool $ ignoreCase = false ): bool
3835 {
3936 if ($ this ->tokenQueue ->isEof ()) {
4037 return false ;
@@ -48,7 +45,7 @@ protected function checkToken($type, string $data = null, bool $ignoreCase = fal
4845
4946 if ($ data && $ token ->getData () !== $ data ) {
5047 if ($ ignoreCase && is_string ($ data ) && is_string ($ token ->getData ())) {
51- return strcasecmp ($ data , $ token ->getData ());
48+ return 0 !== strcasecmp ($ data , $ token ->getData ());
5249 }
5350
5451 return false ;
@@ -89,7 +86,7 @@ protected function expectToken(int $type, string $data = null): Token
8986 if (!$ this ->checkToken ($ type , $ data )) {
9087 throw new ParserException ($ this ->tokenQueue , sprintf ("Expected token [%s, '%s'] " , Token::getTypeName ($ type ), $ data ));
9188 }
92-
89+ \assert ( $ token instanceof GenericToken);
9390 $ this ->tokenQueue ->next ();
9491
9592 return $ token ;
0 commit comments