本文整理汇总了PHP中Token::setFunction方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::setFunction方法的具体用法?PHP Token::setFunction怎么用?PHP Token::setFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::setFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFunctionAccessors
/**
* @covers spriebsch\PHPca\Token::__construct
* @covers spriebsch\PHPca\Token::setFunction
* @covers spriebsch\PHPca\Token::getFunction
*/
public function testFunctionAccessors()
{
$t = new Token(T_OPEN_TAG, '<?php');
$t->setFunction('Foo\\Bar');
$this->assertEquals('Foo\\Bar', $t->getFunction());
}
示例2: tokenize
//.........这里部分代码省略.........
// If we encounter the opening curly brace of a class (this happens
// when $waitForClassBegin is true), we remember the block level of
// this brace so that we can end the class when we encounter the
// matching closing tag.
if ($waitForClassBegin) {
$classCurlyLevel = $level;
$waitForClassBegin = false;
}
// If we encounter the opening curly brace of an interface (this happens
// when $waitForInterfaceBegin is true), we remember the block level of
// this brace so that we can end the interface when we encounter the
// matching closing tag.
if ($waitForInterfaceBegin) {
$interfaceCurlyLevel = $level;
$waitForInterfaceBegin = false;
}
// If we encounter the opening curly brace of a class (this happens
// when $waitForClassBegin is true), we remember the block level of
// this brace so that we can end the class when we encounter the
// matching closing tag.
if ($waitForFunctionBegin) {
$functionCurlyLevel = $level;
$waitForFunctionBegin = false;
}
}
// Since we assemble any new namespace name in $newNamespace,
// we can safely always set the $namespace.
$tokenObj->setNamespace($namespace);
if ($namespaceStarted) {
$namespaceStarted = false;
$namespace = $newNamespace;
$newNamespace = '';
}
// This also sets the class when we are outside the class,
// which is harmless because we then just set an emtpy string.
if (!$waitForClassBegin) {
if (substr($class, 0, 1) == '\\' || $namespace == '\\') {
$classname = $class;
} else {
if ($class != '') {
$classname = $namespace . '\\' . $class;
} else {
$classname = '';
}
}
$tokenObj->setClass($classname);
}
// This also sets the interface when we are outside the interface,
// which is harmless because we then just set an emtpy string.
if (!$waitForInterfaceBegin) {
if (substr($interface, 0, 1) == '\\' || $namespace == '\\') {
$interfaceName = $interface;
} else {
if ($interface != '') {
$interfaceName = $namespace . '\\' . $interface;
} else {
$interfaceName = '';
}
}
$tokenObj->setInterface($interfaceName);
}
// This also sets the function when we are outside the function,
// which is harmless because we then just set an emtpy string.
if (!$waitForFunctionBegin) {
$tokenObj->setFunction($function);
}
$tokenObj->setBlockLevel($level);
// Closing curly decreases the block level. We do this *after*
// we have set the block leven in the current token, so that
// the closing curly's level matches the level of its opening brace.
if ($tokenObj->getId() == T_CLOSE_CURLY) {
$level--;
// We get away with not dealing with namespace ends, since
// non-namespaced code is not allowed when there is at least
// one namespace in a file. So any namespace either implicitly
// ends at the end of a file, or another namespace starts,
// implicitly "ending" the previous namespace.
// If we are inside a class and the closing brace matches the
// opening brace of that class, the block/class has ended.
if ($class != '' && $tokenObj->getBlockLevel() == $classCurlyLevel) {
$class = '';
$classCurlyLevel = 0;
}
// If we are inside an interface and the closing brace matches the
// opening brace of that interface, the block/interface has ended.
if ($interface != '' && $tokenObj->getBlockLevel() == $interfaceCurlyLevel) {
$interface = '';
$interfaceCurlyLevel = 0;
}
// If we are inside a function and the closing brace matches the
// opening brace of that function, the block/function has ended.
if ($function != '' && $tokenObj->getBlockLevel() == $functionCurlyLevel) {
$function = '';
$functionCurlyLevel = 0;
}
}
$file->add($tokenObj);
}
return $file;
}