PHP_CodeSniffer_Fixer::substrToken PHP Method

substrToken() public method

Replace the content of a token with a part of its current content.
public substrToken ( integer $stackPtr, integer $start, integer $length = null ) : boolean
$stackPtr integer The position of the token in the token stack.
$start integer The first character to keep.
$length integer The number of chacters to keep. If NULL, the content of the token from $start to the end of the content is kept.
return boolean If the change was accepted.
    public function substrToken($stackPtr, $start, $length = null)
    {
        $current = $this->getTokenContent($stackPtr);
        if ($length === null) {
            $newContent = substr($current, $start);
        } else {
            $newContent = substr($current, $start, $length);
        }
        return $this->replaceToken($stackPtr, $newContent);
    }