Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FunctionDeclarationSniff.php

function FunctionDeclarationSniff::isMultiLineDeclaration

Determine if this is a multi-line function declaration.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:

int $stackPtr The position of the current token: in the stack passed in $tokens.

int $openBracket The position of the opening bracket: in the stack passed in $tokens.

array $tokens The stack of tokens that make up: the file.

Return value

bool

1 call to FunctionDeclarationSniff::isMultiLineDeclaration()
FunctionDeclarationSniff::process in vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
Processes this test, when one of its tokens is encountered.
1 method overrides FunctionDeclarationSniff::isMultiLineDeclaration()
MultiLineFunctionDeclarationSniff::isMultiLineDeclaration in vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php
Determine if this is a multi-line function declaration.

File

vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php, line 222

Class

FunctionDeclarationSniff

Namespace

PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions

Code

public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tokens) {
    $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
    if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) {
        return true;
    }
    // Closures may use the USE keyword and so be multi-line in this way.
    if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
        $use = $phpcsFile->findNext(T_USE, $closeBracket + 1, $tokens[$stackPtr]['scope_opener']);
        if ($use !== false) {
            // If the opening and closing parenthesis of the use statement
            // are also on the same line, this is a single line declaration.
            $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $use + 1);
            $close = $tokens[$open]['parenthesis_closer'];
            if ($tokens[$open]['line'] !== $tokens[$close]['line']) {
                return true;
            }
        }
    }
    return false;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal