private function findHeaderCommentInsertionIndex(Tokens $tokens)
    {
        if ('after_open' === $this->configuration['location']) {
            return 1;
        }

        $index = $tokens->getNextMeaningfulToken(0);
        if (null === $index) {
            // file without meaningful tokens but an open tag, comment should always be placed directly after the open tag
            return 1;
        }

        if (!$tokens[$index]->isGivenKind(T_DECLARE)) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($index);
        if (null === $next || !$tokens[$next]->equals('(')) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->equals([T_STRING, 'strict_types'], false)) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->equals('=')) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->isGivenKind(T_LNUMBER)) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->equals(')')) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->equals(';')) { // don't insert after close tag
            return 1;
        }

        return $next + 1;
    }
private function findHeaderCommentInsertionIndex(Tokens $tokens)
    {
        if ('after_open' === $this->configuration['location']) {
            return 1;
        }

        $index = $tokens->getNextMeaningfulToken(0);
        if (null === $index) {
            // file without meaningful tokens but an open tag, comment should always be placed directly after the open tag
            return 1;
        }

        if (!$tokens[$index]->isGivenKind(T_DECLARE)) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($index);
        if (null === $next || !$tokens[$next]->equals('(')) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->equals([T_STRING, 'strict_types'], false)) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->equals('=')) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->isGivenKind(T_LNUMBER)) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->equals(')')) {
            return 1;
        }

        $next = $tokens->getNextMeaningfulToken($next);
        if (null === $next || !$tokens[$next]->equals(';')) { // don't insert after close tag
            return 1;
        }

        return $next + 1;
    }
private function findHeaderCommentInsertionIndex ( Tokens $ tokens ) { if ( 'after_open' === $ this -> configuration [ 'location' ] ) { return 1 ; } $ index = $ tokens -> getNextMeaningfulToken ( 0 ) ; if ( null === $ index ) { // file without meaningful tokens but an open tag, comment should always be placed directly after the open tag return 1 ; } if ( ! $ tokens [ $ index ] -> isGivenKind ( T_DECLARE ) ) { return 1 ; } $ next = $ tokens -> getNextMeaningfulToken ( $ index ) ; if ( null === $ next || ! $ tokens [ $ next ] -> equals ( '(' ) ) { return 1 ; } $ next = $ tokens -> getNextMeaningfulToken ( $ next ) ; if ( null === $ next || ! $ tokens [ $ next ] -> equals ( [ T_STRING , 'strict_types' ] , false ) ) { return 1 ; } $ next = $ tokens -> getNextMeaningfulToken ( $ next ) ; if ( null === $ next || ! $ tokens [ $ next ] -> equals ( '=' ) ) { return 1 ; } $ next = $ tokens -> getNextMeaningfulToken ( $ next ) ; if ( null === $ next || ! $ tokens [ $ next ] -> isGivenKind ( T_LNUMBER ) ) { return 1 ; } $ next = $ tokens -> getNextMeaningfulToken ( $ next ) ; if ( null === $ next || ! $ tokens [ $ next ] -> equals ( ')' ) ) { return 1 ; } $ next = $ tokens -> getNextMeaningfulToken ( $ next ) ; if ( null === $ next || ! $ tokens [ $ next ] -> equals ( ';' ) ) { // don't insert after close tag return 1 ; } return $ next + 1 ; }
Find the index where the header comment must be inserted.

@param Tokens $tokens

@return int
Find the index where the header comment must be inserted .