1515
1616class StandardCompiler implements CompilerInterface
1717{
18- const BOOL_TRUE = '1 ' ;
19- const BOOL_FALSE = '0 ' ;
18+ private const BOOL_TRUE = '1 ' ;
19+ private const BOOL_FALSE = '0 ' ;
2020
21- const LOGICAL_AND = '& ' ;
22- const LOGICAL_OR = '| ' ;
21+ private const LOGICAL_AND = '& ' ;
22+ private const LOGICAL_OR = '| ' ;
2323
24- const OPENING_PARENTHESIS = '( ' ;
25- const CLOSING_PARENTHESIS = ') ' ;
24+ private const OPENING_PARENTHESIS = '( ' ;
25+ private const CLOSING_PARENTHESIS = ') ' ;
2626
27- /** @var string */
28- private $ output = '' ;
29- /** @var int */
30- private $ openParenthesis = 0 ;
31- /** @var int */
32- private $ closedParenthesis = 0 ;
27+ private string $ output = '' ;
28+ private int $ openParenthesis = 0 ;
29+ private int $ closedParenthesis = 0 ;
3330
3431 public function getCompiledRule (): string
3532 {
@@ -48,6 +45,7 @@ private function openParenthesis(): void
4845 $ this ->output .= self ::OPENING_PARENTHESIS ;
4946 }
5047
48+ /** @throws ParserException */
5149 private function closeParenthesis (): void
5250 {
5351 if ($ this ->openParenthesis < 1 ) {
@@ -58,6 +56,7 @@ private function closeParenthesis(): void
5856 $ this ->output .= self ::CLOSING_PARENTHESIS ;
5957 }
6058
59+ /** @throws ParserException */
6160 public function addParentheses (BaseToken $ token ): void
6261 {
6362 if ($ token instanceof TokenOpeningParenthesis) {
@@ -70,6 +69,7 @@ public function addParentheses(BaseToken $token): void
7069 }
7170 }
7271
72+ /** @throws ParserException */
7373 public function addLogical (BaseToken $ token ): void
7474 {
7575 $ lastChar = $ this ->getLastChar ();
@@ -85,6 +85,7 @@ public function addLogical(BaseToken $token): void
8585 }
8686 }
8787
88+ /** @throws MissingOperatorException */
8889 public function addBoolean (bool $ bool ): void
8990 {
9091 $ lastChar = $ this ->getLastChar ();
@@ -105,26 +106,24 @@ private function isIncompleteCondition(): bool
105106 {
106107 $ lastChar = $ this ->getLastChar ();
107108
108- return (
109+ return
109110 $ lastChar === self ::LOGICAL_AND ||
110- $ lastChar === self ::LOGICAL_OR
111- );
111+ $ lastChar === self ::LOGICAL_OR ;
112112 }
113113
114114 private function expectOpeningParenthesis (): bool
115115 {
116116 $ lastChar = $ this ->getLastChar ();
117117
118- return (
118+ return
119119 $ lastChar === '' ||
120120 $ lastChar === self ::LOGICAL_AND ||
121121 $ lastChar === self ::LOGICAL_OR ||
122- $ lastChar === self ::OPENING_PARENTHESIS
123- );
122+ $ lastChar === self ::OPENING_PARENTHESIS ;
124123 }
125124
126125 private function getLastChar (): string
127126 {
128- return substr ($ this ->output , -1 );
127+ return substr ($ this ->output , offset: -1 );
129128 }
130129}
0 commit comments