11<?php
22
3+ declare (strict_types=1 );
4+
35namespace PHPCR \Util \CND \Parser ;
46
57use PHPCR \Util \CND \Exception \ParserException ;
@@ -23,10 +25,8 @@ abstract class AbstractParser
2325{
2426 /**
2527 * The token queue.
26- *
27- * @var TokenQueue
2828 */
29- protected $ tokenQueue ;
29+ protected TokenQueue $ tokenQueue ;
3030
3131 /**
3232 * Check the next token without consuming it and return true if it matches the given type and data.
@@ -36,10 +36,8 @@ abstract class AbstractParser
3636 * @param int $type The expected token type
3737 * @param string|null $data The expected data or null
3838 * @param bool $ignoreCase whether to do string comparisons case insensitive or sensitive
39- *
40- * @return bool
4139 */
42- protected function checkToken ($ type , $ data = null , $ ignoreCase = false )
40+ protected function checkToken ($ type , string $ data = null , bool $ ignoreCase = false ): bool
4341 {
4442 if ($ this ->tokenQueue ->isEof ()) {
4543 return false ;
@@ -65,11 +63,9 @@ protected function checkToken($type, $data = null, $ignoreCase = false)
6563 /**
6664 * Check if the token data is one of the elements of the data array.
6765 *
68- * @param int $type
69- *
70- * @return bool
66+ * @param string[] $data
7167 */
72- protected function checkTokenIn ($ type , array $ data , $ ignoreCase = false )
68+ protected function checkTokenIn (int $ type , array $ data , bool $ ignoreCase = false ): bool
7369 {
7470 foreach ($ data as $ d ) {
7571 if ($ this ->checkToken ($ type , $ d , $ ignoreCase )) {
@@ -87,11 +83,9 @@ protected function checkTokenIn($type, array $data, $ignoreCase = false)
8783 * @param int $type The expected token type
8884 * @param string|null $data The expected token data or null
8985 *
90- * @return Token
91- *
9286 * @throws ParserException
9387 */
94- protected function expectToken ($ type , $ data = null )
88+ protected function expectToken (int $ type , string $ data = null ): Token
9589 {
9690 $ token = $ this ->tokenQueue ->peek ();
9791
@@ -110,10 +104,8 @@ protected function expectToken($type, $data = null)
110104 *
111105 * @param int $type The expected token type
112106 * @param string|null $data The expected token data or null
113- *
114- * @return bool|Token
115107 */
116- protected function checkAndExpectToken ($ type , $ data = null )
108+ protected function checkAndExpectToken (int $ type , string $ data = null ): bool | Token
117109 {
118110 if ($ this ->checkToken ($ type , $ data )) {
119111 $ token = $ this ->tokenQueue ->peek ();
0 commit comments