@@ -47,14 +47,30 @@ public function disable(): void
4747 $ this ->fixer = null ;
4848 }
4949
50+ /**
51+ * @param array $stream
52+ */
53+ public function processFile (array $ stream ): void
54+ {
55+ foreach ($ stream as $ index => $ token ) {
56+ $ this ->process ($ index , $ stream );
57+ }
58+ }
59+
60+ /**
61+ * @param int $tokenPosition
62+ * @param Token[] $stream
63+ */
64+ abstract protected function process (int $ tokenPosition , array $ stream ): void ;
65+
5066 /**
5167 * @param Token $token
5268 * @param int|array $type
5369 * @param string|array $value
5470 *
5571 * @return bool
5672 */
57- public function isTokenMatching (Token $ token , $ type , $ value = []): bool
73+ protected function isTokenMatching (Token $ token , $ type , $ value = []): bool
5874 {
5975 if (!is_array ($ type )) {
6076 $ type = [$ type ];
@@ -74,7 +90,7 @@ public function isTokenMatching(Token $token, $type, $value = []): bool
7490 *
7591 * @return int|false
7692 */
77- public function findNext ($ type , array $ tokens , int $ start , bool $ exclude = false )
93+ protected function findNext ($ type , array $ tokens , int $ start , bool $ exclude = false )
7894 {
7995 $ i = 0 ;
8096
@@ -97,7 +113,7 @@ public function findNext($type, array $tokens, int $start, bool $exclude = false
97113 *
98114 * @return int|false
99115 */
100- public function findPrevious ($ type , array $ tokens , int $ start , bool $ exclude = false )
116+ protected function findPrevious ($ type , array $ tokens , int $ start , bool $ exclude = false )
101117 {
102118 $ i = 0 ;
103119
@@ -118,7 +134,7 @@ public function findPrevious($type, array $tokens, int $start, bool $exclude = f
118134 *
119135 * @throws Exception
120136 */
121- public function addWarning (string $ message , Token $ token ): void
137+ protected function addWarning (string $ message , Token $ token ): void
122138 {
123139 $ this ->addMessage (Report::MESSAGE_TYPE_WARNING , $ message , $ token );
124140 }
@@ -129,7 +145,7 @@ public function addWarning(string $message, Token $token): void
129145 *
130146 * @throws Exception
131147 */
132- public function addError (string $ message , Token $ token ): void
148+ protected function addError (string $ message , Token $ token ): void
133149 {
134150 $ this ->addMessage (Report::MESSAGE_TYPE_ERROR , $ message , $ token );
135151 }
@@ -142,7 +158,7 @@ public function addError(string $message, Token $token): void
142158 *
143159 * @throws Exception
144160 */
145- public function addFixableWarning (string $ message , Token $ token ): bool
161+ protected function addFixableWarning (string $ message , Token $ token ): bool
146162 {
147163 return $ this ->addFixableMessage (Report::MESSAGE_TYPE_WARNING , $ message , $ token );
148164 }
@@ -155,41 +171,11 @@ public function addFixableWarning(string $message, Token $token): bool
155171 *
156172 * @throws Exception
157173 */
158- public function addFixableError (string $ message , Token $ token ): bool
174+ protected function addFixableError (string $ message , Token $ token ): bool
159175 {
160176 return $ this ->addFixableMessage (Report::MESSAGE_TYPE_ERROR , $ message , $ token );
161177 }
162178
163- /**
164- * @param Token $token
165- *
166- * @return string|null
167- */
168- public function stringifyValue (Token $ token ): ?string
169- {
170- if ($ token ->getType () === Token::STRING_TYPE ) {
171- return $ token ->getValue ();
172- }
173-
174- return '\'' .$ token ->getValue ().'\'' ;
175- }
176-
177- /**
178- * @param array $stream
179- */
180- public function processFile (array $ stream ): void
181- {
182- foreach ($ stream as $ index => $ token ) {
183- $ this ->process ($ index , $ stream );
184- }
185- }
186-
187- /**
188- * @param int $tokenPosition
189- * @param Token[] $stream
190- */
191- abstract protected function process (int $ tokenPosition , array $ stream ): void ;
192-
193179 /**
194180 * @param int $messageType
195181 * @param string $message
0 commit comments