本文整理汇总了PHP中Parser::process方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::process方法的具体用法?PHP Parser::process怎么用?PHP Parser::process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser::process方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Load a RiveScript document from a file.
*
* @param array|string $file
*/
public function load($files)
{
$files = !is_array($files) ? (array) $files : $files;
foreach ($files as $file) {
$this->tree = $this->parser->process($file, $this->tree);
}
}
示例2: Parser
<?php
/*
* @ author: Alexandr Kozyr;
* @ email: kozyr1av@gmail.com;
* this file aggregates all moves for parsing and saving data to db
*/
if (isset($argv[0])) {
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');
ini_set('max_execution_time', '3600');
require_once 'class/DbConnect.class.php';
require_once 'class/Parser.class.php';
$test = new Parser(DbConnect::MySqlConnecton($config));
$test->process();
} else {
die('Script should start with shell');
}
示例3: process
/**
* @param string $apiTitle
* @param string $directoryToScan
* @param bool $recursion
*
* @return array
* @throws \Com\PaulDevelop\Library\Common\ArgumentException
* @throws \Com\PaulDevelop\Library\Common\TypeCheckException
*/
public function process($apiTitle = '', $directoryToScan = '', $recursion = true)
{
//
$responseSchemes = new AnnotationCollection();
// action
$ramlDocument = '#%RAML 0.8' . PHP_EOL;
$isFirst = true;
$fileList = self::getFiles($directoryToScan, $recursion);
foreach ($fileList as $file) {
$fileAnnotations = Parser::process($file);
if (($titleAnnotation = self::findAnnotation($fileAnnotations->getFileLevel(), 'title')) == null || ($titleAnnotation = self::findAnnotation($fileAnnotations->getFileLevel(), 'title')) !== null && $titleAnnotation->getParameter()['title']->getValue() != $apiTitle) {
continue;
}
if ($isFirst) {
$isFirst = false;
$fileLevelAnnotations = $fileAnnotations->getFileLevel();
// title
if (($annotation = $this->findAnnotation($fileLevelAnnotations, 'title')) !== null) {
$ramlDocument .= self::stringifySimpleAnnotation($annotation);
}
// version
if (($annotation = $this->findAnnotation($fileLevelAnnotations, 'version')) !== null) {
$ramlDocument .= self::stringifySimpleAnnotation($annotation);
}
// base uri
if (($annotation = $this->findAnnotation($fileLevelAnnotations, 'baseUri')) !== null) {
$ramlDocument .= self::stringifySimpleAnnotation($annotation);
}
// protocols
if (count($annotations = $this->findAnnotations($fileLevelAnnotations, 'protocol')) > 0) {
$ramlDocument .= 'protocols: [';
$protocolString = '';
/** @var Annotation $annotation */
foreach ($annotations as $annotation) {
$protocolString .= ($protocolString != '' ? ', ' : '') . $annotation->getParameter()['protocol']->getValue();
}
$ramlDocument .= $protocolString . ']' . PHP_EOL;
}
// security schemes
if (count($annotations = $this->findAnnotations($fileLevelAnnotations, 'securityScheme')) > 0) {
$ramlDocument .= 'securitySchemes:' . PHP_EOL;
/** @var Annotation $annotation */
foreach ($annotations as $annotation) {
$ramlDocument .= ' - ' . $annotation->getParameter()['name']->getValue() . ':' . PHP_EOL;
$ramlDocument .= ' type: ' . $annotation->getParameter()['type']->getValue() . PHP_EOL;
}
}
if (count($annotations = $this->findAnnotations($fileLevelAnnotations, 'responseScheme')) > 0) {
// store response schemes for later use
/** @var Annotation $annotation */
foreach ($annotations as $annotation) {
$responseSchemes->add($annotation, $annotation->getParameter()['name']->getValue());
}
}
}
/** @var AnnotationCollection $annotations */
foreach ($fileAnnotations->getMethodsLevel() as $methodAnnotations) {
$ramlDocument .= PHP_EOL;
// resource
if (($annotation = $this->findAnnotation($methodAnnotations, 'resource')) !== null) {
$ramlDocument .= $annotation->getParameter()['resource']->getValue() . ':' . PHP_EOL;
}
// http verb
$httpVerb = 'GET';
if (($annotation = $this->findAnnotation($methodAnnotations, 'httpVerb')) !== null) {
$httpVerb = $annotation->getParameter()['verb']->getValue();
$ramlDocument .= ' ' . strtolower($annotation->getParameter()['verb']->getValue()) . ':' . PHP_EOL;
}
// description
if (($annotation = $this->findAnnotation($methodAnnotations, 'description')) !== null) {
$ramlDocument .= ' description: ' . $annotation->getParameter()['description']->getValue() . PHP_EOL;
}
// secured by
if (count($annotations = $this->findAnnotations($methodAnnotations, 'securedBy')) > 0) {
$ramlDocument .= ' securedBy: [';
$securedByString = '';
/** @var Annotation $annotation */
foreach ($annotations as $annotation) {
$securedByString .= ($securedByString != '' ? ', ' : '') . $annotation->getParameter()['scheme']->getValue();
}
$ramlDocument .= $securedByString . ']' . PHP_EOL;
}
if ($httpVerb == 'GET') {
// foreach parameter
if (count($annotations = $this->findAnnotations($methodAnnotations, 'parameter')) > 0) {
$ramlDocument .= ' queryParameters:' . PHP_EOL;
/** @var Annotation $annotation */
foreach ($annotations as $annotation) {
$ramlDocument .= ' ' . $annotation->getParameter()['name']->getValue() . ':' . PHP_EOL;
// display name
if (($parameter = $annotation->getParameter()['displayName']) != null) {
//.........这里部分代码省略.........
示例4: isset
header('Content-Type: text/html; charset=utf-8');
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=utf-8");
$query = isset($_GET['q']) ? $_GET['q'] : 'Пушкин';
$format = isset($_GET['f']) ? $_GET['f'] : 'json';
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/'));
include 'Logger.php';
include 'BrowserAdapter.php';
include 'BrowserCurl.php';
include 'simplehtmldom/simple_html_dom.php';
include 'Parser.php';
$br = new Ap_Browser_BrowserCurl();
$url = 'http://193.27.243.130/cgi-bin/irbis64r_91/cgiirbis_64.exe';
$params = array('X_S21P03' => 'K=', 'I21DBN' => 'IBIS', 'P21DBN' => 'IBIS', 'X_S21STR' => $query, 'X_S21P01' => '4', 'X_S21P02' => '1', 'X_S21LOG' => '1', 'S21COLORTERMS' => '1', 'S21FMT' => 'infow_wh', 'S21STN' => '1', 'S21CNR' => '20', 'S21REF' => '3', 'C21COM' => 'S', 'C21COM1' => 'Поиск');
$br->post($url, $params);
$html = str_get_html($br->getResponseText());
$res = array();
// find all link
foreach ($html->find('.advanced tr td[width="95%"]') as $e) {
$str = str_replace('<br>', "\n", $e->innertext);
$str = strip_tags($str, '<b></b>');
$res[] = $str;
}
$parser = new Parser();
$parsedResult = $parser->process($res);
if ($format == 'json') {
echo json_encode($parsedResult);
} else {
Logger::dump($parsedResult);
}