@@ -14,14 +14,14 @@ class PhpCodeStore extends CodeStore
1414 *
1515 * @var int[]
1616 */
17- private $ defaultLevel = [];
17+ private array $ defaultLevel = [];
1818
1919 /**
2020 * The heredoc identifier.
2121 *
2222 * @var string|null
2323 */
24- private $ heredocIdentifier ;
24+ private ? string $ heredocIdentifier = null ;
2525
2626 //--------------------------------------------------------------------------------------------------------------------
2727 /**
@@ -52,7 +52,7 @@ protected function indentationMode(string $line): int
5252
5353 $ mode |= $ this ->indentationModeHeredoc ($ line );
5454 $ mode |= $ this ->indentationModeSwitch ($ line );
55- $ mode |= $ this ->indentationModeBLock ($ line );
55+ $ mode |= $ this ->indentationModeBlock ($ line );
5656
5757 return $ mode ;
5858 }
@@ -83,7 +83,7 @@ private function defaultLevelIncrement(): void
8383
8484 //--------------------------------------------------------------------------------------------------------------------
8585 /**
86- * Returns true if the indent level of the current switch statement (if any) is zero. Otherwise, returns false .
86+ * Returns whether the indent level of the current switch statement (if any) is zero.
8787 */
8888 private function defaultLevelIsZero (): bool
8989 {
@@ -104,14 +104,14 @@ private function indentationModeBlock(string $line): int
104104
105105 if ($ this ->heredocIdentifier !==null ) return $ mode ;
106106
107- if (substr ($ line , - 1 , 1 )== '{ ' )
107+ if (str_ends_with ($ line , '{ ' ) )
108108 {
109109 $ mode |= self ::C_INDENT_INCREMENT_AFTER ;
110110
111111 $ this ->defaultLevelIncrement ();
112112 }
113113
114- if (substr ($ line , 0 , 1 )== '} ' )
114+ if (str_starts_with ($ line , '} ' ) )
115115 {
116116 $ this ->defaultLevelDecrement ();
117117
@@ -132,6 +132,7 @@ private function indentationModeBlock(string $line): int
132132
133133 //--------------------------------------------------------------------------------------------------------------------
134134 /**
135+ * Returns the indentation mode based on a line of code starting a heredoc.
135136 *
136137 * @param string $line The line of code.
137138 *
@@ -176,19 +177,19 @@ private function indentationModeSwitch(string $line): int
176177
177178 if ($ this ->heredocIdentifier !==null ) return $ mode ;
178179
179- if (substr ($ line , 0 , 5 )== 'case ' )
180+ if (str_starts_with ($ line , 'case ' ) )
180181 {
181182 $ mode |= self ::C_INDENT_INCREMENT_AFTER ;
182183 }
183184
184- if (substr ($ line , 0 , 8 )== 'default: ' )
185+ if (str_starts_with ($ line , 'default: ' ) )
185186 {
186187 $ this ->defaultLevel [] = 0 ;
187188
188189 $ mode |= self ::C_INDENT_INCREMENT_AFTER ;
189190 }
190191
191- if (substr ($ line , 0 , 6 )== 'break; ' )
192+ if (str_starts_with ($ line , 'break; ' ) )
192193 {
193194 $ mode |= self ::C_INDENT_DECREMENT_AFTER ;
194195 }
0 commit comments