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

Breadcrumb

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

function Scanner::setState

Sets the current scanner state

Parameters

array $state State:

Return value

$this

File

vendor/mck89/peast/lib/Peast/Syntax/Scanner.php, line 570

Class

Scanner
Base class for scanners.

Namespace

Peast\Syntax

Code

public function setState($state) {
    if ($this->registerTokens) {
        
        //Check if tokens have been added
        if (isset($this->tokens[$state["tokensNum"]])) {
            
            //Remove all added tokens
            for ($i = count($this->tokens) - 1; $i >= $state["tokensNum"]; $i--) {
                array_pop($this->tokens);
            }
        }
        unset($state["tokensNum"]);
    }
    
    //Emit the ResetState event and pass the given state
    $this->eventsEmitter && $this->eventsEmitter
        ->fire("ResetState", array(
        &$state,
    ));
    foreach ($state as $key => $value) {
        $this->{$key} = $value;
    }
    return $this;
}

API Navigation

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