findSequence([[T_STRING, 'define'], '(', [T_CONSTANT_ENCAPSED_STRING, "'MAUTIC_TABLE_PREFIX'"]]); if ($matches) { $begin_defined = $tokens->getPrevTokenOfKind(array_key_first($matches), [[T_STRING, 'defined']]); $begin_if = $tokens->getPrevTokenOfKind($begin_defined, [[T_IF, 'if']]); if ($begin_defined) { if ((int) $begin_if >= $begin_defined - 4) { $begin = $begin_if; $end_token = ['}']; } else { $begin = $begin_defined; $end_token = [';']; } $end = $tokens->getNextTokenOfKind(array_key_last($matches), $end_token); foreach (range($begin, $end) as $id) { $tokens->clearAt($id); } $tokens->removeLeadingWhitespace($end); } } } public function isCandidate(Tokens $tokens): bool { return $tokens->isTokenKindFound(T_CONSTANT_ENCAPSED_STRING); } public function getDefinition(): FixerDefinitionInterface { return new FixerDefinition( 'Test should not define the `MAUTIC_TABLE_PREFIX` const.', [new CodeSample("getPathname()); } /** * run before the whitespace cleanup. */ public function getPriority(): int { return 1; } }