@@ -60,10 +60,9 @@ public function process(File $phpcsFile, $stackPtr)
6060 }
6161
6262 if (!$ this ->isVariableInConstructorParameters ($ phpcsFile , $ equalsPtr , $ statementEnd )) {
63- $ next = $ stackPtr ;
64- $ className = $ this ->obtainClassToGetOrCreate ($ phpcsFile , $ next , $ statementEnd );
63+ $ className = $ this ->obtainClassToGetOrCreate ($ phpcsFile , $ stackPtr , $ statementEnd );
6564
66- $ phpcsFile ->addWarning (
65+ $ phpcsFile ->addError (
6766 sprintf ("Class %s needs to be requested in constructor, " .
6867 "otherwise compiler will not be able to find and generate these classes " , $ className ),
6968 $ stackPtr ,
@@ -182,6 +181,8 @@ protected function variableName(string $parameterName): string
182181 }
183182
184183 /**
184+ * Checks if a variable is present in the constructor parameters
185+ *
185186 * @param File $phpcsFile
186187 * @param int $equalsPtr
187188 * @param int $statementEnd
@@ -205,12 +206,14 @@ private function isVariableInConstructorParameters(File $phpcsFile, int $equalsP
205206 }
206207
207208 /**
209+ * Obtain the class inside ObjectManager::getInstance()->get|create()
210+ *
208211 * @param File $phpcsFile
209- * @param $next
212+ * @param int $next
210213 * @param int $statementEnd
211214 * @return string
212215 */
213- private function obtainClassToGetOrCreate (File $ phpcsFile , $ next , int $ statementEnd ): string
216+ private function obtainClassToGetOrCreate (File $ phpcsFile , int $ next , int $ statementEnd ): string
214217 {
215218 while ($ next = $ phpcsFile ->findNext (T_DOUBLE_COLON , $ next + 1 , $ statementEnd )) {
216219 if ($ this ->getNext ($ phpcsFile , $ next , $ statementEnd , T_STRING )['content ' ] === 'class ' ) {
0 commit comments