Commit e13f0580 authored by Klaus Purer's avatar Klaus Purer
Browse files

fix(GlobalFunction): Use core version as string and return number of token to...

fix(GlobalFunction): Use core version as string and return number of token to skip files for performance
parent 9514bd49
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class GlobalConstantSniff implements Sniff
     * @param int                         $stackPtr  The position of the current token
     *                                               in the stack passed in $tokens.
     *
     * @return void
     * @return void|int
     */
    public function process(File $phpcsFile, $stackPtr)
    {
@@ -56,7 +56,8 @@ class GlobalConstantSniff implements Sniff

        $coreVersion = Project::getCoreVersion($phpcsFile);
        if ($coreVersion !== '8.x') {
            return;
            // No need to check this file again, mark it as done.
            return ($phpcsFile->numTokens + 1);
        }

        // Allow constants if they are deprecated.
+3 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ class GlobalDefineSniff extends FunctionCall
     * @param int                         $closeBracket The position of the closing
     *                                                  parenthesis in the stack.
     *
     * @return void
     * @return void|int
     */
    public function processFunctionCall(
        File $phpcsFile,
@@ -64,7 +64,8 @@ class GlobalDefineSniff extends FunctionCall

        $coreVersion = Project::getCoreVersion($phpcsFile);
        if ($coreVersion !== '8.x') {
            return;
            // No need to check this file again, mark it as done.
            return ($phpcsFile->numTokens + 1);
        }

        // Allow constants if they are deprecated.
+2 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ class DbQuerySniff extends FunctionCall
     * @param int                         $closeBracket The position of the closing
     *                                                  parenthesis in the stack.
     *
     * @return void
     * @return void|int
     */
    public function processFunctionCall(
        File $phpcsFile,
@@ -57,7 +57,7 @@ class DbQuerySniff extends FunctionCall
    ) {
        // This check only applies to Drupal 7, not Drupal 6.
        if (Project::getCoreVersion($phpcsFile) !== '7.x') {
            return;
            return ($phpcsFile->numTokens + 1);
        }

        $tokens   = $phpcsFile->getTokens();
+3 −3
Original line number Diff line number Diff line
@@ -34,19 +34,19 @@ class HookInitCssSniff extends FunctionDefinition
     * @param int                         $functionPtr The position of the function keyword
     *                                                 in the stack.
     *
     * @return void
     * @return void|int
     */
    public function processFunction(File $phpcsFile, $stackPtr, $functionPtr)
    {
        $fileExtension = strtolower(substr($phpcsFile->getFilename(), -6));
        // Only check in *.module files.
        if ($fileExtension !== 'module') {
            return;
            return ($phpcsFile->numTokens + 1);
        }

        // This check only applies to Drupal 7, not Drupal 6.
        if (Project::getCoreVersion($phpcsFile) !== '7.x') {
            return;
            return ($phpcsFile->numTokens + 1);
        }

        $fileName = substr(basename($phpcsFile->getFilename()), 0, -7);
+3 −3
Original line number Diff line number Diff line
@@ -34,14 +34,14 @@ class InstallTSniff extends FunctionDefinition
     * @param int                         $functionPtr The position of the function keyword
     *                                                 in the stack.
     *
     * @return void
     * @return void|int
     */
    public function processFunction(File $phpcsFile, $stackPtr, $functionPtr)
    {
        $fileExtension = strtolower(substr($phpcsFile->getFilename(), -7));
        // Only check in *.install files.
        if ($fileExtension !== 'install') {
            return;
            return ($phpcsFile->numTokens + 1);
        }

        $fileName = substr(basename($phpcsFile->getFilename()), 0, -8);
@@ -54,7 +54,7 @@ class InstallTSniff extends FunctionDefinition

        // This check only applies to Drupal 7, not Drupal 8.
        if (Project::getCoreVersion($phpcsFile) !== '7.x') {
            return;
            return ($phpcsFile->numTokens + 1);
        }

        // Search in the function body for t() calls.
Loading