本文整理汇总了PHP中SqlParser\Context::isWhitespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::isWhitespace方法的具体用法?PHP Context::isWhitespace怎么用?PHP Context::isWhitespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlParser\Context
的用法示例。
在下文中一共展示了Context::isWhitespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsWhitespace
public function testIsWhitespace()
{
$this->assertTrue(Context::isWhitespace(" "));
$this->assertTrue(Context::isWhitespace("\r"));
$this->assertTrue(Context::isWhitespace("\n"));
$this->assertTrue(Context::isWhitespace("\t"));
$this->assertFalse(Context::isWhitespace("a"));
$this->assertFalse(Context::isWhitespace("\\b"));
$this->assertFalse(Context::isWhitespace("\\u1000"));
}
示例2: extract
//.........这里部分代码省略.........
if ($this->query[$i] === "\n") {
$this->status = 0;
}
continue;
} elseif ($this->status === static::STATUS_COMMENT_C) {
// C-like comments end in */.
if ($this->query[$i - 1] === '*' && $this->query[$i] === '/') {
$this->status = 0;
}
continue;
}
/*
* Checking if a string started.
*/
if ($this->query[$i] === '\'') {
$this->status = static::STATUS_STRING_SINGLE_QUOTES;
$this->current .= $this->query[$i];
continue;
} elseif ($this->query[$i] === '"') {
$this->status = static::STATUS_STRING_DOUBLE_QUOTES;
$this->current .= $this->query[$i];
continue;
} elseif ($this->query[$i] === '`') {
$this->status = static::STATUS_STRING_BACKTICK;
$this->current .= $this->query[$i];
continue;
}
/*
* Checking if a comment started.
*/
if ($this->query[$i] === '#') {
$this->status = static::STATUS_COMMENT_BASH;
continue;
} elseif ($i + 2 < $len && $this->query[$i] === '-' && $this->query[$i + 1] === '-' && Context::isWhitespace($this->query[$i + 2])) {
$this->status = static::STATUS_COMMENT_SQL;
continue;
} elseif ($i + 2 < $len && $this->query[$i] === '/' && $this->query[$i + 1] === '*' && $this->query[$i + 2] !== '!') {
$this->status = static::STATUS_COMMENT_C;
continue;
}
/*
* Handling `DELIMITER` statement.
*
* The code below basically checks for
* `strtoupper(substr($this->query, $i, 9)) === 'DELIMITER'`
*
* This optimization makes the code about 3 times faster.
*/
if ($i + 9 < $len && ($this->query[$i] === 'D' || $this->query[$i] === 'd') && ($this->query[$i + 1] === 'E' || $this->query[$i + 1] === 'e') && ($this->query[$i + 2] === 'L' || $this->query[$i + 2] === 'l') && ($this->query[$i + 3] === 'I' || $this->query[$i + 3] === 'i') && ($this->query[$i + 4] === 'M' || $this->query[$i + 4] === 'm') && ($this->query[$i + 5] === 'I' || $this->query[$i + 5] === 'i') && ($this->query[$i + 6] === 'T' || $this->query[$i + 6] === 't') && ($this->query[$i + 7] === 'E' || $this->query[$i + 7] === 'e') && ($this->query[$i + 8] === 'R' || $this->query[$i + 8] === 'r') && Context::isWhitespace($this->query[$i + 9])) {
// Saving the current index to be able to revert any parsing
// done in this block.
$iBak = $i;
$i += 9;
// Skipping `DELIMITER`.
// Skipping whitespaces.
while ($i < $len && Context::isWhitespace($this->query[$i])) {
++$i;
}
// Parsing the delimiter.
$delimiter = '';
while ($i < $len && !Context::isWhitespace($this->query[$i])) {
$delimiter .= $this->query[$i++];
}
// Checking if the delimiter definition ended.
if ($delimiter != '' && ($i < $len && Context::isWhitespace($this->query[$i]) || $i === $len && $end)) {
// Saving the delimiter.
示例3: parseWhitespace
/**
* Parses a whitespace.
*
* @return Token
*/
public function parseWhitespace()
{
$token = $this->str[$this->last];
if (!Context::isWhitespace($token)) {
return null;
}
while (++$this->last < $this->len && Context::isWhitespace($this->str[$this->last])) {
$token .= $this->str[$this->last];
}
--$this->last;
return new Token($token, Token::TYPE_WHITESPACE);
}