Sets the state of the scanner (for internal use only).

Returns either the second element from matches or null.

@param array    $matches
@param int|null $head
@param int|null $last

@return string|null
962057
protected function setState($matches = array(), $head = null, $last = null)
    {
        if (isset($head)) {
            $this->head = $head;
        }
        if (isset($last)) {
            $this->last = $last;
        }
        if (is_array($matches)) {
            $this->captures = array_slice($matches, 1);
            if (count($matches)) {
                $this->match = $matches[0];
            } else {
                $this->match = null;
            }
            return $this->match;
        } else {
            return null;
        }
    }
1307535
public function last($object = false)
    {
        $this->prepare();

        $data = $this->_map;
        if (count($data) > 0) {
            return $this->prepareResult(end($data), $object);
        }

        return null;
    }
390986
public function match(array $matches) {
        $params = explode(' ', $matches[1]);
        $paramsNum = count($params);
        $this->params[] = $params[0];

        if (1 == $paramsNum) {
            return sprintf($this->defaultRegx['char'], '+');
        }
        else if (2 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], '+');
        }
        else if (3 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], $params[2] > 0 ? '{' . $params[2] . '}' : '*');
        }
        else if (4 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], '{' . $params[2] . ',' . $params[3] . '}');
        }
    }
81254
public static function last($filters = null, $fields = null)
    {
        $model = new static();

        if (is_string($primaryKey = $model->getPrimaryKey())) {
            $options['order'] = [$primaryKey => SORT_DESC];
        } else {
            throw new BadMethodCallException('infer `:class` order condition for last failed:', ['class' => static::class]);
        }

        $rs = static::query(null, $model)->select($fields)->where($filters)->limit(1)->fetch();
        return isset($rs[0]) ? $rs[0] : null;
    }
497504
public function last($n = 1) {
		if ($this->_count - $n < 0) {
			return NULL;
		}
		return $this->_stack[$this->_count - $n];
	}
131072
public function setMatches($matches)
    {
        foreach ($matches as $key => $dtoData) {
            $this->matches[$key] = new MatchReferenceDto($dtoData);
        }
    
        return $this;
    }
710725
public function last(array $elements, $amount = 1)
    {
        $elements = array_slice($elements, count($elements) - $amount);

        return count($elements) == 1 ? reset($elements) : $elements;
    }
251180
private function getTokenFromMatch($match)
    {
        $value = $match[0];
        $offset = $match[1];

        // If we don't match at the beginning of the string, it fails.
        if ($offset !== 0)
            return null;

        if ($this->value) $value = $this->value;

        return new Token($value, $this->tokenType, $match[0]);
    }
61535
public function poll()
    {
        if ($this->count() === 0) {
            return null;
        }

        $head = $this[$this->index];

        unset($this[$this->index]);
        $this->index++;

        return $head;
    }
903567
public function setLast($last)
    {
        $this->_links[self::LAST][self::HREF] = $last;
        $this->removeEmptyLinks();

        return $this;
    }
652819
public static function head($url, $headers = array(), $options = array()) {
		return self::request($url, $headers, null, self::HEAD, $options);
	}
1102504
public function at($head, ...$tail) {
        if ('@' == $head[0]) $head = $this->marks[$head];
        return $head.self::DS.join(self::DS, $tail);
    }
838053
final public static function head($xs, $n = null, $guard = null)
    {
        return static::first($xs, $n, $guard);
    }
1199246
public function last(callable $conditions = null)
    {
        $array = $this->convertArray($this);

        if ($conditions) {
            $prev = null;

            foreach ($array as $key => $value) {
                if ($conditions($value, $key)) {
                    $prev = $value;
                }
            }

            return $prev;
        }

        return $array[array_key_last($array)];
    }
1116325
public function getMatch(string $pattern, int $flags = 0, int $offset = 0)
	{
		return preg_match($pattern, $this->str, $matches, $flags, $offset) === false ? null : $matches;
	}
1360994
public function lastByName($name) {
        for ($i = count($this->tokens) - 1; $i >= 0; $i--) {
            if ($this->tokens[$i]->getName() === $name) {
                return $this->tokens[$i];
            }
        }

        return null;
    }
471533
public function leftJoin($secondStore,$matching)
    {
        $dstore = new DataStore;
        // join with other datasource to produce new one with above condition
        $firstKeys = array_keys($matching);
        $secondKeys = array_values($matching);
        
        
        $firstMaps = $this->_mapKeyIndex($this->rows, $firstKeys);
        $secondMaps = $this->_mapKeyIndex($secondStore->all(), $secondKeys);

        $secondNullRow = array();
        foreach ($secondStore->first() as $k=>$v) {
            $secondNullRow[$k] = null;
        }
        
        foreach ($firstMaps as $key=>$indices) {
            foreach ($indices as $i) {
                if (isset($secondMaps[$key])) {
                    foreach ($secondMaps[$key] as $j) {
                        $dstore->push(
                            array_merge(
                                $this->rows[$i],
                                $secondStore->get($j)
                            )
                        );
                    }
                } else {
                    $dstore->push(
                        array_merge(
                            $this->rows[$i],
                            $secondNullRow
                        )
                    );
                }
            }
        }

        $columnMeta = array_merge(
            $this->metaData["columns"], 
            $secondStore->meta()["columns"]
        );
        $dstore->meta(array("columns"=>$columnMeta));
        return $dstore;
    }