本文整理汇总了PHP中static::parser方法的典型用法代码示例。如果您正苦于以下问题:PHP static::parser方法的具体用法?PHP static::parser怎么用?PHP static::parser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::parser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParser
/**
* Create a parser for arithmitic expressions
*
* @return Hoa\Compiler\Llk\Parser
*/
protected function getParser()
{
if (!isset(static::$parser)) {
static::$parser = Hoa\Compiler\Llk\Llk::load(new Hoa\File\Read('hoa://Library/Math/Arithmetic.pp'));
}
return static::$parser;
}
示例2: getParser
public static function getParser()
{
if (static::$parser === null) {
static::$parser = new VersionParser();
}
return static::$parser;
}
示例3: _init
/**
* Load Markdown and get it setup.
*
* @return void
*/
public static function _init()
{
if (!class_exists('Michelf\\MarkdownExtra')) {
throw new Exception('The Markdown composer library isn\'t installed. Make sure it\'s in your "composer.json", then run "composer update" to install it!');
}
static::$parser = new \Michelf\MarkdownExtra();
}
示例4: _init
/**
* Load Markdown and get it setup.
*
* @return void
*/
public static function _init()
{
if (!class_exists('MarkdownExtra_Parser', false)) {
include COREPATH . 'vendor' . DS . 'markdown' . DS . 'markdown.php';
}
static::$parser = new MarkdownExtra_Parser();
}
示例5: parse
/**
* Parses PHP Markdown syntax.
*
* @param string $string Markdown syntax string.
*
* @return string String after having been parsed as PHP Markdown.
*
* @throws exception If invalid types are passed through arguments list.
*/
public function parse($string)
{
$this->check_arg_types('string', func_get_args());
if (!isset(static::$parser)) {
static::$parser = new externals\markdown_x();
}
return static::$parser->transform($string);
}
示例6: parser
/**
* Load annotation parser
*
* @param ParserInterface $parser
* @return ParserInterface
*/
public static function parser(ParserInterface $parser = null)
{
if ($parser) {
static::$parser = $parser;
} elseif (!static::$parser) {
static::$parser = new Annotation\KeyValuePairParser();
}
return static::$parser;
}
示例7: getInstance
/**
* {@inheritdoc}
*/
public static function getInstance()
{
// setup an instance if needed
if (!static::$parser) {
if (class_exists('Michelf\\MarkdownExtra')) {
static::$parser = new \Michelf\MarkdownExtra();
} else {
throw new \RuntimeException('FOU-021: Unable to create a Markdown instance. Did you install the "michelf\\php-markdown" composer package?');
}
}
return static::$parser;
}
示例8: parse
public static function parse($text)
{
if (!isset(static::$parser)) {
static::$parser = static::getParser();
}
if (isset(static::$beforeParse)) {
$text = \call_user_func(static::$beforeParse, $text);
}
$xml = static::$parser->parse($text);
if (isset(static::$afterParse)) {
$xml = \call_user_func(static::$afterParse, $xml);
}
return $xml;
}
示例9: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
static::$parser = new CityMapParser();
}
示例10: fromString
/**
* Create a new rule from a string.
*
* @param string $string
* @throws Exception\ParseException
* @return Rule
*/
public static function fromString($string)
{
if (static::$parser === null) {
static::$parser = new Parser();
}
if (!preg_match('(nplurals=(?P<nplurals>\\d+))', $string, $match)) {
throw new Exception\ParseException(sprintf('Unknown or invalid parser rule: %s', $string));
}
$numPlurals = (int) $match['nplurals'];
if (!preg_match('(plural=(?P<plural>[^;\\n]+))', $string, $match)) {
throw new Exception\ParseException(sprintf('Unknown or invalid parser rule: %s', $string));
}
$tree = static::$parser->parse($match['plural']);
$ast = static::createAst($tree);
return new static($numPlurals, $ast);
}
示例11: reset
/**
* Reset the cached parser and renderer
*
* @return void
*/
public static function reset()
{
static::$parser = null;
static::$renderer = null;
}
示例12: setParserFactory
/**
* Set search query parser factory instance.
*
* @param \Sofa\Eloquence\Contracts\Searchable\ParserFactory $factory
*/
public static function setParserFactory(ParserFactory $factory)
{
static::$parser = $factory;
}
示例13: _reset
public static function _reset(Test $test)
{
self::$calls = ['getParser' => 0, 'getRenderer' => 0];
$mock = $test->getMock('stdClass', ['parse', 'render', 'setParameters']);
$mock->expects($test->never())->method('parse');
$mock->expects($test->never())->method('render');
$mock->expects($test->never())->method('setParameters');
static::$parser = null;
static::$_parser = $mock;
static::$renderer = null;
static::$_renderer = $mock;
static::$beforeParse = null;
static::$afterParse = null;
static::$beforeRender = null;
static::$afterRender = null;
static::$beforeUnparse = null;
static::$afterUnparse = null;
}
示例14: getParser
/**
* Gets the Parser implementation.
*
* @return Parser\ParserInterface
*
* @since 2.0.0
*/
private static function getParser()
{
if (is_null(static::$parser)) {
static::$parser = new Parser\DateTimeParser();
}
return static::$parser;
}
示例15: setParser
/**
* Seriously? You want to do your own parsing thang? Ok, set a callback here.
*
* @param mixed $callback any valid callback.
* @return object
*/
public static function setParser($callback)
{
static::$parser = $callback;
return static::chain();
}