本文整理汇总了PHP中self::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP self::parse方法的具体用法?PHP self::parse怎么用?PHP self::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类self
的用法示例。
在下文中一共展示了self::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cssToXpath
/**
* @throws SyntaxError When got None for xpath expression
*/
public static function cssToXpath($cssExpr, $prefix = 'descendant-or-self::')
{
if (is_string($cssExpr)) {
if (preg_match('#^\\w+\\s*$#u', $cssExpr, $match)) {
return $prefix . trim($match[0]);
}
if (preg_match('~^(\\w*)#(\\w+)\\s*$~u', $cssExpr, $match)) {
return sprintf("%s%s[@id = '%s']", $prefix, $match[1] ? $match[1] : '*', $match[2]);
}
if (preg_match('#^(\\w*)\\.(\\w+)\\s*$#u', $cssExpr, $match)) {
return sprintf("%s%s[contains(concat(' ', normalize-space(@class), ' '), ' %s ')]", $prefix, $match[1] ? $match[1] : '*', $match[2]);
}
$parser = new self();
$cssExpr = $parser->parse($cssExpr);
}
$expr = $cssExpr->toXpath();
// @codeCoverageIgnoreStart
if (!$expr) {
throw new SyntaxError(sprintf('Got None for xpath expression from %s.', $cssExpr));
}
// @codeCoverageIgnoreEnd
if ($prefix) {
$expr->addPrefix($prefix);
}
return (string) $expr;
}
示例2: Render
/**
* Returns a preview of given Text
*
* @param type $foo
* @return type
*/
public static function Render($markdown)
{
$markdown = CHtml::encode($markdown);
$parser = new self();
$text = $parser->parse($markdown);
return $text;
}
示例3: getAtts
public static function getAtts(&$source)
{
$p = new self();
$res = $p->parse($source);
$source = !empty($p->modifiers) ? ' |' . $p->modifiers : '';
return $res;
}
示例4: style
/**
* Creates a stylesheet link with LESS support
*
* @param string $style file name
* @param array $attributes default attributes
* @param bool $index include the index page
* @param array $imports compare file date for these too, CSS and LESS in style @import
* @return string
*/
public static function style($file, array $attributes = null, $index = false, $imports = null)
{
$imports = (array) $imports;
// Compile only .less files
if (substr_compare($file, '.less', -5, 5, false) === 0) {
$css = substr_replace($file, 'css', -4);
$compiled = is_file($css) ? filemtime($css) : 0;
try {
// Check if imported files have changed
$compile = filemtime($file) > $compiled;
if (!$compile && !empty($imports)) {
foreach ($imports as $import) {
if (filemtime($import) > $compiled) {
$compile = true;
break;
}
}
}
// Compile LESS
if ($compile) {
$compiler = new self($file);
file_put_contents($css, $compiler->parse());
}
$file = $css;
} catch (Exception $e) {
Kohana::$log->add(Kohana::ERROR, __METHOD__ . ': Error compiling LESS file ' . $file . ', ' . $e->getMessage());
}
}
return HTML::style($file . '?' . filemtime($file), $attributes, $index);
}
示例5: match
public static function match($method)
{
if (Strings::startsWith($method, 'findBy')) {
$dynamicFinder = new self($method);
$dynamicFinder->parse();
return $dynamicFinder;
}
return null;
}
示例6: test
/**
* Simple entry point for command-line testing
*/
static function test($text)
{
try {
$ce = new self($text);
$ce->parse();
} catch (ConfEditorParseError $e) {
return $e->getMessage() . "\n" . $e->highlight($text);
}
return "OK";
}
示例7: fromFile
public static function fromFile($file)
{
if (!empty($file) && is_file($file)) {
$basePath = pathinfo($file, PATHINFO_DIRNAME);
$parser = new self($basePath);
return $parser->parse(file_get_contents($file));
} else {
throw new RuntimeException('Could not load json schema ' . $file);
}
}
示例8: quickParse
/**
* Quick parse modules feed.
*
* @param string $url XML feed URL
* @param string $cache_dir Cache directoy or null for no cache
* @param boolean $force Force query repository
* @return object Self instance
*/
public static function quickParse($url, $cache_dir = null, $force = false)
{
$parser = new self();
if ($cache_dir) {
$parser->setCacheDir($cache_dir);
}
if ($force) {
$parser->setForce($force);
}
return $parser->parse($url);
}
示例9: find_or_create_by_uastring
public static function find_or_create_by_uastring($ua_string)
{
$ua_string = trim($ua_string);
if (!strlen($ua_string)) {
return NULL;
}
$agent = self::find_one_by_user_agent($ua_string);
if (!$agent) {
$agent = new self();
$agent->user_agent = $ua_string;
$agent->parse()->save();
}
return $agent;
}
示例10: getBlock
protected function getBlock()
{
if (!$this->testCurrentString('[[')) {
throw new \Exception('Block start expected!');
}
$this->nextChar();
$this->nextChar();
$blockSignature = $this->getBlockSignature();
$block = $this->blockSignatureParser->parse($blockSignature);
$position = $this->getNextNotWhiteSpacePosition($this->position);
if ($this->testString($position, '{{')) {
$this->skipWhiteSpace();
$content = $this->getBlockContent();
// todo: block can be parsed in one pass
$clone = new self($this->blockSignatureParser);
$result = $clone->parse($content);
$block['markup'] = $result;
}
return $block;
}
示例11: parsePreToken
private function parsePreToken($preToken)
{
$token = null;
$matches = [];
foreach ($this->regEx as $tokenName => $rgx) {
if (preg_match($rgx, $preToken, $matches)) {
$token = $this->createToken($tokenName, $matches['value']);
break;
}
}
if (is_null($token)) {
$token = $this->createToken(self::ILEGAL, $preToken);
} else {
if (array_key_exists('inner', $matches)) {
$this->addToken($token);
$tokenizer = new self();
$stream = $tokenizer->parse($matches['inner']);
$this->addTokens($stream);
} else {
$this->addToken($token);
}
}
return $this->currentToken;
}
示例12: run
/**
* Shortcut to instantiate, tokenize, parse and evaluate
*
* @param string $expression
* @param array $values
* @return boolean
*/
public static function run($expression, $values)
{
$evaluator = new self();
$evaluator->parse($evaluator->tokenize($expression));
return $evaluator->evaluate($values);
}
示例13: fromString
public static function fromString($s)
{
$parser = new self($s);
return $parser->parse();
}
示例14: combine
/**
* @param $in
* @param $root_url
*
* @return string
*/
public static function combine($in, $root_url)
{
$css = new self($in, $root_url);
return $css->parse();
}
示例15: parseBlock
private function parseBlock($offset, $yaml, $exceptionOnInvalidType, $objectSupport, $objectForMap)
{
$skippedLineNumbers = $this->skippedLineNumbers;
foreach ($this->locallySkippedLineNumbers as $lineNumber) {
if ($lineNumber < $offset) {
continue;
}
$skippedLineNumbers[] = $lineNumber;
}
$parser = new self($offset, $this->totalNumberOfLines, $skippedLineNumbers);
$parser->refs =& $this->refs;
return $parser->parse($yaml, $exceptionOnInvalidType, $objectSupport, $objectForMap);
}