PHP_CodeSniffer_Fixer::endChangeset PHP Method

endChangeset() public method

Stop recording actions for a changeset, and apply logged changes.
public endChangeset ( ) : boolean
return boolean
    public function endChangeset()
    {
        if ($this->_inConflict === true) {
            return false;
        }
        $this->_inChangeset = false;
        $success = true;
        $applied = array();
        foreach ($this->_changeset as $stackPtr => $content) {
            $success = $this->replaceToken($stackPtr, $content);
            if ($success === false) {
                break;
            } else {
                $applied[] = $stackPtr;
            }
        }
        if ($success === false) {
            // Rolling back all changes.
            foreach ($applied as $stackPtr) {
                $this->revertToken($stackPtr);
            }
            if (PHP_CODESNIFFER_VERBOSITY > 1) {
                @ob_end_clean();
                echo "\t=> Changeset failed to apply" . PHP_EOL;
                ob_start();
            }
        } else {
            if (PHP_CODESNIFFER_VERBOSITY > 1) {
                $fixes = count($this->_changeset);
                @ob_end_clean();
                echo "\t=> Changeset ended: {$fixes} changes applied" . PHP_EOL;
                ob_start();
            }
        }
        $this->_changeset = array();
    }