本文整理汇总了PHP中Token::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::getValue方法的具体用法?PHP Token::getValue怎么用?PHP Token::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetters
public function testGetters()
{
$token = new Token(Token::IDENTIFIER, 'foobar', 7);
$this->assertNotEquals(Token::TEXT, $token->getType());
$this->assertEquals(Token::IDENTIFIER, $token->getType());
$this->assertNotEquals('foo', $token->getValue());
$this->assertEquals('foobar', $token->getValue());
$this->assertNotEquals(6, $token->getLine());
$this->assertEquals(7, $token->getLine());
}
示例2: isOperator
/**
* Check if the token is operator
*
* @param Token $token
* @return boolean
*/
public function isOperator(Token $token)
{
if (T_STRING == $token->getType()) {
if (isset($this->byPass[$token->getValue()])) {
return false;
}
return isset($this->operatorsStrings[$token->getValue()]);
}
return isset($this->operators[$token->getType()]);
}
示例3: testWithersReturnNewModifiedInstance
public function testWithersReturnNewModifiedInstance()
{
$value = 'bob';
$newValue = 'alice';
$type = new TokenType(TokenType::DYNAMIC_ARRAY_TYPE);
$token = new Token($value, $type);
$newToken = $token->withValue($newValue);
$this->assertEquals($value, $token->getValue());
$this->assertEquals($type->getValue(), $token->getType());
$this->assertInstanceOf(Token::class, $newToken);
$this->assertEquals($newValue, $newToken->getValue());
$this->assertEquals($type->getValue(), $newToken->getType());
}
示例4: addToken
public function addToken(Token $token)
{
switch ($token->getType()) {
// This block is basically a whitelist of token types permissible before
// seeing a T_FUNCTION. If we hit anything else, the docblock isn't
// attached to something we care about.
case T_DOC_COMMENT:
$this->docblock = $token;
// fall through
// fall through
case T_WHITESPACE:
case T_PUBLIC:
case T_PROTECTED:
case T_PRIVATE:
case T_STATIC:
case T_ABSTRACT:
break;
case Token::SINGLE_CHARACTER:
if ($token->is('{')) {
$this->has_started = true;
$this->depth++;
} elseif ($token->is('}')) {
$this->depth--;
}
break;
case T_FUNCTION:
$this->track = false;
break;
case T_STRING:
if (!$this->has_started) {
$this->name = $token->getValue();
}
// fall through
// fall through
default:
if ($this->track) {
$this->no_op = true;
}
break;
}
if ($this->has_started) {
$this->body[] = $token;
} else {
$this->head[] = $token;
}
return $this;
}
示例5: Token
<?php
use Tester\Assert;
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/Token.php";
//valid value
$value = str_repeat('BeerNowThere0sATemporarySolution', 2);
$tokenFoo = new Token($value);
Assert::same("BeerNowThere0sATemporarySolutionBeerNowThere0sATemporarySolution", $tokenFoo->getValue());
//compare with another object of same value
$tokenBar = new Token("BeerNowThere0sATemporarySolutionBeerNowThere0sATemporarySolution");
$areSame = $tokenBar->sameValueAs($tokenFoo);
Assert::true($areSame);
//compare with another object of different value
$value = str_repeat('CraftBeerLovers0', 4);
//
$tokenPub = new Token($value);
Assert::same("CraftBeerLovers0CraftBeerLovers0CraftBeerLovers0CraftBeerLovers0", $tokenPub->getValue());
$areSame = $tokenPub->sameValueAs($tokenBar);
Assert::false($areSame);
//invalid values
Assert::exception(function () {
new Token(null);
}, InvalidArgumentException::class, "Token must be not empty");
Assert::exception(function () {
new Token("InvalidTokenLength123456789");
}, InvalidArgumentException::class, "Token must be 64 characters long");
Assert::exception(function () {
$value = str_repeat('?!@#$%^&', 8);
new Token($value);
}, InvalidArgumentException::class, "Token must be valid base_64");
示例6: setToken
/**
* Initialise class from a token
* @access public
*/
function setToken($tokenstr)
{
$ok = false;
$token = new Token();
if ($token->parse($tokenstr)) {
$ok = $token->hasValue("e") && $token->hasValue("n") && $token->hasValue("s");
if ($ok) {
$this->service = $token->getValue("s");
$this->nateastings = $token->getValue("e") * $this->divisor[$this->service];
$this->natnorthings = $token->getValue("n") * $this->divisor[$this->service];
$this->width = $this->tilewidth[$this->service];
if ($token->hasValue("r")) {
$this->epoch = $token->getValue("r");
}
}
}
return $ok;
}
示例7: reconsumeCurrentTokenAsRegexp
/**
* Tries to reconsume the current token as a regexp if possible
*
* @return Token|null
*/
public function reconsumeCurrentTokenAsRegexp()
{
$token = $this->getToken();
$value = $token ? $token->getValue() : null;
//Check if the token starts with "/"
if (!$value || $value[0] !== "/") {
return null;
}
//Reset the scanner position to the token's start position
$startPosition = $token->getLocation()->getStart();
$this->index = $startPosition->getIndex();
$this->column = $startPosition->getColumn();
$this->line = $startPosition->getLine();
$buffer = "/";
$this->index++;
$this->column++;
$inClass = false;
while (true) {
//In a characters class the delmiter "/" is allowed without escape,
//so the characters class must be closed before closing the regexp
$stops = $inClass ? array("]") : array("/", "[");
$tempBuffer = $this->consumeUntil($stops);
if ($tempBuffer === null) {
if ($inClass) {
return $this->error("Unterminated character class in regexp");
} else {
return $this->error("Unterminated regexp");
}
}
$buffer .= $tempBuffer[0];
if ($tempBuffer[1] === "/") {
break;
} else {
$inClass = $tempBuffer[1] === "[";
}
}
//Flags
while (($char = $this->charAt()) !== null) {
$lower = strtolower($char);
if ($lower >= "a" && $lower <= "z") {
$buffer .= $char;
$this->index++;
$this->column++;
} else {
break;
}
}
//If next token has already been parsed and it's a bracket exclude it
//from the count of open brackets
if ($this->nextToken) {
$nextVal = $this->nextToken->getValue();
if (isset($this->brackets[$nextVal]) && isset($this->openBrackets[$nextVal])) {
if ($this->brackets[$nextVal]) {
$this->openBrackets[$nextVal]++;
} else {
$this->openBrackets[$nextVal]--;
}
}
$this->nextToken = null;
}
//Replace the current token with a regexp token
$token = new Token(Token::TYPE_REGULAR_EXPRESSION, $buffer);
$this->currentToken = $token->setStartPosition($startPosition)->setEndPosition($this->getPosition(true));
return $this->currentToken;
}
示例8: equals
/**
* Equals
*
* @param \PHP\Manipulator\Token $token
* @return boolean
*/
public function equals(Token $token, $strict = false)
{
$match = false;
if ($this->getType() === $token->getType() && $this->getValue() === $token->getValue()) {
$match = true;
}
if (true === $strict && $this->_linenumber !== $token->getLinenumber()) {
$match = false;
}
return $match;
}
示例9: setToken
/**
* Initialise class from a token
* @access public
*/
function setToken($tokenstr, $allowWithoutMosaic = false)
{
$ok = false;
$token = new Token();
if ($token->parse($tokenstr)) {
$ok = $token->hasValue("x") && $token->hasValue("y") && $token->hasValue("w") && $token->hasValue("h") && $token->hasValue("s") && ($allowWithoutMosaic || $token->hasValue("f"));
if ($ok) {
$this->setOrigin($token->getValue("x"), $token->getValue("y"));
$this->setMosaicSize($token->getValue("w"), $token->getValue("h"));
$this->setScale($token->getValue("s"));
$this->setMosaicFactor($token->hasValue("f") ? $token->getValue("f") : 2);
$this->type_or_user = $token->hasValue("t") ? $token->getValue("t") : 0;
$this->palette = $token->hasValue("p") ? $token->getValue("p") : 0;
} else {
$info = "";
foreach ($token->data as $name => $value) {
$info .= "{$name}={$value} ";
}
$this->_err("setToken: missing elements ({$info})");
}
} else {
$this->_err("setToken: parse failure");
}
return $ok;
}
示例10: serveImageFromToken
function serveImageFromToken($tokenstr)
{
$token = new Token();
if ($token->parse($tokenstr)) {
$this->width = $token->getValue("w");
$this->height = $token->getValue("h");
$this->gridimage_id = $token->getValue("i");
$image = new GridImage($this->gridimage_id);
} else {
header("HTTP/1.0 403 Bad Token");
}
}
示例11: buildSymbolToken
protected function buildSymbolToken(Token $token, Character $char)
{
$token->setType(TokenType::SYMBOL);
$token->setValue($char->getValue());
switch ($char->getValue()) {
// case ';':
// break;
case '(':
case ')':
break;
case '=':
case '!':
case '>':
case '<':
case '+':
case '-':
case '/':
case '*':
$prevchar = $char->getValue();
$char = $this->getCharacter();
if ($char->isEOL()) {
throw new SyntaxException($char->getLine(), $char->getColumn(), 'Broken expression "' . $prevchar . $char->getValue() . '"', __FILE__, __LINE__);
} elseif ($prevchar == '/' && $char->getValue() == '/') {
$token->setValue($prevchar . $char->getValue());
} elseif ($char->getValue() == '=') {
$token->setValue($prevchar . $char->getValue());
} elseif ($prevchar == '+' && $char->getValue() == '+') {
$token->setValue($prevchar . $char->getValue());
} elseif ($prevchar == '-' && $char->getValue() == '-') {
$token->setValue($prevchar . $char->getValue());
} else {
$this->ungetCharacter();
}
break;
case '&':
case '|':
$prevchar = $char->getValue();
$char = $this->getCharacter();
if ($char->isEOL()) {
throw new SyntaxException($char->getLine(), $char->getColumn(), 'Invalid expression "' . $prevchar . '"', __FILE__, __LINE__);
} elseif ($prevchar == $char->getValue()) {
$token->setValue($prevchar . $token->getValue());
} else {
$this->ungetCharacter();
}
break;
default:
break;
}
return $token;
}
示例12: inEmptyRequestInt
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
require_once 'geograph/global.inc.php';
require_once 'geograph/gridimage.class.php';
require_once 'geograph/gridsquare.class.php';
require_once 'geograph/searchcriteria.class.php';
init_session();
$rater = inEmptyRequestInt('rater', 0);
$i = inEmptyRequestInt('i', 0);
$l = inEmptyRequestInt('l', 0);
if (isset($_REQUEST['t'])) {
$ok = false;
$token = new Token();
if ($token->parse($_REQUEST['t'])) {
if ($token->hasValue("i")) {
$i = $token->getValue("i");
}
if ($token->hasValue("p")) {
$_GET['page'] = $token->getValue("p");
}
}
}
if (isset($_REQUEST['debug']) && $USER->hasPerm("admin")) {
$token = new Token();
$token->setValue("i", $i);
if (!empty($_GET['page'])) {
$token->setValue("p", $_GET['page']);
}
print $token->getToken();
}
if (isset($_GET['l']) && isset($_SESSION['gameToken'])) {
示例13: GeographPage
require_once 'geograph/token.class.php';
require_once 'geograph/gazetteer.class.php';
init_session();
$smarty = new GeographPage();
$template = 'submit_popup.tpl';
$cacheid = '';
$square = new GridSquare();
if (!$USER->hasPerm("basic") || empty($_GET['t'])) {
$smarty->assign('error', "unable to access page");
$smarty->display($template, $cacheid);
exit;
}
$token = new Token();
if ($token->parse($_GET['t'])) {
if ($token->hasValue("g")) {
$gridref = $token->getValue("g");
}
if ($token->hasValue("p")) {
$photographer_gridref = $token->getValue("p");
}
if ($token->hasValue("v")) {
$view_direction = $token->getValue("v");
}
}
$grid_given = false;
$grid_ok = false;
$pgrid_given = false;
$pgrid_ok = false;
if (!empty($gridref)) {
$grid_given = true;
$grid_ok = $square->setByFullGridRef($gridref, true);
示例14: floor
$ab = floor($i % 10000);
$cacheid = "search|{$ab}|{$i}.{$pg}";
if (!empty($_GET['count'])) {
$engine->countOnly = 1;
$cacheid .= ".";
}
//what style should we use?
$style = $USER->getStyle();
$cacheid .= $style;
if (!empty($_GET['legacy'])) {
$cacheid .= "X";
$smarty->assign('legacy', 1);
}
if (!empty($_GET['t'])) {
$token = new Token();
if ($token->parse($_GET['t']) && $token->getValue("i") == $i) {
$smarty->clear_cache($template, $cacheid);
}
}
if (!$smarty->is_cached($template, $cacheid)) {
dieUnderHighLoad(3, 'search_unavailable.tpl');
$smarty->assign_by_ref('google_maps_api_key', $CONF['google_maps_api_key']);
$smarty->register_function("searchbreak", "smarty_function_searchbreak");
$smarty->register_function("votestars", "smarty_function_votestars");
$smarty->assign('maincontentclass', 'content_photo' . $style);
if ($display == 'reveal') {
$engine->noCache = true;
$engine->criteria->limit4 = 1;
//only works in GB
}
$smarty->assign('querytime', $engine->Execute($pg));
示例15: GeographPage
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
require_once 'geograph/global.inc.php';
require_once 'geograph/imagelist.class.php';
init_session();
$smarty = new GeographPage();
customGZipHandlerStart();
$USER->mustHavePerm("basic");
$template = 'submissions.tpl';
$max_gridimage_id = 0;
$count = 0;
if (!empty($_GET['next'])) {
$token = new Token();
if ($token->parse($_GET['next']) && $token->hasValue("id")) {
$max_gridimage_id = intval($token->getValue("id"));
$count = intval($token->getValue("c"));
} else {
die("invalid token");
}
}
$ab = floor($USER->user_id / 10000);
$cacheid = "user{$ab}|{$USER->user_id}|{$max_gridimage_id}";
//what style should we use?
$style = $USER->getStyle();
if ($smarty->caching) {
$smarty->caching = 2;
// lifetime is per cache
$smarty->cache_lifetime = 300;
customExpiresHeader(300, false, true);
}