本文整理汇总了PHP中r8函数的典型用法代码示例。如果您正苦于以下问题:PHP r8函数的具体用法?PHP r8怎么用?PHP r8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r8函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParseAlias_WithAs
public function testParseAlias_WithAs()
{
$access = \vc\Tokens\Access::buildAccess($this->oneTokenReader()->thenAUse->thenSomeSpace->thenANamespacePath('sub1\\sub2')->thenSomeSpace->then(Token::T_AS, 'as')->thenSomeSpace->thenAName('renamed')->thenASemicolon->thenAClass);
$parser = new \vc\Parser\NSpace\Alias(new \vc\Parser\Path());
$this->assertEquals(r8(new \vc\Data\Alias('sub1\\sub2'))->setAlias('renamed'), $parser->parseAlias($access));
$this->assertHasToken(Token::T_CLASS, $access);
}
示例2: testParseConstant_Heredoc
public function testParseConstant_Heredoc()
{
$access = \vc\Tokens\Access::buildAccess($this->oneTokenReader()->thenAConst->thenSomeSpace->thenAName('NAME')->thenSomeSpace->thenAnEquals->thenSomeSpace->thenAHereDoc('contents')->thenASemicolon->thenAClass);
$parser = $this->getConstantParser();
$this->assertEquals(r8(new \vc\Data\Constant('NAME'))->setValue(new \vc\Data\Value('contents', 'string')), $parser->parseConstant($access));
$this->assertHasToken(Token::T_CLASS, $access);
}
示例3: testParseProperty_defaultValue
public function testParseProperty_defaultValue()
{
$access = \vc\Tokens\Access::buildAccess($this->oneTokenReader()->thenAPublic->thenSomeSpace->thenAVariable('$var')->thenSomeSpace->thenAnEquals->thenAnInteger(789)->thenASemicolon);
$sig = new \vc\Data\Signature(120, new \vc\Data\Comment('Note'));
$this->assertEquals(r8(new \vc\Data\Property(120, new \vc\Data\Comment('Note')))->setName('$var')->setValue(new \vc\Data\Value(789, 'int')), $this->getPropertyParser()->parseProperty($sig, $access));
$this->assertEndOfTokens($access);
}
示例4: redirect
/**
* Helper function that redirects the client to another url
*
* If redirect is called twice, the second call will override the first call
*
* @param String $url The URL to forward them to
* @return \r8\Page\Context Returns a self reference
*/
public function redirect($url)
{
$url = trim((string) $url);
r8(new \r8\Validator\URL(\r8\Validator\URL::ALLOW_RELATIVE))->ensure($url);
$this->redirect = $url;
$this->suppress();
return $this;
}
示例5: normalizeLabel
/**
* Normalizes a variable name and checks whether it is properly formatted
*
* @throws \r8\Exception\Argument Thrown if the label is invalid
* @param String $label The variable name being filtered
* @return String
*/
public static function normalizeLabel($label)
{
$label = r8(new \r8\Filter\Variable())->filter($label);
if (!r8(new \r8\Validator\Variable())->isValid($label)) {
throw new \r8\Exception\Argument(0, "Label", "Must be a valid PHP variable name");
}
return $label;
}
示例6: testParse_TagsNestedAtSymbol
public function testParse_TagsNestedAtSymbol()
{
$parser = new \vc\Parser\Comment();
$this->assertEquals(\r8(new \vc\Data\Comment("This is a test comment"))->addTag(new \vc\Data\Tag("tag", "Single @Line"))->addTag(new \vc\Data\Tag("flag", NULL)), $parser->parse('/**
* This is a test comment
* @tag Single @Line
* @flag
*/'));
}
示例7: dump
/**
* A helper method that dumps the current backtrace to the client
*
* @return NULL
*/
public static function dump()
{
if (\r8\Env::request()->isCLI()) {
$format = new \r8\Backtrace\Formatter\Text();
} else {
$format = new \r8\Backtrace\Formatter\HTML();
}
echo r8(new \r8\Backtrace\Formatter($format))->format(self::create()->popEvent());
}
示例8: testParseReference_WithArgs
public function testParseReference_WithArgs()
{
$access = \vc\Tokens\Access::buildAccess($this->oneTokenReader()->thenAFunction->thenSomeSpace->thenAName('MyFunc')->thenOpenParens->thenAVariable('$var')->thenCloseParens->thenAnOpenBlock->thenAnEcho->thenSomeSpace->thenAString('test')->thenASemicolon->thenACloseBlock);
$routine = $this->getMockForAbstractClass('\\vc\\Data\\Routine', array(1));
$this->getFuncParser()->parseRoutine($routine, $access);
$this->assertEquals('MyFunc', $routine->getName());
$this->assertEquals(array(r8(new \vc\Data\Arg())->setVariable('$var')), $routine->getArgs());
$this->assertEndOfTokens($access);
}
示例9: testScan_ParseError
public function testScan_ParseError()
{
$file = new \r8\FileSys\File(__FILE__);
$parser = $this->getMock('\\vc\\iface\\Parser');
$parser->expects($this->once())->method("parse")->with($this->equalTo($file))->will($this->throwException($this->getMock('\\vc\\Tokens\\Exception')));
$storage = $this->getMock('\\vc\\iface\\Storage');
$storage->expects($this->never())->method("store");
$scanner = new \vc\App\Scanner($this->getParseLogger(), $parser, $storage);
$scanner->scan(\r8(new \vc\App\Paths())->addInput($file));
}
示例10: formatAddress
/**
* Returns an e-mail address formatted as such: Name <addr@host.com>
*
* @param String $email The e-mail address
* @param String $name The name of the person associated with the address
* @return String The well formatted address line
*/
public static function formatAddress($email, $name = NULL)
{
$email = r8(new \r8\Filter\Email())->filter($email);
if (!\r8\isVague($name)) {
$name = trim(\r8\str\stripNoPrint($name));
}
if (\r8\isVague($name)) {
return "<" . $email . ">";
} else {
return '"' . addslashes($name) . '" <' . $email . '>';
}
}
示例11: testProcess_WithFlags
public function testProcess_WithFlags()
{
$input = new \r8\CLI\Input(array('test.php', '-a', 'one', 'two'));
$arg = new \r8\CLI\Arg\Many('test');
$form = new \r8\CLI\Form();
$form->addOption(\r8(new \r8\CLI\Option('a', 'test'))->addArg($arg));
$result = $form->process($input);
$this->assertThat($result, $this->isInstanceOf('\\r8\\CLI\\Result'));
$this->assertTrue($result->flagExists('a'));
$this->assertSame(array('one', 'two'), $result->getArgsForFlag('a'));
$this->assertSame(array(array('one', 'two')), $result->getAllArgsForFlag('a'));
}
示例12: __construct
/**
* Constructor...
*
* @param String $method The name of the method to invoke
* @param mixed $args... Any rightward arguments
*/
public function __construct($method)
{
$method = trim((string) $method);
if (!r8(new \r8\Validator\Method())->isValid($method)) {
throw new \r8\Exception\Argument(0, "Method", "Invalid method name");
}
$this->method = $method;
if (func_num_args() > 1) {
$args = func_get_args();
array_shift($args);
$this->setRightByArray($args);
}
}
示例13: cleanSQL
/**
* Cleans up a SQL query for comparison
*
* @param String $sql The SQL to clean
* @return String
*/
public static function cleanSQL($sql)
{
$quoter = new \r8\Quoter();
$quoter->setQuote('"')->setQuote("'")->setQuote("`");
$parsed = $quoter->parse($sql);
$parsed->setIncludeQuoted(FALSE)->setIncludeUnquoted(TRUE);
$keywords = '/\\b(?:' . implode("|", self::$keywords) . ')\\b/i';
$breaks = '/\\b(' . implode("|", self::$breaks) . ')\\b/i';
$parsed->filter(new \r8\Filter\Chain(r8(new \r8\Curry\Call('str_replace'))->setLeft(array("\n", "\r"), " "), r8(new \r8\Curry\Call('\\r8\\str\\stripRepeats'))->setRight(" "), r8(new \r8\Curry\Call('preg_replace_callback'))->setLeft($keywords, function ($value) {
return strtoupper($value[0]);
}), r8(new \r8\Curry\Call('preg_replace'))->setLeft($breaks, "\n\\1")));
return trim($parsed->__toString(), " ;");
}
示例14: getTestForm
/**
* Returns a test form
*
* @return \r8\Form
*/
public function getTestForm()
{
$form = new \r8\Form();
$form->setAction("http://www.example.com/submit.php");
$form->andFormValidator(new \r8\Validator\Fail("Form Error"));
$form->addField(r8(new \r8\Form\Checkbox("CheckboxFld", "Checkbox Label"))->andValidator(new \r8\Validator\Fail("Checkbox Error")));
$form->addField(new \r8\Form\File("FileFld", "File Label"));
$form->addField(r8(new \r8\Form\Hidden("HiddenFld")));
$form->addField(r8(new \r8\Form\Password("PasswordFld", "Password Label"))->andValidator(new \r8\Validator\Fail("Password Error")));
$form->addField(r8(new \r8\Form\Radio("RadioFld", "Radio Label"))->addOption(1234, "Radio Option")->andValidator(new \r8\Validator\Fail("Radio Error")));
$form->addField(r8(new \r8\Form\Select("SelectFld", "Select Label"))->andValidator(new \r8\Validator\Fail("Select Error")));
$form->addField(r8(new \r8\Form\Text("TextFld", "Text Label"))->andValidator(new \r8\Validator\Fail("Text Error")));
$form->addField(r8(new \r8\Form\TextArea("TextAreaFld", "TextArea Label"))->andValidator(new \r8\Validator\Fail("TextArea Error")));
return $form;
}
示例15: getArgParser
/**
* Builds an object for parsing the command line arguments
*
* @return \r8\CLI\Command
*/
public static function getArgParser()
{
$cmd = new \r8\CLI\Command('vocab', 'PHP documentation generator');
$pathFilter = new \r8\Filter\Chain(new \r8\Filter\Printable(), new \r8\Curry\Call('trim'));
$cmd->addArg(new \r8\CLI\Arg\One('Output Directory', $pathFilter, new \r8\Validator\All(\r8(new \r8\Validator\NotEmpty())->addError('Output directory must not be empty'), new \r8\Validator\Callback(function ($dir) {
return is_file($dir) ? 'Path must not be an existing file: ' . $dir : NULL;
}))));
$inputValidator = new \r8\Validator\All(\r8(new \r8\Validator\NotEmpty())->addError('Input path must not be empty'), new \r8\Validator\Callback(function ($path) {
return file_exists($path) ? NULL : 'Path does not exist: ' . $path;
}));
$cmd->addArg(new \r8\CLI\Arg\One('Input Path', $pathFilter, $inputValidator));
$cmd->addArg(new \r8\CLI\Arg\Many('Input Path', $pathFilter, $inputValidator));
// A command form for viewing help/version info
$info = new \r8\CLI\Form();
$cmd->addForm($info);
$info->addOption(\r8(new \r8\CLI\Option('v', 'Outputs version information'))->addFlag('version'));
$info->addOption(\r8(new \r8\CLI\Option('h', 'Displays the help screen'))->addFlag('help'));
return $cmd;
}