ApiGen + woodocs template + grunt task

This commit is contained in:
Mike Jolley 2014-02-14 14:29:30 +00:00 committed by Coen Jacobs
parent 6d0a31b491
commit c22309fd51
417 changed files with 101977 additions and 1 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ Thumbs.db
.settings*
sftp-config.json
/deploy/
/wc-apidocs/
# Ignore all log files except for .htaccess
/logs/*

View File

@ -126,6 +126,12 @@ module.exports = function( grunt ){
'php index.php generate',
'sed -i "" "s/\\/\\/exit( \'Locked\' );/exit( \'Locked\' );/g" index.php',
].join( '&&' )
},
apigen: {
command: [
'cd apigen/',
'php apigen.php --source ../ --destination ../wc-apidocs --download yes --template-config ./templates/woodocs/config.neon --title "WooCommerce" --exclude "*/mijireh/*" --exclude "*/includes/libraries/*" --exclude "*/i18n/*" --exclude "*/node_modules/*" --exclude "*/deploy/*"',
].join( '&&' )
}
},
@ -139,7 +145,8 @@ module.exports = function( grunt ){
'!Gruntfile.js',
'!sftp-config.json',
'!package.json',
'!node_modules/**'
'!node_modules/**',
'!wc-apidocs/**'
],
dest: 'deploy',
expand: true,
@ -175,6 +182,10 @@ module.exports = function( grunt ){
'shell:generatepot'
]);
grunt.registerTask( 'docs', [
'shell:apigen'
]);
grunt.registerTask( 'dev', [
'default',
'shell:txpull',

301
apigen/ApiGen/Backend.php Normal file
View File

@ -0,0 +1,301 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use TokenReflection, TokenReflection\IReflectionConstant, TokenReflection\IReflectionFunction, TokenReflection\Broker, TokenReflection\Resolver;
use InvalidArgumentException, RuntimeException;
/**
* Customized TokenReflection broker backend.
*
* Adds internal classes from @param, @var, @return, @throws annotations as well
* as parent classes to the overall class list.
*/
class Backend extends Broker\Backend\Memory
{
/**
* Generator instance.
*
* @var \ApiGen\Generator
*/
private $generator;
/**
* Cache of processed token streams.
*
* @var array
*/
private $fileCache = array();
/**
* Determines if token streams should be cached in filesystem.
*
* @var boolean
*/
private $cacheTokenStreams = false;
/**
* Constructor.
*
* @param \ApiGen\Generator $generator Generator instance
* @param boolean $cacheTokenStreams If token stream should be cached
*/
public function __construct(Generator $generator, $cacheTokenStreams = false)
{
$this->generator = $generator;
$this->cacheTokenStreams = $cacheTokenStreams;
}
/**
* Destructor.
*
* Deletes all cached token streams.
*/
public function __destruct()
{
foreach ($this->fileCache as $file) {
unlink($file);
}
}
/**
* Adds a file to the backend storage.
*
* @param \TokenReflection\Stream\StreamBase $tokenStream Token stream
* @param \TokenReflection\ReflectionFile $file File reflection object
* @return \TokenReflection\Broker\Backend\Memory
*/
public function addFile(TokenReflection\Stream\StreamBase $tokenStream, TokenReflection\ReflectionFile $file)
{
if ($this->cacheTokenStreams) {
$this->fileCache[$file->getName()] = $cacheFile = tempnam(sys_get_temp_dir(), 'trc');
file_put_contents($cacheFile, serialize($tokenStream));
}
parent::addFile($tokenStream, $file);
return $this;
}
/**
* Returns an array of tokens for a particular file.
*
* @param string $fileName File name
* @return \TokenReflection\Stream
* @throws \RuntimeException If the token stream could not be returned.
*/
public function getFileTokens($fileName)
{
try {
if (!$this->isFileProcessed($fileName)) {
throw new InvalidArgumentException('File was not processed');
}
$realName = Broker::getRealPath($fileName);
if (!isset($this->fileCache[$realName])) {
throw new InvalidArgumentException('File is not in the cache');
}
$data = @file_get_contents($this->fileCache[$realName]);
if (false === $data) {
throw new RuntimeException('Cached file is not readable');
}
$file = @unserialize($data);
if (false === $file) {
throw new RuntimeException('Stream could not be loaded from cache');
}
return $file;
} catch (\Exception $e) {
throw new RuntimeException(sprintf('Could not return token stream for file %s', $fileName), 0, $e);
}
}
/**
* Prepares and returns used class lists.
*
* @return array
*/
protected function parseClassLists()
{
$allClasses = array(
self::TOKENIZED_CLASSES => array(),
self::INTERNAL_CLASSES => array(),
self::NONEXISTENT_CLASSES => array()
);
$declared = array_flip(array_merge(get_declared_classes(), get_declared_interfaces()));
foreach ($this->getNamespaces() as $namespace) {
foreach ($namespace->getClasses() as $name => $trClass) {
$class = new ReflectionClass($trClass, $this->generator);
$allClasses[self::TOKENIZED_CLASSES][$name] = $class;
if (!$class->isDocumented()) {
continue;
}
foreach (array_merge($trClass->getParentClasses(), $trClass->getInterfaces()) as $parentName => $parent) {
if ($parent->isInternal()) {
if (!isset($allClasses[self::INTERNAL_CLASSES][$parentName])) {
$allClasses[self::INTERNAL_CLASSES][$parentName] = $parent;
}
} elseif (!$parent->isTokenized()) {
if (!isset($allClasses[self::NONEXISTENT_CLASSES][$parentName])) {
$allClasses[self::NONEXISTENT_CLASSES][$parentName] = $parent;
}
}
}
$this->generator->checkMemory();
}
}
foreach ($allClasses[self::TOKENIZED_CLASSES] as $class) {
if (!$class->isDocumented()) {
continue;
}
foreach ($class->getOwnMethods() as $method) {
$allClasses = $this->processFunction($declared, $allClasses, $method);
}
foreach ($class->getOwnProperties() as $property) {
$annotations = $property->getAnnotations();
if (!isset($annotations['var'])) {
continue;
}
foreach ($annotations['var'] as $doc) {
foreach (explode('|', preg_replace('~\\s.*~', '', $doc)) as $name) {
if ($name = rtrim($name, '[]')) {
$name = Resolver::resolveClassFQN($name, $class->getNamespaceAliases(), $class->getNamespaceName());
$allClasses = $this->addClass($declared, $allClasses, $name);
}
}
}
}
$this->generator->checkMemory();
}
foreach ($this->getFunctions() as $function) {
$allClasses = $this->processFunction($declared, $allClasses, $function);
}
array_walk_recursive($allClasses, function(&$reflection, $name, Generator $generator) {
if (!$reflection instanceof ReflectionClass) {
$reflection = new ReflectionClass($reflection, $generator);
}
}, $this->generator);
return $allClasses;
}
/**
* Processes a function/method and adds classes from annotations to the overall class array.
*
* @param array $declared Array of declared classes
* @param array $allClasses Array with all classes parsed so far
* @param \ApiGen\ReflectionFunction|\TokenReflection\IReflectionFunctionBase $function Function/method reflection
* @return array
*/
private function processFunction(array $declared, array $allClasses, $function)
{
static $parsedAnnotations = array('param', 'return', 'throws');
$annotations = $function->getAnnotations();
foreach ($parsedAnnotations as $annotation) {
if (!isset($annotations[$annotation])) {
continue;
}
foreach ($annotations[$annotation] as $doc) {
foreach (explode('|', preg_replace('~\\s.*~', '', $doc)) as $name) {
if ($name) {
$name = Resolver::resolveClassFQN(rtrim($name, '[]'), $function->getNamespaceAliases(), $function->getNamespaceName());
$allClasses = $this->addClass($declared, $allClasses, $name);
}
}
}
}
foreach ($function->getParameters() as $param) {
if ($hint = $param->getClassName()) {
$allClasses = $this->addClass($declared, $allClasses, $hint);
}
}
return $allClasses;
}
/**
* Adds a class to list of classes.
*
* @param array $declared Array of declared classes
* @param array $allClasses Array with all classes parsed so far
* @param string $name Class name
* @return array
*/
private function addClass(array $declared, array $allClasses, $name)
{
$name = ltrim($name, '\\');
if (!isset($declared[$name]) || isset($allClasses[self::TOKENIZED_CLASSES][$name])
|| isset($allClasses[self::INTERNAL_CLASSES][$name]) || isset($allClasses[self::NONEXISTENT_CLASSES][$name])
) {
return $allClasses;
}
$parameterClass = $this->getBroker()->getClass($name);
if ($parameterClass->isInternal()) {
$allClasses[self::INTERNAL_CLASSES][$name] = $parameterClass;
foreach (array_merge($parameterClass->getInterfaces(), $parameterClass->getParentClasses()) as $parentClass) {
if (!isset($allClasses[self::INTERNAL_CLASSES][$parentName = $parentClass->getName()])) {
$allClasses[self::INTERNAL_CLASSES][$parentName] = $parentClass;
}
}
} elseif (!$parameterClass->isTokenized() && !isset($allClasses[self::NONEXISTENT_CLASSES][$name])) {
$allClasses[self::NONEXISTENT_CLASSES][$name] = $parameterClass;
}
return $allClasses;
}
/**
* Returns all constants from all namespaces.
*
* @return array
*/
public function getConstants()
{
$generator = $this->generator;
return array_map(function(IReflectionConstant $constant) use ($generator) {
return new ReflectionConstant($constant, $generator);
}, parent::getConstants());
}
/**
* Returns all functions from all namespaces.
*
* @return array
*/
public function getFunctions()
{
$generator = $this->generator;
return array_map(function(IReflectionFunction $function) use ($generator) {
return new ReflectionFunction($function, $generator);
}, parent::getFunctions());
}
}

602
apigen/ApiGen/Config.php Normal file
View File

@ -0,0 +1,602 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use Nette\Utils\Neon;
/**
* Configuration processing class.
*/
class Config
{
/**
* Options.
*
* @var array
*/
private $options = array();
/**
* Parsed configuration.
*
* @var array
*/
private $config = array();
/**
* Default configuration.
*
* @var array
*/
private static $defaultConfig = array(
'config' => '',
'source' => array(),
'destination' => '',
'extensions' => array('php'),
'exclude' => array(),
'skipDocPath' => array(),
'skipDocPrefix' => array(),
'charset' => array('auto'),
'main' => '',
'title' => '',
'baseUrl' => '',
'googleCseId' => '',
'googleCseLabel' => '',
'googleAnalytics' => '',
'templateConfig' => '',
'allowedHtml' => array('b', 'i', 'a', 'ul', 'ol', 'li', 'p', 'br', 'var', 'samp', 'kbd', 'tt'),
'groups' => 'auto',
'autocomplete' => array('classes', 'constants', 'functions'),
'accessLevels' => array('public', 'protected'),
'internal' => false,
'php' => true,
'tree' => true,
'deprecated' => false,
'todo' => false,
'download' => false,
'sourceCode' => true,
'report' => '',
'undocumented' => '',
'wipeout' => true,
'quiet' => false,
'progressbar' => true,
'colors' => true,
'updateCheck' => true,
'debug' => false
);
/**
* File or directory path options.
*
* @var array
*/
private static $pathOptions = array(
'config',
'source',
'destination',
'templateConfig',
'report'
);
/**
* Possible values for options.
*
* @var array
*/
private static $possibleOptionsValues = array(
'groups' => array('auto', 'namespaces', 'packages', 'none'),
'autocomplete' => array('classes', 'constants', 'functions', 'methods', 'properties', 'classconstants'),
'accessLevels' => array('public', 'protected', 'private')
);
/**
* Initializes default configuration.
*/
public function __construct()
{
$templateDir = self::isInstalledByPear() ? '@data_dir@' . DIRECTORY_SEPARATOR . 'ApiGen' : realpath(__DIR__ . DIRECTORY_SEPARATOR . '..');
self::$defaultConfig['templateConfig'] = $templateDir . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'config.neon';
self::$defaultConfig['colors'] = 'WIN' !== substr(PHP_OS, 0, 3);
$this->config = self::$defaultConfig;
}
/**
* Processes command line options.
*
* @param array $options
* @return \ApiGen\Config
*/
public function processCliOptions(array $options)
{
while ($option = current($options)) {
if (preg_match('~^--([a-z][-a-z]*[a-z])(?:=(.+))?$~', $option, $matches) || preg_match('~^-([a-z])=?(.*)~', $option, $matches)) {
$name = $matches[1];
if (!empty($matches[2])) {
$value = $matches[2];
} else {
$next = next($options);
if (false === $next || '-' === $next{0}) {
prev($options);
$value = '';
} else {
$value = $next;
}
}
$this->options[$name][] = $value;
}
next($options);
}
$this->options = array_map(function($value) {
return 1 === count($value) ? $value[0] : $value;
}, $this->options);
// Compatibility with ApiGen 1.0
foreach (array('config', 'source', 'destination') as $option) {
if (isset($this->options[$option{0}]) && !isset($this->options[$option])) {
$this->options[$option] = $this->options[$option{0}];
}
unset($this->options[$option{0}]);
}
return $this;
}
/**
* Prepares configuration.
*
* @return \ApiGen\Config
* @throws \ApiGen\ConfigException If something in configuration is wrong.
*/
public function prepare()
{
// Command line options
$cli = array();
$translator = array();
foreach ($this->options as $option => $value) {
$converted = preg_replace_callback('~-([a-z])~', function($matches) {
return strtoupper($matches[1]);
}, $option);
$cli[$converted] = $value;
$translator[$converted] = $option;
}
$unknownOptions = array_keys(array_diff_key($cli, self::$defaultConfig));
if (!empty($unknownOptions)) {
$originalOptions = array_map(function($option) {
return (1 === strlen($option) ? '-' : '--') . $option;
}, array_values(array_diff_key($translator, self::$defaultConfig)));
$message = count($unknownOptions) > 1
? sprintf('Unknown command line options "%s"', implode('", "', $originalOptions))
: sprintf('Unknown command line option "%s"', $originalOptions[0]);
throw new ConfigException($message);
}
// Config file
$neon = array();
if (empty($this->options) && $this->defaultConfigExists()) {
$this->options['config'] = $this->getDefaultConfigPath();
}
if (isset($this->options['config']) && is_file($this->options['config'])) {
$neon = Neon::decode(file_get_contents($this->options['config']));
foreach (self::$pathOptions as $option) {
if (!empty($neon[$option])) {
if (is_array($neon[$option])) {
foreach ($neon[$option] as $key => $value) {
$neon[$option][$key] = $this->getAbsolutePath($value);
}
} else {
$neon[$option] = $this->getAbsolutePath($neon[$option]);
}
}
}
$unknownOptions = array_keys(array_diff_key($neon, self::$defaultConfig));
if (!empty($unknownOptions)) {
$message = count($unknownOptions) > 1
? sprintf('Unknown config file options "%s"', implode('", "', $unknownOptions))
: sprintf('Unknown config file option "%s"', $unknownOptions[0]);
throw new ConfigException($message);
}
}
// Merge options
$this->config = array_merge(self::$defaultConfig, $neon, $cli);
// Compatibility with old option name "undocumented"
if (!isset($this->config['report']) && isset($this->config['undocumented'])) {
$this->config['report'] = $this->config['undocumented'];
unset($this->config['undocumented']);
}
foreach (self::$defaultConfig as $option => $valueDefinition) {
if (is_array($this->config[$option]) && !is_array($valueDefinition)) {
throw new ConfigException(sprintf('Option "%s" must be set only once', $option));
}
if (is_bool($this->config[$option]) && !is_bool($valueDefinition)) {
throw new ConfigException(sprintf('Option "%s" expects value', $option));
}
if (is_bool($valueDefinition) && !is_bool($this->config[$option])) {
// Boolean option
$value = strtolower($this->config[$option]);
if ('on' === $value || 'yes' === $value || 'true' === $value || '' === $value) {
$value = true;
} elseif ('off' === $value || 'no' === $value || 'false' === $value) {
$value = false;
}
$this->config[$option] = (bool) $value;
} elseif (is_array($valueDefinition)) {
// Array option
$this->config[$option] = array_unique((array) $this->config[$option]);
foreach ($this->config[$option] as $key => $value) {
$value = explode(',', $value);
while (count($value) > 1) {
array_push($this->config[$option], array_shift($value));
}
$this->config[$option][$key] = array_shift($value);
}
$this->config[$option] = array_filter($this->config[$option]);
}
// Check posssible values
if (!empty(self::$possibleOptionsValues[$option])) {
$values = self::$possibleOptionsValues[$option];
if (is_array($valueDefinition)) {
$this->config[$option] = array_filter($this->config[$option], function($value) use ($values) {
return in_array($value, $values);
});
} elseif (!in_array($this->config[$option], $values)) {
$this->config[$option] = '';
}
}
}
// Unify character sets
$this->config['charset'] = array_map('strtoupper', $this->config['charset']);
// Process options that specify a filesystem path
foreach (self::$pathOptions as $option) {
if (is_array($this->config[$option])) {
array_walk($this->config[$option], function(&$value) {
if (file_exists($value)) {
$value = realpath($value);
}
});
usort($this->config[$option], 'strcasecmp');
} else {
if (file_exists($this->config[$option])) {
$this->config[$option] = realpath($this->config[$option]);
}
}
}
// Unify directory separators
foreach (array('exclude', 'skipDocPath') as $option) {
$this->config[$option] = array_map(function($mask) {
return str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $mask);
}, $this->config[$option]);
usort($this->config[$option], 'strcasecmp');
}
// Unify prefixes
$this->config['skipDocPrefix'] = array_map(function($prefix) {
return ltrim($prefix, '\\');
}, $this->config['skipDocPrefix']);
usort($this->config['skipDocPrefix'], 'strcasecmp');
// Base url without slash at the end
$this->config['baseUrl'] = rtrim($this->config['baseUrl'], '/');
// No progressbar in quiet mode
if ($this->config['quiet']) {
$this->config['progressbar'] = false;
}
// Check
$this->check();
// Default template config
$this->config['template'] = array(
'require' => array(),
'resources' => array(),
'templates' => array(
'common' => array(),
'optional' => array()
)
);
// Merge template config
$this->config = array_merge_recursive($this->config, array('template' => Neon::decode(file_get_contents($fileName = $this->config['templateConfig']))));
$this->config['template']['config'] = realpath($fileName);
// Check template
$this->checkTemplate();
return $this;
}
/**
* Checks configuration.
*
* @return \ApiGen\Config
* @throws \ApiGen\ConfigException If something in configuration is wrong.
*/
private function check()
{
if (!empty($this->config['config']) && !is_file($this->config['config'])) {
throw new ConfigException(sprintf('Config file "%s" doesn\'t exist', $this->config['config']));
}
if (empty($this->config['source'])) {
throw new ConfigException('Source is not set');
}
foreach ($this->config['source'] as $source) {
if (!file_exists($source)) {
throw new ConfigException(sprintf('Source "%s" doesn\'t exist', $source));
}
}
if (empty($this->config['destination'])) {
throw new ConfigException('Destination is not set');
}
foreach ($this->config['extensions'] as $extension) {
if (!preg_match('~^[a-z\\d]+$~i', $extension)) {
throw new ConfigException(sprintf('Invalid file extension "%s"', $extension));
}
}
if (!is_file($this->config['templateConfig'])) {
throw new ConfigException(sprintf('Template config "%s" doesn\'t exist', $this->config['templateConfig']));
}
if (!empty($this->config['baseUrl']) && !preg_match('~^https?://(?:[-a-z0-9]+\.)+[a-z]{2,6}(?:/.*)?$~i', $this->config['baseUrl'])) {
throw new ConfigException(sprintf('Invalid base url "%s"', $this->config['baseUrl']));
}
if (!empty($this->config['googleCseId']) && !preg_match('~^\d{21}:[-a-z0-9_]{11}$~', $this->config['googleCseId'])) {
throw new ConfigException(sprintf('Invalid Google Custom Search ID "%s"', $this->config['googleCseId']));
}
if (!empty($this->config['googleAnalytics']) && !preg_match('~^UA\\-\\d+\\-\\d+$~', $this->config['googleAnalytics'])) {
throw new ConfigException(sprintf('Invalid Google Analytics tracking code "%s"', $this->config['googleAnalytics']));
}
if (empty($this->config['groups'])) {
throw new ConfigException('No supported groups value given');
}
if (empty($this->config['autocomplete'])) {
throw new ConfigException('No supported autocomplete value given');
}
if (empty($this->config['accessLevels'])) {
throw new ConfigException('No supported access level given');
}
return $this;
}
/**
* Checks template configuration.
*
* @return \ApiGen\Config
* @throws \ApiGen\ConfigException If something in template configuration is wrong.
*/
private function checkTemplate()
{
$require = $this->config['template']['require'];
if (isset($require['min']) && !preg_match('~^\\d+(?:\\.\\d+){0,2}$~', $require['min'])) {
throw new ConfigException(sprintf('Invalid minimal version definition "%s"', $require['min']));
}
if (isset($require['max']) && !preg_match('~^\\d+(?:\\.\\d+){0,2}$~', $require['max'])) {
throw new ConfigException(sprintf('Invalid maximal version definition "%s"', $require['max']));
}
$isMinOk = function($min) {
$min .= str_repeat('.0', 2 - substr_count($min, '.'));
return version_compare($min, Generator::VERSION, '<=');
};
$isMaxOk = function($max) {
$max .= str_repeat('.0', 2 - substr_count($max, '.'));
return version_compare($max, Generator::VERSION, '>=');
};
if (isset($require['min'], $require['max']) && (!$isMinOk($require['min']) || !$isMaxOk($require['max']))) {
throw new ConfigException(sprintf('The template requires version from "%s" to "%s", you are using version "%s"', $require['min'], $require['max'], Generator::VERSION));
} elseif (isset($require['min']) && !$isMinOk($require['min'])) {
throw new ConfigException(sprintf('The template requires version "%s" or newer, you are using version "%s"', $require['min'], Generator::VERSION));
} elseif (isset($require['max']) && !$isMaxOk($require['max'])) {
throw new ConfigException(sprintf('The template requires version "%s" or older, you are using version "%s"', $require['max'], Generator::VERSION));
}
foreach (array('main', 'optional') as $section) {
foreach ($this->config['template']['templates'][$section] as $type => $config) {
if (!isset($config['filename'])) {
throw new ConfigException(sprintf('Filename for "%s" is not defined', $type));
}
if (!isset($config['template'])) {
throw new ConfigException(sprintf('Template for "%s" is not defined', $type));
}
if (!is_file(dirname($this->config['templateConfig']) . DIRECTORY_SEPARATOR . $config['template'])) {
throw new ConfigException(sprintf('Template for "%s" doesn\'t exist', $type));
}
}
}
return $this;
}
/**
* Returns default configuration file path.
*
* @return string
*/
private function getDefaultConfigPath()
{
return getcwd() . DIRECTORY_SEPARATOR . 'apigen.neon';
}
/**
* Checks if default configuration file exists.
*
* @return boolean
*/
private function defaultConfigExists()
{
return is_file($this->getDefaultConfigPath());
}
/**
* Returns absolute path.
*
* @param string $path Path
* @return string
*/
private function getAbsolutePath($path)
{
if (preg_match('~/|[a-z]:~Ai', $path)) {
return $path;
}
return dirname($this->options['config']) . DIRECTORY_SEPARATOR . $path;
}
/**
* Checks if a configuration option exists.
*
* @param string $name Option name
* @return boolean
*/
public function __isset($name)
{
return isset($this->config[$name]);
}
/**
* Returns a configuration option value.
*
* @param string $name Option name
* @return mixed
*/
public function __get($name)
{
return isset($this->config[$name]) ? $this->config[$name] : null;
}
/**
* If the user requests help.
*
* @return boolean
*/
public function isHelpRequested()
{
if (empty($this->options) && !$this->defaultConfigExists()) {
return true;
}
if (isset($this->options['h']) || isset($this->options['help'])) {
return true;
}
return false;
}
/**
* Returns help.
*
* @return string
*/
public function getHelp()
{
return <<<"HELP"
Usage:
apigen @option@--config@c <@value@path@c> [options]
apigen @option@--source@c <@value@dir@c|@value@file@c> @option@--destination@c <@value@dir@c> [options]
Options:
@option@--config@c|@option@-c@c <@value@file@c> Config file
@option@--source@c|@option@-s@c <@value@dir@c|@value@file@c> Source file or directory to parse (can be used multiple times)
@option@--destination@c|@option@-d@c <@value@dir@c> Directory where to save the generated documentation
@option@--extensions@c <@value@list@c> List of allowed file extensions, default "@value@php@c"
@option@--exclude@c <@value@mask@c> Mask (case sensitive) to exclude file or directory from processing (can be used multiple times)
@option@--skip-doc-path@c <@value@mask@c> Don't generate documentation for elements from file or directory with this (case sensitive) mask (can be used multiple times)
@option@--skip-doc-prefix@c <@value@value@c> Don't generate documentation for elements with this (case sensitive) name prefix (can be used multiple times)
@option@--charset@c <@value@list@c> Character set of source files, default "@value@auto@c"
@option@--main@c <@value@value@c> Main project name prefix
@option@--title@c <@value@value@c> Title of generated documentation
@option@--base-url@c <@value@value@c> Documentation base URL
@option@--google-cse-id@c <@value@value@c> Google Custom Search ID
@option@--google-cse-label@c <@value@value@c> Google Custom Search label
@option@--google-analytics@c <@value@value@c> Google Analytics tracking code
@option@--template-config@c <@value@file@c> Template config file, default "@value@{$this->config['templateConfig']}@c"
@option@--allowed-html@c <@value@list@c> List of allowed HTML tags in documentation, default "@value@b,i,a,ul,ol,li,p,br,var,samp,kbd,tt@c"
@option@--groups@c <@value@value@c> How should elements be grouped in the menu. Default value is "@value@auto@c" (namespaces if available, packages otherwise)
@option@--autocomplete@c <@value@list@c> Element types for search input autocomplete. Default value is "@value@classes,constants,functions@c"
@option@--access-levels@c <@value@list@c> Generate documentation for methods and properties with given access level, default "@value@public,protected@c"
@option@--internal@c <@value@yes@c|@value@no@c> Generate documentation for elements marked as internal and display internal documentation parts, default "@value@no@c"
@option@--php@c <@value@yes@c|@value@no@c> Generate documentation for PHP internal classes, default "@value@yes@c"
@option@--tree@c <@value@yes@c|@value@no@c> Generate tree view of classes, interfaces, traits and exceptions, default "@value@yes@c"
@option@--deprecated@c <@value@yes@c|@value@no@c> Generate documentation for deprecated elements, default "@value@no@c"
@option@--todo@c <@value@yes@c|@value@no@c> Generate documentation of tasks, default "@value@no@c"
@option@--source-code@c <@value@yes@c|@value@no@c> Generate highlighted source code files, default "@value@yes@c"
@option@--download@c <@value@yes@c|@value@no@c> Add a link to download documentation as a ZIP archive, default "@value@no@c"
@option@--report@c <@value@file@c> Save a checkstyle report of poorly documented elements into a file
@option@--wipeout@c <@value@yes@c|@value@no@c> Wipe out the destination directory first, default "@value@yes@c"
@option@--quiet@c <@value@yes@c|@value@no@c> Don't display scaning and generating messages, default "@value@no@c"
@option@--progressbar@c <@value@yes@c|@value@no@c> Display progressbars, default "@value@yes@c"
@option@--colors@c <@value@yes@c|@value@no@c> Use colors, default "@value@no@c" on Windows, "@value@yes@c" on other systems
@option@--update-check@c <@value@yes@c|@value@no@c> Check for update, default "@value@yes@c"
@option@--debug@c <@value@yes@c|@value@no@c> Display additional information in case of an error, default "@value@no@c"
@option@--help@c|@option@-h@c Display this help
Only source and destination directories are required - either set explicitly or using a config file. Configuration parameters passed via command line have precedence over parameters from a config file.
Boolean options (those with possible values @value@yes@c|@value@no@c) do not have to have their values defined explicitly. Using @option@--debug@c and @option@--debug@c=@value@yes@c is exactly the same.
Some options can have multiple values. You can do so either by using them multiple times or by separating values by a comma. That means that writing @option@--source@c=@value@file1.php@c @option@--source@c=@value@file2.php@c or @option@--source@c=@value@file1.php,file2.php@c is exactly the same.
Files or directories specified by @option@--exclude@c will not be processed at all.
Elements from files within @option@--skip-doc-path@c or with @option@--skip-doc-prefix@c will be parsed but will not have their documentation generated. However if classes have any child classes, the full class tree will be generated and their inherited methods, properties and constants will be displayed (but will not be clickable).
HELP;
}
/**
* Checks if ApiGen is installed by PEAR.
*
* @return boolean
*/
public static function isInstalledByPear()
{
return false === strpos('@data_dir@', '@data_dir');
}
/**
* Checks if ApiGen is installed from downloaded archive.
*
* @return boolean
*/
public static function isInstalledByDownload()
{
return !self::isInstalledByPear();
}
}

View File

@ -0,0 +1,25 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use RuntimeException;
/**
* ApiGen configuration exception.
*
* Thrown when an invalid configuration is detected.
*/
class ConfigException extends RuntimeException
{
}

2121
apigen/ApiGen/Generator.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
/**
* Helper set interface.
*/
interface IHelperSet
{
/**
* Tries to load the requested helper.
*
* @param string $helperName Helper name
* @return \Nette\Callback
*/
public function loader($helperName);
}

View File

@ -0,0 +1,23 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use Nette\Latte\Macros\MacroSet as NetteMacroSet;
/**
* Macro set base class.
*/
abstract class MacroSet extends NetteMacroSet
{
}

View File

@ -0,0 +1,240 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use TokenReflection\IReflection;
/**
* Base reflection envelope.
*
* Alters TokenReflection\IReflection functionality for ApiGen.
*/
abstract class ReflectionBase
{
/**
* List of parsed classes.
*
* @var \ArrayObject
*/
protected static $parsedClasses;
/**
* List of parsed constants.
*
* @var \ArrayObject
*/
protected static $parsedConstants;
/**
* List of parsed functions.
*
* @var \ArrayObject
*/
protected static $parsedFunctions;
/**
* Generator.
*
* @var \ApiGen\Generator
*/
protected static $generator = null;
/**
* Config.
*
* @var \ApiGen\Config
*/
protected static $config = null;
/**
* Class methods cache.
*
* @var array
*/
protected static $reflectionMethods = array();
/**
* Reflection type (reflection class).
*
* @var string
*/
protected $reflectionType;
/**
* Inspected class reflection.
*
* @var \TokenReflection\IReflectionClass
*/
protected $reflection;
/**
* Constructor.
*
* Sets the inspected reflection.
*
* @param \TokenReflection\IReflection $reflection Inspected reflection
* @param \ApiGen\Generator $generator ApiGen generator
*/
public function __construct(IReflection $reflection, Generator $generator)
{
if (null === self::$generator) {
self::$generator = $generator;
self::$config = $generator->getConfig();
self::$parsedClasses = $generator->getParsedClasses();
self::$parsedConstants = $generator->getParsedConstants();
self::$parsedFunctions = $generator->getParsedFunctions();
}
$this->reflectionType = get_class($this);
if (!isset(self::$reflectionMethods[$this->reflectionType])) {
self::$reflectionMethods[$this->reflectionType] = array_flip(get_class_methods($this));
}
$this->reflection = $reflection;
}
/**
* Retrieves a property or method value.
*
* First tries the envelope object's property storage, then its methods
* and finally the inspected element reflection.
*
* @param string $name Property name
* @return mixed
*/
public function __get($name)
{
$key = ucfirst($name);
if (isset(self::$reflectionMethods[$this->reflectionType]['get' . $key])) {
return $this->{'get' . $key}();
}
if (isset(self::$reflectionMethods[$this->reflectionType]['is' . $key])) {
return $this->{'is' . $key}();
}
return $this->reflection->__get($name);
}
/**
* Checks if the given property exists.
*
* First tries the envelope object's property storage, then its methods
* and finally the inspected element reflection.
*
* @param mixed $name Property name
* @return boolean
*/
public function __isset($name)
{
$key = ucfirst($name);
return isset(self::$reflectionMethods[$this->reflectionType]['get' . $key]) || isset(self::$reflectionMethods[$this->reflectionType]['is' . $key]) || $this->reflection->__isset($name);
}
/**
* Returns the reflection broker used by this reflection object.
*
* @return \TokenReflection\Broker
*/
public function getBroker()
{
return $this->reflection->getBroker();
}
/**
* Returns the name (FQN).
*
* @return string
*/
public function getName()
{
return $this->reflection->getName();
}
/**
* Returns an element pretty (docblock compatible) name.
*
* @return string
*/
public function getPrettyName()
{
return $this->reflection->getPrettyName();
}
/**
* Returns if the reflection object is internal.
*
* @return boolean
*/
public function isInternal()
{
return $this->reflection->isInternal();
}
/**
* Returns if the reflection object is user defined.
*
* @return boolean
*/
public function isUserDefined()
{
return $this->reflection->isUserDefined();
}
/**
* Returns if the current reflection comes from a tokenized source.
*
* @return boolean
*/
public function isTokenized()
{
return $this->reflection->isTokenized();
}
/**
* Returns the file name the reflection object is defined in.
*
* @return string
*/
public function getFileName()
{
return $this->reflection->getFileName();
}
/**
* Returns the definition start line number in the file.
*
* @return integer
*/
public function getStartLine()
{
$startLine = $this->reflection->getStartLine();
if ($doc = $this->getDocComment()) {
$startLine -= substr_count($doc, "\n") + 1;
}
return $startLine;
}
/**
* Returns the definition end line number in the file.
*
* @return integer
*/
public function getEndLine()
{
return $this->reflection->getEndLine();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,145 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
/**
* Constant reflection envelope.
*
* Alters TokenReflection\IReflectionConstant functionality for ApiGen.
*/
class ReflectionConstant extends ReflectionElement
{
/**
* Returns the unqualified name (UQN).
*
* @return string
*/
public function getShortName()
{
return $this->reflection->getShortName();
}
/**
* Returns constant type hint.
*
* @return string
*/
public function getTypeHint()
{
if ($annotations = $this->getAnnotation('var')) {
list($types) = preg_split('~\s+|$~', $annotations[0], 2);
if (!empty($types)) {
return $types;
}
}
try {
$type = gettype($this->getValue());
if ('null' !== strtolower($type)) {
return $type;
}
} catch (\Exception $e) {
// Nothing
}
return 'mixed';
}
/**
* Returns the constant declaring class.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringClass()
{
$className = $this->reflection->getDeclaringClassName();
return null === $className ? null : self::$parsedClasses[$className];
}
/**
* Returns the name of the declaring class.
*
* @return string|null
*/
public function getDeclaringClassName()
{
return $this->reflection->getDeclaringClassName();
}
/**
* Returns the constant value.
*
* @return mixed
*/
public function getValue()
{
return $this->reflection->getValue();
}
/**
* Returns the constant value definition.
*
* @return string
*/
public function getValueDefinition()
{
return $this->reflection->getValueDefinition();
}
/**
* Returns if the constant is valid.
*
* @return boolean
*/
public function isValid()
{
if ($this->reflection instanceof \TokenReflection\Invalid\ReflectionConstant) {
return false;
}
if ($class = $this->getDeclaringClass()) {
return $class->isValid();
}
return true;
}
/**
* Returns if the constant should be documented.
*
* @return boolean
*/
public function isDocumented()
{
if (null === $this->isDocumented && parent::isDocumented() && null === $this->reflection->getDeclaringClassName()) {
$fileName = self::$generator->unPharPath($this->reflection->getFilename());
foreach (self::$config->skipDocPath as $mask) {
if (fnmatch($mask, $fileName, FNM_NOESCAPE)) {
$this->isDocumented = false;
break;
}
}
if (true === $this->isDocumented) {
foreach (self::$config->skipDocPrefix as $prefix) {
if (0 === strpos($this->reflection->getName(), $prefix)) {
$this->isDocumented = false;
break;
}
}
}
}
return $this->isDocumented;
}
}

View File

@ -0,0 +1,373 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
/**
* Element reflection envelope.
*
* Alters TokenReflection\IReflection functionality for ApiGen.
*/
abstract class ReflectionElement extends ReflectionBase
{
/**
* Cache for information if the element should be documented.
*
* @var boolean
*/
protected $isDocumented;
/**
* Reflection elements annotations.
*
* @var array
*/
protected $annotations;
/**
* Returns the PHP extension reflection.
*
* @return \ApiGen\ReflectionExtension|null
*/
public function getExtension()
{
$extension = $this->reflection->getExtension();
return null === $extension ? null : new ReflectionExtension($extension, self::$generator);
}
/**
* Returns the PHP extension name.
*
* @return boolean
*/
public function getExtensionName()
{
return $this->reflection->getExtensionName();
}
/**
* Returns the start position in the file token stream.
*
* @return integer
*/
public function getStartPosition()
{
return $this->reflection->getStartPosition();
}
/**
* Returns the end position in the file token stream.
*
* @return integer
*/
public function getEndPosition()
{
return $this->reflection->getEndPosition();
}
/**
* Returns if the element belongs to main project.
*
* @return boolean
*/
public function isMain()
{
return empty(self::$config->main) || 0 === strpos($this->getName(), self::$config->main);
}
/**
* Returns if the element should be documented.
*
* @return boolean
*/
public function isDocumented()
{
if (null === $this->isDocumented) {
$this->isDocumented = $this->reflection->isTokenized() || $this->reflection->isInternal();
if ($this->isDocumented) {
if (!self::$config->php && $this->reflection->isInternal()) {
$this->isDocumented = false;
} elseif (!self::$config->deprecated && $this->reflection->isDeprecated()) {
$this->isDocumented = false;
} elseif (!self::$config->internal && ($internal = $this->reflection->getAnnotation('internal')) && empty($internal[0])) {
$this->isDocumented = false;
} elseif (count($this->reflection->getAnnotation('ignore')) > 0) {
$this->isDocumented = false;
}
}
}
return $this->isDocumented;
}
/**
* Returns if the element is deprecated.
*
* @return boolean
*/
public function isDeprecated()
{
if ($this->reflection->isDeprecated()) {
return true;
}
if (($this instanceof ReflectionMethod || $this instanceof ReflectionProperty || $this instanceof ReflectionConstant)
&& $class = $this->getDeclaringClass()
) {
return $class->isDeprecated();
}
return false;
}
/**
* Returns if the element is in package.
*
* @return boolean
*/
public function inPackage()
{
return '' !== $this->getPackageName();
}
/**
* Returns element package name (including subpackage name).
*
* @return string
*/
public function getPackageName()
{
static $packages = array();
if ($package = $this->getAnnotation('package')) {
$packageName = preg_replace('~\s+.*~s', '', $package[0]);
if (empty($packageName)) {
return '';
}
if ($subpackage = $this->getAnnotation('subpackage')) {
$subpackageName = preg_replace('~\s+.*~s', '', $subpackage[0]);
if (empty($subpackageName)) {
// Do nothing
} elseif (0 === strpos($subpackageName, $packageName)) {
$packageName = $subpackageName;
} else {
$packageName .= '\\' . $subpackageName;
}
}
$packageName = strtr($packageName, '._/', '\\\\\\');
$lowerPackageName = strtolower($packageName);
if (!isset($packages[$lowerPackageName])) {
$packages[$lowerPackageName] = $packageName;
}
return $packages[$lowerPackageName];
}
return '';
}
/**
* Returns element package name (including subpackage name).
*
* For internal elements returns "PHP", for elements in global space returns "None".
*
* @return string
*/
public function getPseudoPackageName()
{
if ($this->isInternal()) {
return 'PHP';
}
return $this->getPackageName() ?: 'None';
}
/**
* Returns if the element is defined within a namespace.
*
* @return boolean
*/
public function inNamespace()
{
return '' !== $this->getNamespaceName();
}
/**
* Returns element namespace name.
*
* @return string
*/
public function getNamespaceName()
{
static $namespaces = array();
$namespaceName = $this->reflection->getNamespaceName();
if (!$namespaceName) {
return $namespaceName;
}
$lowerNamespaceName = strtolower($namespaceName);
if (!isset($namespaces[$lowerNamespaceName])) {
$namespaces[$lowerNamespaceName] = $namespaceName;
}
return $namespaces[$lowerNamespaceName];
}
/**
* Returns element namespace name.
*
* For internal elements returns "PHP", for elements in global space returns "None".
*
* @return string
*/
public function getPseudoNamespaceName()
{
return $this->isInternal() ? 'PHP' : $this->getNamespaceName() ?: 'None';
}
/**
* Returns imported namespaces and aliases from the declaring namespace.
*
* @return array
*/
public function getNamespaceAliases()
{
return $this->reflection->getNamespaceAliases();
}
/**
* Returns the short description.
*
* @return string
*/
public function getShortDescription()
{
$short = $this->reflection->getAnnotation(\TokenReflection\ReflectionAnnotation::SHORT_DESCRIPTION);
if (!empty($short)) {
return $short;
}
if ($this instanceof ReflectionProperty || $this instanceof ReflectionConstant) {
$var = $this->getAnnotation('var');
list(, $short) = preg_split('~\s+|$~', $var[0], 2);
}
return $short;
}
/**
* Returns the long description.
*
* @return string
*/
public function getLongDescription()
{
$short = $this->getShortDescription();
$long = $this->reflection->getAnnotation(\TokenReflection\ReflectionAnnotation::LONG_DESCRIPTION);
if (!empty($long)) {
$short .= "\n\n" . $long;
}
return $short;
}
/**
* Returns the appropriate docblock definition.
*
* @return string|boolean
*/
public function getDocComment()
{
return $this->reflection->getDocComment();
}
/**
* Returns reflection element annotations.
*
* Removes the short and long description.
*
* In case of classes, functions and constants, @package, @subpackage, @author and @license annotations
* are added from declaring files if not already present.
*
* @return array
*/
public function getAnnotations()
{
if (null === $this->annotations) {
static $fileLevel = array('package' => true, 'subpackage' => true, 'author' => true, 'license' => true, 'copyright' => true);
$annotations = $this->reflection->getAnnotations();
unset($annotations[\TokenReflection\ReflectionAnnotation::SHORT_DESCRIPTION]);
unset($annotations[\TokenReflection\ReflectionAnnotation::LONG_DESCRIPTION]);
if ($this->reflection instanceof \TokenReflection\ReflectionClass || $this->reflection instanceof \TokenReflection\ReflectionFunction || ($this->reflection instanceof \TokenReflection\ReflectionConstant && null === $this->reflection->getDeclaringClassName())) {
foreach ($this->reflection->getFileReflection()->getAnnotations() as $name => $value) {
if (isset($fileLevel[$name]) && empty($annotations[$name])) {
$annotations[$name] = $value;
}
}
}
$this->annotations = $annotations;
}
return $this->annotations;
}
/**
* Returns reflection element annotation.
*
* @param string $annotation Annotation name
* @return array
*/
public function getAnnotation($annotation)
{
$annotations = $this->getAnnotations();
return isset($annotations[$annotation]) ? $annotations[$annotation] : null;
}
/**
* Checks if there is a particular annotation.
*
* @param string $annotation Annotation name
* @return boolean
*/
public function hasAnnotation($annotation)
{
$annotations = $this->getAnnotations();
return isset($annotations[$annotation]);
}
/**
* Adds element annotation.
*
* @param string $annotation Annotation name
* @param string $value Annotation value
* @return \ApiGen\ReflectionElement
*/
public function addAnnotation($annotation, $value)
{
if (null === $this->annotations) {
$this->getAnnotations();
}
$this->annotations[$annotation][] = $value;
return $this;
}
}

View File

@ -0,0 +1,135 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
/**
* Extension reflection envelope.
*
* Alters TokenReflection\IReflectionExtension functionality for ApiGen.
*/
class ReflectionExtension extends ReflectionBase
{
/**
* Returns a class reflection.
*
* @param string $name Class name
* @return \ApiGen\ReflectionClass|null
*/
public function getClass($name)
{
$class = $this->reflection->getClass($name);
if (null === $class) {
return null;
}
if (isset(self::$parsedClasses[$name])) {
return self::$parsedClasses[$name];
}
return new ReflectionClass($class, self::$generator);
}
/**
* Returns classes defined by this extension.
*
* @return array
*/
public function getClasses()
{
$generator = self::$generator;
$classes = self::$parsedClasses;
return array_map(function(TokenReflection\IReflectionClass $class) use ($generator, $classes) {
return isset($classes[$class->getName()]) ? $classes[$class->getName()] : new ReflectionClass($class, $generator);
}, $this->reflection->getClasses());
}
/**
* Returns a constant reflection.
*
* @param string $name Constant name
* @return \ApiGen\ReflectionConstant|null
*/
public function getConstant($name)
{
return $this->getConstantReflection($name);
}
/**
* Returns a constant reflection.
*
* @param string $name Constant name
* @return \ApiGen\ReflectionConstant|null
*/
public function getConstantReflection($name)
{
$constant = $this->reflection->getConstantReflection($name);
return null === $constant ? null : new ReflectionConstant($constant, self::$generator);
}
/**
* Returns reflections of defined constants.
*
* @return array
*/
public function getConstants()
{
return $this->getConstantReflections();
}
/**
* Returns reflections of defined constants.
*
* @return array
*/
public function getConstantReflections()
{
$generator = self::$generator;
return array_map(function(TokenReflection\IReflectionConstant $constant) use ($generator) {
return new ReflectionConstant($constant, $generator);
}, $this->reflection->getConstantReflections());
}
/**
* Returns a function reflection.
*
* @param string $name Function name
* @return \ApiGen\ReflectionFunction
*/
public function getFunction($name)
{
$function = $this->reflection->getFunction($name);
return null === $function ? null : new ReflectionFunction($function, self::$generator);
}
/**
* Returns functions defined by this extension.
*
* @return array
*/
public function getFunctions()
{
$generator = self::$generator;
return array_map(function(TokenReflection\IReflectionFunction $function) use ($generator) {
return new ReflectionFunction($function, $generator);
}, $this->reflection->getFunctions());
}
/**
* Returns names of functions defined by this extension.
*
* @return array
*/
public function getFunctionNames()
{
return $this->reflection->getFunctionNames();
}
}

View File

@ -0,0 +1,64 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
/**
* Function reflection envelope.
*
* Alters TokenReflection\IReflectionFunction functionality for ApiGen.
*/
class ReflectionFunction extends ReflectionFunctionBase
{
/**
* Returns if the function is valid.
*
* @return boolean
*/
public function isValid()
{
if ($this->reflection instanceof \TokenReflection\Invalid\ReflectionFunction) {
return false;
}
return true;
}
/**
* Returns if the function should be documented.
*
* @return boolean
*/
public function isDocumented()
{
if (null === $this->isDocumented && parent::isDocumented()) {
$fileName = self::$generator->unPharPath($this->reflection->getFilename());
foreach (self::$config->skipDocPath as $mask) {
if (fnmatch($mask, $fileName, FNM_NOESCAPE)) {
$this->isDocumented = false;
break;
}
}
if (true === $this->isDocumented) {
foreach (self::$config->skipDocPrefix as $prefix) {
if (0 === strpos($this->reflection->getName(), $prefix)) {
$this->isDocumented = false;
break;
}
}
}
}
return $this->isDocumented;
}
}

View File

@ -0,0 +1,151 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use TokenReflection;
use InvalidArgumentException;
/**
* Function/method reflection envelope parent class.
*
* Alters TokenReflection\IReflectionFunctionBase functionality for ApiGen.
*/
abstract class ReflectionFunctionBase extends ReflectionElement
{
/**
* Cache for list of parameters.
*
* @var array
*/
protected $parameters;
/**
* Returns the unqualified name (UQN).
*
* @return string
*/
public function getShortName()
{
return $this->reflection->getShortName();
}
/**
* Returns if the function/method returns its value as reference.
*
* @return boolean
*/
public function returnsReference()
{
return $this->reflection->returnsReference();
}
/**
* Returns a list of function/method parameters.
*
* @return array
*/
public function getParameters()
{
if (null === $this->parameters) {
$generator = self::$generator;
$this->parameters = array_map(function(TokenReflection\IReflectionParameter $parameter) use ($generator) {
return new ReflectionParameter($parameter, $generator);
}, $this->reflection->getParameters());
$annotations = $this->getAnnotation('param');
if (null !== $annotations) {
foreach ($annotations as $position => $annotation) {
if (isset($parameters[$position])) {
// Standard parameter
continue;
}
if (!preg_match('~^(?:([\\w\\\\]+(?:\\|[\\w\\\\]+)*)\\s+)?\\$(\\w+),\\.{3}(?:\\s+(.*))?($)~s', $annotation, $matches)) {
// Wrong annotation format
continue;
}
list(, $typeHint, $name) = $matches;
if (empty($typeHint)) {
$typeHint = 'mixed';
}
$parameter = new ReflectionParameterMagic(null, self::$generator);
$parameter
->setName($name)
->setPosition($position)
->setTypeHint($typeHint)
->setDefaultValueDefinition(null)
->setUnlimited(true)
->setPassedByReference(false)
->setDeclaringFunction($this);
$this->parameters[$position] = $parameter;
}
}
}
return $this->parameters;
}
/**
* Returns a particular function/method parameter.
*
* @param integer|string $parameterName Parameter name or position
* @return \ApiGen\ReflectionParameter
* @throws \InvalidArgumentException If there is no parameter of the given name.
* @throws \InvalidArgumentException If there is no parameter at the given position.
*/
public function getParameter($parameterName)
{
$parameters = $this->getParameters();
if (is_numeric($parameterName)) {
if (isset($parameters[$parameterName])) {
return $parameters[$parameterName];
}
throw new InvalidArgumentException(sprintf('There is no parameter at position "%d" in function/method "%s"', $parameterName, $this->getName()), Exception\Runtime::DOES_NOT_EXIST);
} else {
foreach ($parameters as $parameter) {
if ($parameter->getName() === $parameterName) {
return $parameter;
}
}
throw new InvalidArgumentException(sprintf('There is no parameter "%s" in function/method "%s"', $parameterName, $this->getName()), Exception\Runtime::DOES_NOT_EXIST);
}
}
/**
* Returns the number of parameters.
*
* @return integer
*/
public function getNumberOfParameters()
{
return $this->reflection->getNumberOfParameters();
}
/**
* Returns the number of required parameters.
*
* @return integer
*/
public function getNumberOfRequiredParameters()
{
return $this->reflection->getNumberOfRequiredParameters();
}
}

View File

@ -0,0 +1,250 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
/**
* Method reflection envelope.
*
* Alters TokenReflection\IReflectionMethod functionality for ApiGen.
*/
class ReflectionMethod extends ReflectionFunctionBase
{
/**
* Returns if the method is magic.
*
* @return boolean
*/
public function isMagic()
{
return false;
}
/**
* Returns the method declaring class.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringClass()
{
$className = $this->reflection->getDeclaringClassName();
return null === $className ? null : self::$parsedClasses[$className];
}
/**
* Returns the declaring class name.
*
* @return string|null
*/
public function getDeclaringClassName()
{
return $this->reflection->getDeclaringClassName();
}
/**
* Returns method modifiers.
*
* @return integer
*/
public function getModifiers()
{
return $this->reflection->getModifiers();
}
/**
* Returns if the method is abstract.
*
* @return boolean
*/
public function isAbstract()
{
return $this->reflection->isAbstract();
}
/**
* Returns if the method is final.
*
* @return boolean
*/
public function isFinal()
{
return $this->reflection->isFinal();
}
/**
* Returns if the method is private.
*
* @return boolean
*/
public function isPrivate()
{
return $this->reflection->isPrivate();
}
/**
* Returns if the method is protected.
*
* @return boolean
*/
public function isProtected()
{
return $this->reflection->isProtected();
}
/**
* Returns if the method is public.
*
* @return boolean
*/
public function isPublic()
{
return $this->reflection->isPublic();
}
/**
* Returns if the method is static.
*
* @return boolean
*/
public function isStatic()
{
return $this->reflection->isStatic();
}
/**
* Returns if the method is a constructor.
*
* @return boolean
*/
public function isConstructor()
{
return $this->reflection->isConstructor();
}
/**
* Returns if the method is a destructor.
*
* @return boolean
*/
public function isDestructor()
{
return $this->reflection->isDestructor();
}
/**
* Returns the method declaring trait.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringTrait()
{
$traitName = $this->reflection->getDeclaringTraitName();
return null === $traitName ? null : self::$parsedClasses[$traitName];
}
/**
* Returns the declaring trait name.
*
* @return string|null
*/
public function getDeclaringTraitName()
{
return $this->reflection->getDeclaringTraitName();
}
/**
* Returns the overridden method.
*
* @return \ApiGen\ReflectionMethod|null
*/
public function getImplementedMethod()
{
foreach ($this->getDeclaringClass()->getOwnInterfaces() as $interface) {
if ($interface->hasMethod($this->getName())) {
return $interface->getMethod($this->getName());
}
}
return null;
}
/**
* Returns the overridden method.
*
* @return \ApiGen\ReflectionMethod|null
*/
public function getOverriddenMethod()
{
$parent = $this->getDeclaringClass()->getParentClass();
if (null === $parent) {
return null;
}
foreach ($parent->getMethods() as $method) {
if ($this->getName() === $method->getName()) {
if (!$method->isPrivate() && !$method->isAbstract()) {
return $method;
} else {
return null;
}
}
}
return null;
}
/**
* Returns the original name when importing from a trait.
*
* @return string|null
*/
public function getOriginalName()
{
return $this->reflection->getOriginalName();
}
/**
* Returns the original modifiers value when importing from a trait.
*
* @return integer|null
*/
public function getOriginalModifiers()
{
return $this->reflection->getOriginalModifiers();
}
/**
* Returns the original method when importing from a trait.
*
* @return \ApiGen\ReflectionMethod|null
*/
public function getOriginal()
{
$originalName = $this->reflection->getOriginalName();
return null === $originalName ? null : self::$parsedClasses[$this->reflection->getOriginal()->getDeclaringClassName()]->getMethod($originalName);
}
/**
* Returns if the method is valid.
*
* @return boolean
*/
public function isValid()
{
if ($class = $this->getDeclaringClass()) {
return $class->isValid();
}
return true;
}
}

View File

@ -0,0 +1,729 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use ReflectionProperty as InternalReflectionMethod;
/**
* Envelope for magic methods that are defined only as @method annotation.
*/
class ReflectionMethodMagic extends ReflectionMethod
{
/**
* Method name.
*
* @var string
*/
protected $name;
/**
* Short description.
*
* @var string
*/
protected $shortDescription;
/**
* Start line number in the file.
*
* @var integer
*/
protected $startLine;
/**
* End line number in the file.
*
* @var integer
*/
protected $endLine;
/**
* If the method returns reference.
*
* @var boolean
*/
protected $returnsReference;
/**
* The declaring class.
*
* @var \ApiGen\ReflectionClass
*/
protected $declaringClass;
/**
* Constructor.
*
* @param \TokenReflection\IReflection $reflection Inspected reflection
* @param \ApiGen\Generator $generator ApiGen generator
*/
public function __construct(IReflection $reflection = null, Generator $generator = null)
{
$this->reflectionType = get_class($this);
if (!isset(self::$reflectionMethods[$this->reflectionType])) {
self::$reflectionMethods[$this->reflectionType] = array_flip(get_class_methods($this));
}
}
/**
* Sets method name.
*
* @param string $name
* @return \Apigen\ReflectionMethodMagic
*/
public function setName($name)
{
$this->name = (string) $name;
return $this;
}
/**
* Sets short description.
*
* @param string $shortDescription
* @return \Apigen\ReflectionMethodMagic
*/
public function setShortDescription($shortDescription)
{
$this->shortDescription = (string) $shortDescription;
return $this;
}
/**
* Sets start line.
*
* @param integer $startLine
* @return \Apigen\ReflectionMethodMagic
*/
public function setStartLine($startLine)
{
$this->startLine = (int) $startLine;
return $this;
}
/**
* Sets end line.
*
* @param integer $endLine
* @return \Apigen\ReflectionMethodMagic
*/
public function setEndLine($endLine)
{
$this->endLine = (int) $endLine;
return $this;
}
/**
* Sets if the method returns reference.
*
* @param boolean $returnsReference
* @return \Apigen\ReflectionMethodMagic
*/
public function setReturnsReference($returnsReference)
{
$this->returnsReference = (bool) $returnsReference;
return $this;
}
/**
* Sets parameters.
*
* @param array $parameters
* @return \Apigen\ReflectionMethodMagic
*/
public function setParameters(array $parameters)
{
$this->parameters = $parameters;
return $this;
}
/**
* Sets declaring class.
*
* @param \ApiGen\ReflectionClass $declaringClass
* @return \ApiGen\ReflectionMethodMagic
*/
public function setDeclaringClass(ReflectionClass $declaringClass)
{
$this->declaringClass = $declaringClass;
return $this;
}
/**
* Returns the reflection broker used by this reflection object.
*
* @return \TokenReflection\Broker
*/
public function getBroker()
{
return $this->declaringClass->getBroker();
}
/**
* Returns the start position in the file token stream.
*
* @return integer
*/
public function getStartPosition()
{
return $this->declaringClass->getStartPosition();
}
/**
* Returns the end position in the file token stream.
*
* @return integer
*/
public function getEndPosition()
{
return $this->declaringClass->getEndPosition();
}
/**
* Returns the name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Returns the short description.
*
* @return string
*/
public function getShortDescription()
{
return $this->shortDescription;
}
/**
* Returns the long description.
*
* @return string
*/
public function getLongDescription()
{
return $this->shortDescription;
}
/**
* Returns the definition start line number in the file.
*
* @return integer
*/
public function getStartLine()
{
return $this->startLine;
}
/**
* Returns the definition end line number in the file.
*
* @return integer
*/
public function getEndLine()
{
return $this->endLine;
}
/**
* Returns if the function/method returns its value as reference.
*
* @return boolean
*/
public function returnsReference()
{
return $this->returnsReference;
}
/**
* Returns if the property is magic.
*
* @return boolean
*/
public function isMagic()
{
return true;
}
/**
* Returns the unqualified name (UQN).
*
* @return string
*/
public function getShortName()
{
return $this->name;
}
/**
* Returns the PHP extension reflection.
*
* @return \ApiGen\ReflectionExtension|null
*/
public function getExtension()
{
return null;
}
/**
* Returns the PHP extension name.
*
* @return boolean
*/
public function getExtensionName()
{
return false;
}
/**
* Returns if the method should be documented.
*
* @return boolean
*/
public function isDocumented()
{
if (null === $this->isDocumented) {
$this->isDocumented = self::$config->deprecated || !$this->isDeprecated();
}
return $this->isDocumented;
}
/**
* Returns if the property is deprecated.
*
* @return boolean
*/
public function isDeprecated()
{
return $this->declaringClass->isDeprecated();
}
/**
* Returns property package name (including subpackage name).
*
* @return string
*/
public function getPackageName()
{
return $this->declaringClass->getPackageName();
}
/**
* Returns property namespace name.
*
* @return string
*/
public function getNamespaceName()
{
return $this->declaringClass->getNamespaceName();
}
/**
* Returns property annotations.
*
* @return array
*/
public function getAnnotations()
{
if (null === $this->annotations) {
$this->annotations = array();
}
return $this->annotations;
}
/**
* Returns the method declaring class.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringClass()
{
return $this->declaringClass;
}
/**
* Returns the declaring class name.
*
* @return string|null
*/
public function getDeclaringClassName()
{
return $this->declaringClass->getName();
}
/**
* Returns method modifiers.
*
* @return integer
*/
public function getModifiers()
{
return InternalReflectionMethod::IS_PUBLIC;
}
/**
* Returns if the method is abstract.
*
* @return boolean
*/
public function isAbstract()
{
return false;
}
/**
* Returns if the method is final.
*
* @return boolean
*/
public function isFinal()
{
return false;
}
/**
* Returns if the method is private.
*
* @return boolean
*/
public function isPrivate()
{
return false;
}
/**
* Returns if the method is protected.
*
* @return boolean
*/
public function isProtected()
{
return false;
}
/**
* Returns if the method is public.
*
* @return boolean
*/
public function isPublic()
{
return true;
}
/**
* Returns if the method is static.
*
* @return boolean
*/
public function isStatic()
{
return false;
}
/**
* Returns if the property is internal.
*
* @return boolean
*/
public function isInternal()
{
return false;
}
/**
* Returns if the method is a constructor.
*
* @return boolean
*/
public function isConstructor()
{
return false;
}
/**
* Returns if the method is a destructor.
*
* @return boolean
*/
public function isDestructor()
{
return false;
}
/**
* Returns the method declaring trait.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringTrait()
{
return $this->declaringClass->isTrait() ? $this->declaringClass : null;
}
/**
* Returns the declaring trait name.
*
* @return string|null
*/
public function getDeclaringTraitName()
{
if ($declaringTrait = $this->getDeclaringTrait()) {
return $declaringTrait->getName();
}
return null;
}
/**
* Returns the overridden method.
*
* @return \ApiGen\ReflectionMethod|null
*/
public function getImplementedMethod()
{
return null;
}
/**
* Returns the overridden method.
*
* @return \ApiGen\ReflectionMethod|null
*/
public function getOverriddenMethod()
{
$parent = $this->declaringClass->getParentClass();
if (null === $parent) {
return null;
}
foreach ($parent->getMagicMethods() as $method) {
if ($this->name === $method->getName()) {
return $method;
}
}
return null;
}
/**
* Returns the original name when importing from a trait.
*
* @return string|null
*/
public function getOriginalName()
{
return $this->getName();
}
/**
* Returns the original modifiers value when importing from a trait.
*
* @return integer|null
*/
public function getOriginalModifiers()
{
return $this->getModifiers();
}
/**
* Returns the original method when importing from a trait.
*
* @return \ApiGen\ReflectionMethod|null
*/
public function getOriginal()
{
return null;
}
/**
* Returns a list of method parameters.
*
* @return array
*/
public function getParameters()
{
return $this->parameters;
}
/**
* Returns the number of parameters.
*
* @return integer
*/
public function getNumberOfParameters()
{
return count($this->parameters);
}
/**
* Returns the number of required parameters.
*
* @return integer
*/
public function getNumberOfRequiredParameters()
{
$count = 0;
array_walk($this->parameters, function(ReflectionParameter $parameter) use (&$count) {
if (!$parameter->isOptional()) {
$count++;
}
});
return $count;
}
/**
* Returns imported namespaces and aliases from the declaring namespace.
*
* @return array
*/
public function getNamespaceAliases()
{
return $this->declaringClass->getNamespaceAliases();
}
/**
* Returns an property pretty (docblock compatible) name.
*
* @return string
*/
public function getPrettyName()
{
return sprintf('%s::%s()', $this->declaringClass->getName(), $this->name);
}
/**
* Returns the file name the method is defined in.
*
* @return string
*/
public function getFileName()
{
return $this->declaringClass->getFileName();
}
/**
* Returns if the method is user defined.
* @return boolean
*/
public function isUserDefined()
{
return true;
}
/**
* Returns if the method comes from a tokenized source.
*
* @return boolean
*/
public function isTokenized()
{
return true;
}
/**
* Returns the appropriate docblock definition.
*
* @return string|boolean
*/
public function getDocComment()
{
$docComment = "/**\n";
if (!empty($this->shortDescription)) {
$docComment .= $this->shortDescription . "\n\n";
}
if ($annotations = $this->getAnnotation('param')) {
foreach ($annotations as $annotation) {
$docComment .= sprintf("@param %s\n", $annotation);
}
}
if ($annotations = $this->getAnnotation('return')) {
foreach ($annotations as $annotation) {
$docComment .= sprintf("@return %s\n", $annotation);
}
}
$docComment .= "*/\n";
return $docComment;
}
/**
* Checks if there is a particular annotation.
*
* @param string $name Annotation name
* @return boolean
*/
public function hasAnnotation($name)
{
$annotations = $this->getAnnotations();
return array_key_exists($name, $annotations);
}
/**
* Returns a particular annotation value.
*
* @param string $name Annotation name
* @return string|array|null
*/
public function getAnnotation($name)
{
$annotations = $this->getAnnotations();
if (array_key_exists($name, $annotations)) {
return $annotations[$name];
}
return null;
}
/**
* Retrieves a property or method value.
*
* @param string $name Property name
* @return mixed
*/
public function __get($name)
{
$key = ucfirst($name);
if (isset(self::$reflectionMethods[$this->reflectionType]['get' . $key])) {
return $this->{'get' . $key}();
}
if (isset(self::$reflectionMethods[$this->reflectionType]['is' . $key])) {
return $this->{'is' . $key}();
}
return null;
}
/**
* Checks if the given property exists.
*
* @param mixed $name Property name
* @return boolean
*/
public function __isset($name)
{
$key = ucfirst($name);
return isset(self::$reflectionMethods[$this->reflectionType]['get' . $key]) || isset(self::$reflectionMethods[$this->reflectionType]['is' . $key]);
}
}

View File

@ -0,0 +1,215 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
/**
* Parameter reflection envelope.
*
* Alters TokenReflection\IReflectionParameter functionality for ApiGen.
*/
class ReflectionParameter extends ReflectionBase
{
/**
* Returns parameter type hint.
*
* @return string
*/
public function getTypeHint()
{
if ($this->isArray()) {
return 'array';
} elseif ($this->isCallable()) {
return 'callable';
} elseif ($className = $this->getClassName()) {
return $className;
} elseif ($annotations = $this->getDeclaringFunction()->getAnnotation('param')) {
if (!empty($annotations[$this->getPosition()])) {
list($types) = preg_split('~\s+|$~', $annotations[$this->getPosition()], 2);
if (!empty($types) && '$' !== $types[0]) {
return $types;
}
}
}
return 'mixed';
}
/**
* Returns the part of the source code defining the parameter default value.
*
* @return string
*/
public function getDefaultValueDefinition()
{
return $this->reflection->getDefaultValueDefinition();
}
/**
* Retutns if a default value for the parameter is available.
*
* @return boolean
*/
public function isDefaultValueAvailable()
{
return $this->reflection->isDefaultValueAvailable();
}
/**
* Returns the position within all parameters.
*
* @return integer
*/
public function getPosition()
{
return $this->reflection->position;
}
/**
* Returns if the parameter expects an array.
*
* @return boolean
*/
public function isArray()
{
return $this->reflection->isArray();
}
/**
* Returns if the parameter expects a callback.
*
* @return boolean
*/
public function isCallable()
{
return $this->reflection->isCallable();
}
/**
* Returns reflection of the required class of the parameter.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getClass()
{
$className = $this->reflection->getClassName();
return null === $className ? null : self::$parsedClasses[$className];
}
/**
* Returns the required class name of the value.
*
* @return string|null
*/
public function getClassName()
{
return $this->reflection->getClassName();
}
/**
* Returns if the the parameter allows NULL.
*
* @return boolean
*/
public function allowsNull()
{
return $this->reflection->allowsNull();
}
/**
* Returns if the parameter is optional.
*
* @return boolean
*/
public function isOptional()
{
return $this->reflection->isOptional();
}
/**
* Returns if the parameter value is passed by reference.
*
* @return boolean
*/
public function isPassedByReference()
{
return $this->reflection->isPassedByReference();
}
/**
* Returns if the paramter value can be passed by value.
*
* @return boolean
*/
public function canBePassedByValue()
{
return $this->reflection->canBePassedByValue();
}
/**
* Returns the declaring function.
*
* @return \ApiGen\ReflectionFunctionBase
*/
public function getDeclaringFunction()
{
$functionName = $this->reflection->getDeclaringFunctionName();
if ($className = $this->reflection->getDeclaringClassName()) {
return self::$parsedClasses[$className]->getMethod($functionName);
} else {
return self::$parsedFunctions[$functionName];
}
}
/**
* Returns the declaring function name.
*
* @return string
*/
public function getDeclaringFunctionName()
{
return $this->reflection->getDeclaringFunctionName();
}
/**
* Returns the function/method declaring class.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringClass()
{
$className = $this->reflection->getDeclaringClassName();
return null === $className ? null : self::$parsedClasses[$className];
}
/**
* Returns the declaring class name.
*
* @return string|null
*/
public function getDeclaringClassName()
{
return $this->reflection->getDeclaringClassName();
}
/**
* If the parameter can be used unlimited.
*
* @return boolean
*/
public function isUnlimited()
{
return false;
}
}

View File

@ -0,0 +1,479 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use TokenReflection;
/**
* Envelope for parameters that are defined only in @param or @method annotation.
*/
class ReflectionParameterMagic extends ReflectionParameter
{
/**
* Parameter name.
*
* @var string
*/
protected $name;
/**
* Defines a type hint of parameter values.
*
* @var string
*/
protected $typeHint;
/**
* Position of the parameter in the function/method.
*
* @var integer
*/
protected $position;
/**
* The part of the source code defining the parameter default value.
*
* @var boolean
*/
protected $defaultValueDefinition;
/**
* If the parameter can be used unlimited times.
*
* @var boolean
*/
protected $unlimited;
/**
* If the parameter value is passed by reference.
*
* @var boolean
*/
protected $passedByReference;
/**
* The declaring function.
*
* @var \ApiGen\ReflectionFunctionBase
*/
protected $declaringFunction;
/**
* Constructor.
*
* @param \TokenReflection\IReflection $reflection Inspected reflection
* @param \ApiGen\Generator $generator ApiGen generator
*/
public function __construct(IReflection $reflection = null, Generator $generator = null)
{
$this->reflectionType = get_class($this);
if (!isset(self::$reflectionMethods[$this->reflectionType])) {
self::$reflectionMethods[$this->reflectionType] = array_flip(get_class_methods($this));
}
}
/**
* Sets parameter name.
*
* @param string $name
* @return \ApiGen\ReflectionParameterMagic
*/
public function setName($name)
{
$this->name = (string) $name;
return $this;
}
/**
* Sets type hint.
*
* @param string $typeHint
* @return \ApiGen\ReflectionParameterMagic
*/
public function setTypeHint($typeHint)
{
$this->typeHint = (string) $typeHint;
return $this;
}
/**
* Sets position of the parameter in the function/method.
*
* @param integer $position
* @return \ApiGen\ReflectionParameterMagic
*/
public function setPosition($position)
{
$this->position = (int) $position;
return $this;
}
/**
* Sets the part of the source code defining the parameter default value.
*
* @param string|null $defaultValueDefinition
* @return \ApiGen\ReflectionParameterMagic
*/
public function setDefaultValueDefinition($defaultValueDefinition)
{
$this->defaultValueDefinition = $defaultValueDefinition;
return $this;
}
/**
* Sets if the parameter can be used unlimited times.
*
* @param boolean $unlimited
* @return \ApiGen\ReflectionParameterMagic
*/
public function setUnlimited($unlimited)
{
$this->unlimited = (bool) $unlimited;
return $this;
}
/**
* Sets if the parameter value is passed by reference.
*
* @param boolean $passedByReference
* @return \ApiGen\ReflectionParameterMagic
*/
public function setPassedByReference($passedByReference)
{
$this->passedByReference = (bool) $passedByReference;
return $this;
}
/**
* Sets declaring function.
*
* @param \ApiGen\ReflectionFunctionBase $declaringFunction
* @return \ApiGen\ReflectionParameterMagic
*/
public function setDeclaringFunction(ReflectionFunctionBase $declaringFunction)
{
$this->declaringFunction = $declaringFunction;
return $this;
}
/**
* Returns the reflection broker used by this reflection object.
*
* @return \TokenReflection\Broker
*/
public function getBroker()
{
return $this->declaringFunction->getBroker();
}
/**
* Returns the name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Returns the type hint.
*
* @return string
*/
public function getTypeHint()
{
return $this->typeHint;
}
/**
* Returns the file name the parameter is defined in.
*
* @return string
*/
public function getFileName()
{
return $this->declaringFunction->getFileName();
}
/**
* Returns if the reflection object is internal.
*
* @return boolean
*/
public function isInternal()
{
return false;
}
/**
* Returns if the reflection object is user defined.
*
* @return boolean
*/
public function isUserDefined()
{
return true;
}
/**
* Returns if the current reflection comes from a tokenized source.
*
* @return boolean
*/
public function isTokenized()
{
return true;
}
/**
* Returns an element pretty (docblock compatible) name.
*
* @return string
*/
public function getPrettyName()
{
return str_replace('()', '($' . $this->name . ')', $this->declaringFunction->getPrettyName());
}
/**
* Returns the declaring class.
*
* @return \Apigen\ReflectionClass|null
*/
public function getDeclaringClass()
{
return $this->declaringFunction->getDeclaringClass();
}
/**
* Returns the declaring class name.
*
* @return string|null
*/
public function getDeclaringClassName()
{
return $this->declaringFunction->getDeclaringClassName();
}
/**
* Returns the declaring function.
*
* @return \ApiGen\ReflectionFunctionBase
*/
public function getDeclaringFunction()
{
return $this->declaringFunction;
}
/**
* Returns the declaring function name.
*
* @return string
*/
public function getDeclaringFunctionName()
{
return $this->declaringFunction->getName();
}
/**
* Returns the definition start line number in the file.
*
* @return integer
*/
public function getStartLine()
{
return $this->declaringFunction->getStartLine();
}
/**
* Returns the definition end line number in the file.
*
* @return integer
*/
public function getEndLine()
{
return $this->declaringFunction->getEndLine();
}
/**
* Returns the appropriate docblock definition.
*
* @return string|boolean
*/
public function getDocComment()
{
return false;
}
/**
* Returns the part of the source code defining the parameter default value.
*
* @return string
*/
public function getDefaultValueDefinition()
{
return $this->defaultValueDefinition;
}
/**
* Returns if a default value for the parameter is available.
*
* @return boolean
*/
public function isDefaultValueAvailable()
{
return null !== $this->defaultValueDefinition;
}
/**
* Returns the position within all parameters.
*
* @return integer
*/
public function getPosition()
{
return $this->position;
}
/**
* Returns if the parameter expects an array.
*
* @return boolean
*/
public function isArray()
{
return TokenReflection\ReflectionParameter::ARRAY_TYPE_HINT === $this->typeHint;
}
public function isCallable()
{
return TokenReflection\ReflectionParameter::CALLABLE_TYPE_HINT === $this->typeHint;
}
/**
* Returns reflection of the required class of the value.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getClass()
{
$className = $this->getClassName();
return null === $className ? null : self::$parsedClasses[$className];
}
/**
* Returns the required class name of the value.
*
* @return string|null
*/
public function getClassName()
{
if ($this->isArray() || $this->isCallable()) {
return null;
}
if (isset(self::$parsedClasses[$this->typeHint])) {
return $typeHint;
}
return null;
}
/**
* Returns if the the parameter allows NULL.
*
* @return boolean
*/
public function allowsNull()
{
if ($this->isArray() || $this->isCallable()) {
return 'null' === strtolower($this->defaultValueDefinition);
}
return !empty($this->defaultValueDefinition);
}
/**
* Returns if the parameter is optional.
*
* @return boolean
*/
public function isOptional()
{
return $this->isDefaultValueAvailable();
}
/**
* Returns if the parameter value is passed by reference.
*
* @return boolean
*/
public function isPassedByReference()
{
return $this->passedByReference;
}
/**
* Returns if the parameter value can be passed by value.
*
* @return boolean
*/
public function canBePassedByValue()
{
return false;
}
/**
* Returns if the parameter can be used unlimited times.
*
* @return boolean
*/
public function isUnlimited()
{
return $this->unlimited;
}
/**
* Retrieves a property or method value.
*
* @param string $name Property name
* @return mixed
*/
public function __get($name)
{
$key = ucfirst($name);
if (isset(self::$reflectionMethods[$this->reflectionType]['get' . $key])) {
return $this->{'get' . $key}();
}
if (isset(self::$reflectionMethods[$this->reflectionType]['is' . $key])) {
return $this->{'is' . $key}();
}
return null;
}
/**
* Checks if the given property exists.
*
* @param mixed $name Property name
* @return boolean
*/
public function __isset($name)
{
$key = ucfirst($name);
return isset(self::$reflectionMethods[$this->reflectionType]['get' . $key]) || isset(self::$reflectionMethods[$this->reflectionType]['is' . $key]);
}
}

View File

@ -0,0 +1,214 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
/**
* Property reflection envelope.
*
* Alters TokenReflection\IReflectionProperty functionality for ApiGen.
*/
class ReflectionProperty extends ReflectionElement
{
/**
* Returns if the property is read-only.
*
* @return boolean
*/
public function isReadOnly()
{
return false;
}
/**
* Returns if the property is write-only.
*
* @return boolean
*/
public function isWriteOnly()
{
return false;
}
/**
* Returns if the property is magic.
*
* @return boolean
*/
public function isMagic()
{
return false;
}
/**
* Returns property type hint.
*
* @return string
*/
public function getTypeHint()
{
if ($annotations = $this->getAnnotation('var')) {
list($types) = preg_split('~\s+|$~', $annotations[0], 2);
if (!empty($types) && '$' !== $types[0]) {
return $types;
}
}
try {
$type = gettype($this->getDefaultValue());
if ('null' !== strtolower($type)) {
return $type;
}
} catch (\Exception $e) {
// Nothing
}
return 'mixed';
}
/**
* Returns the property declaring class.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringClass()
{
$className = $this->reflection->getDeclaringClassName();
return null === $className ? null : self::$parsedClasses[$className];
}
/**
* Returns the name of the declaring class.
*
* @return string
*/
public function getDeclaringClassName()
{
return $this->reflection->getDeclaringClassName();
}
/**
* Returns the property default value.
*
* @return mixed
*/
public function getDefaultValue()
{
return $this->reflection->getDefaultValue();
}
/**
* Returns the part of the source code defining the property default value.
*
* @return string
*/
public function getDefaultValueDefinition()
{
return $this->reflection->getDefaultValueDefinition();
}
/**
* Returns if the property was created at compile time.
*
* @return boolean
*/
public function isDefault()
{
return $this->reflection->isDefault();
}
/**
* Returns property modifiers.
*
* @return integer
*/
public function getModifiers()
{
return $this->reflection->getModifiers();
}
/**
* Returns if the property is private.
*
* @return boolean
*/
public function isPrivate()
{
return $this->reflection->isPrivate();
}
/**
* Returns if the property is protected.
*
* @return boolean
*/
public function isProtected()
{
return $this->reflection->isProtected();
}
/**
* Returns if the property is public.
*
* @return boolean
*/
public function isPublic()
{
return $this->reflection->isPublic();
}
/**
* Returns if the poperty is static.
*
* @return boolean
*/
public function isStatic()
{
return $this->reflection->isStatic();
}
/**
* Returns the property declaring trait.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringTrait()
{
$traitName = $this->reflection->getDeclaringTraitName();
return null === $traitName ? null : self::$parsedClasses[$traitName];
}
/**
* Returns the declaring trait name.
*
* @return string|null
*/
public function getDeclaringTraitName()
{
return $this->reflection->getDeclaringTraitName();
}
/**
* Returns if the property is valid.
*
* @return boolean
*/
public function isValid()
{
if ($class = $this->getDeclaringClass()) {
return $class->isValid();
}
return true;
}
}

View File

@ -0,0 +1,651 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use ReflectionProperty as InternalReflectionProperty;
/**
* Envelope for magic properties that are defined
* only as @property, @property-read or @property-write annotation.
*/
class ReflectionPropertyMagic extends ReflectionProperty
{
/**
* Property name.
*
* @var string
*/
protected $name;
/**
* Defines a type hint of parameter values.
*
* @var string
*/
protected $typeHint;
/**
* Short description.
*
* @var string
*/
protected $shortDescription;
/**
* Start line number in the file.
*
* @var integer
*/
protected $startLine;
/**
* End line number in the file.
*
* @var integer
*/
protected $endLine;
/**
* If the property is read-only.
*
* @var boolean
*/
protected $readOnly;
/**
* If the property is write-only.
*
* @var boolean
*/
protected $writeOnly;
/**
* The declaring class.
*
* @var \ApiGen\ReflectionClass
*/
protected $declaringClass;
/**
* Constructor.
*
* @param \TokenReflection\IReflection $reflection Inspected reflection
* @param \ApiGen\Generator $generator ApiGen generator
*/
public function __construct(IReflection $reflection = null, Generator $generator = null)
{
$this->reflectionType = get_class($this);
if (!isset(self::$reflectionMethods[$this->reflectionType])) {
self::$reflectionMethods[$this->reflectionType] = array_flip(get_class_methods($this));
}
}
/**
* Sets property name.
*
* @param string $name
* @return \Apigen\ReflectionPropertyMagic
*/
public function setName($name)
{
$this->name = (string) $name;
return $this;
}
/**
* Sets type hint.
*
* @param string $typeHint
* @return \ApiGen\ReflectionParameterUnlimited
*/
public function setTypeHint($typeHint)
{
$this->typeHint = (string) $typeHint;
return $this;
}
/**
* Sets short description.
*
* @param string $shortDescription
* @return \Apigen\ReflectionPropertyMagic
*/
public function setShortDescription($shortDescription)
{
$this->shortDescription = (string) $shortDescription;
return $this;
}
/**
* Sets start line.
*
* @param integer $startLine
* @return \Apigen\ReflectionPropertyMagic
*/
public function setStartLine($startLine)
{
$this->startLine = (int) $startLine;
return $this;
}
/**
* Sets end line.
*
* @param integer $endLine
* @return \Apigen\ReflectionPropertyMagic
*/
public function setEndLine($endLine)
{
$this->endLine = (int) $endLine;
return $this;
}
/**
* Sets if the property is read-only.
*
* @param boolean $readOnly
* @return \Apigen\ReflectionPropertyMagic
*/
public function setReadOnly($readOnly)
{
$this->readOnly = (bool) $readOnly;
return $this;
}
/**
* Sets if the property is write only.
*
* @param boolean $writeOnly
* @return \Apigen\ReflectionPropertyMagic
*/
public function setWriteOnly($writeOnly)
{
$this->writeOnly = (bool) $writeOnly;
return $this;
}
/**
* Sets declaring class.
*
* @param \ApiGen\ReflectionClass $declaringClass
* @return \ApiGen\ReflectionPropertyMagic
*/
public function setDeclaringClass(ReflectionClass $declaringClass)
{
$this->declaringClass = $declaringClass;
return $this;
}
/**
* Returns the reflection broker used by this reflection object.
*
* @return \TokenReflection\Broker
*/
public function getBroker()
{
return $this->declaringClass->getBroker();
}
/**
* Returns the start position in the file token stream.
*
* @return integer
*/
public function getStartPosition()
{
return $this->declaringClass->getStartPosition();
}
/**
* Returns the end position in the file token stream.
*
* @return integer
*/
public function getEndPosition()
{
return $this->declaringClass->getEndPosition();
}
/**
* Returns the name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Returns the type hint.
*
* @return string
*/
public function getTypeHint()
{
return $this->typeHint;
}
/**
* Returns the short description.
*
* @return string
*/
public function getShortDescription()
{
return $this->shortDescription;
}
/**
* Returns the long description.
*
* @return string
*/
public function getLongDescription()
{
return $this->shortDescription;
}
/**
* Returns the definition start line number in the file.
*
* @return integer
*/
public function getStartLine()
{
return $this->startLine;
}
/**
* Returns the definition end line number in the file.
*
* @return integer
*/
public function getEndLine()
{
return $this->endLine;
}
/**
* Returns if the property is read-only.
*
* @return boolean
*/
public function isReadOnly()
{
return $this->readOnly;
}
/**
* Returns if the property is write-only.
*
* @return boolean
*/
public function isWriteOnly()
{
return $this->writeOnly;
}
/**
* Returns if the property is magic.
*
* @return boolean
*/
public function isMagic()
{
return true;
}
/**
* Returns the PHP extension reflection.
*
* @return \ApiGen\ReflectionExtension|null
*/
public function getExtension()
{
return null;
}
/**
* Returns the PHP extension name.
*
* @return boolean
*/
public function getExtensionName()
{
return false;
}
/**
* Returns if the property should be documented.
*
* @return boolean
*/
public function isDocumented()
{
if (null === $this->isDocumented) {
$this->isDocumented = self::$config->deprecated || !$this->isDeprecated();
}
return $this->isDocumented;
}
/**
* Returns if the property is deprecated.
*
* @return boolean
*/
public function isDeprecated()
{
return $this->declaringClass->isDeprecated();
}
/**
* Returns property package name (including subpackage name).
*
* @return string
*/
public function getPackageName()
{
return $this->declaringClass->getPackageName();
}
/**
* Returns property namespace name.
*
* @return string
*/
public function getNamespaceName()
{
return $this->declaringClass->getNamespaceName();
}
/**
* Returns property annotations.
*
* @return array
*/
public function getAnnotations()
{
if (null === $this->annotations) {
$this->annotations = array();
}
return $this->annotations;
}
/**
* Returns the property declaring class.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringClass()
{
return $this->declaringClass;
}
/**
* Returns the name of the declaring class.
*
* @return string
*/
public function getDeclaringClassName()
{
return $this->declaringClass->getName();
}
/**
* Returns the property default value.
*
* @return mixed
*/
public function getDefaultValue()
{
return null;
}
/**
* Returns the part of the source code defining the property default value.
*
* @return string
*/
public function getDefaultValueDefinition()
{
return '';
}
/**
* Returns if the property was created at compile time.
*
* @return boolean
*/
public function isDefault()
{
return false;
}
/**
* Returns property modifiers.
*
* @return integer
*/
public function getModifiers()
{
return InternalReflectionProperty::IS_PUBLIC;
}
/**
* Returns if the property is private.
*
* @return boolean
*/
public function isPrivate()
{
return false;
}
/**
* Returns if the property is protected.
*
* @return boolean
*/
public function isProtected()
{
return false;
}
/**
* Returns if the property is public.
*
* @return boolean
*/
public function isPublic()
{
return true;
}
/**
* Returns if the poperty is static.
*
* @return boolean
*/
public function isStatic()
{
return false;
}
/**
* Returns if the property is internal.
*
* @return boolean
*/
public function isInternal()
{
return false;
}
/**
* Returns the property declaring trait.
*
* @return \ApiGen\ReflectionClass|null
*/
public function getDeclaringTrait()
{
return $this->declaringClass->isTrait() ? $this->declaringClass : null;
}
/**
* Returns the declaring trait name.
*
* @return string|null
*/
public function getDeclaringTraitName()
{
if ($declaringTrait = $this->getDeclaringTrait()) {
return $declaringTrait->getName();
}
return null;
}
/**
* Returns imported namespaces and aliases from the declaring namespace.
*
* @return array
*/
public function getNamespaceAliases()
{
return $this->declaringClass->getNamespaceAliases();
}
/**
* Returns an property pretty (docblock compatible) name.
*
* @return string
*/
public function getPrettyName()
{
return sprintf('%s::$%s', $this->declaringClass->getName(), $this->name);
}
/**
* Returns the file name the property is defined in.
*
* @return string
*/
public function getFileName()
{
return $this->declaringClass->getFileName();
}
/**
* Returns if the property is user defined.
* @return boolean
*/
public function isUserDefined()
{
return true;
}
/**
* Returns if the property comes from a tokenized source.
*
* @return boolean
*/
public function isTokenized()
{
return true;
}
/**
* Returns the appropriate docblock definition.
*
* @return string|boolean
*/
public function getDocComment()
{
$docComment = "/**\n";
if (!empty($this->shortDescription)) {
$docComment .= $this->shortDescription . "\n\n";
}
if ($annotations = $this->getAnnotation('var')) {
$docComment .= sprintf("@var %s\n", $annotations[0]);
}
$docComment .= "*/\n";
return $docComment;
}
/**
* Checks if there is a particular annotation.
*
* @param string $name Annotation name
* @return boolean
*/
public function hasAnnotation($name)
{
$annotations = $this->getAnnotations();
return array_key_exists($name, $annotations);
}
/**
* Returns a particular annotation value.
*
* @param string $name Annotation name
* @return string|array|null
*/
public function getAnnotation($name)
{
$annotations = $this->getAnnotations();
if (array_key_exists($name, $annotations)) {
return $annotations[$name];
}
return null;
}
/**
* Retrieves a property or method value.
*
* @param string $name Property name
* @return mixed
*/
public function __get($name)
{
$key = ucfirst($name);
if (isset(self::$reflectionMethods[$this->reflectionType]['get' . $key])) {
return $this->{'get' . $key}();
}
if (isset(self::$reflectionMethods[$this->reflectionType]['is' . $key])) {
return $this->{'is' . $key}();
}
return null;
}
/**
* Checks if the given property exists.
*
* @param mixed $name Property name
* @return boolean
*/
public function __isset($name)
{
$key = ucfirst($name);
return isset(self::$reflectionMethods[$this->reflectionType]['get' . $key]) || isset(self::$reflectionMethods[$this->reflectionType]['is' . $key]);
}
}

View File

@ -0,0 +1,75 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use RecursiveDirectoryIterator;
use RecursiveFilterIterator;
/**
* Filters excluded files and directories.
*/
class SourceFilesFilterIterator extends RecursiveFilterIterator
{
/**
* File/directory exclude masks.
*
* @var array
*/
private $excludeMasks;
/**
* Creates the iterator.
*
* @param \RecursiveDirectoryIterator $iterator Directory iterator
* @param array $excludeMasks File/directory exlude masks
*/
public function __construct(RecursiveDirectoryIterator $iterator, array $excludeMasks)
{
parent::__construct($iterator);
$this->excludeMasks = $excludeMasks;
}
/**
* Returns if the current file/directory should be processed.
*
* @return boolean
*/
public function accept() {
/** @var \SplFileInfo */
$current = $this->current();
foreach ($this->excludeMasks as $mask) {
if (fnmatch($mask, $current->getPathName(), FNM_NOESCAPE)) {
return false;
}
}
if (!is_readable($current->getPathname())) {
throw new \InvalidArgumentException(sprintf('File/directory "%s" is not readable.', $current->getPathname()));
}
return true;
}
/**
* Returns the iterator of the current element's children.
*
* @return \ApiGen\SourceFilesFilterIterator
*/
public function getChildren()
{
return new static($this->getInnerIterator()->getChildren(), $this->excludeMasks);
}
}

809
apigen/ApiGen/Template.php Normal file
View File

@ -0,0 +1,809 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use Nette, FSHL;
/**
* Customized ApiGen template class.
*
* Adds ApiGen helpers to the Nette\Templating\FileTemplate parent class.
*/
class Template extends Nette\Templating\FileTemplate
{
/**
* Generator.
*
* @var \ApiGen\Generator
*/
private $generator;
/**
* Config.
*
* @var \ApiGen\Config
*/
private $config;
/**
* Texy.
*
* @var Texy
*/
private $texy;
/**
* Creates template.
*
* @param \ApiGen\Generator $generator
*/
public function __construct(Generator $generator)
{
$this->generator = $generator;
$this->config = $generator->getConfig();
$that = $this;
// Output in HTML5
Nette\Utils\Html::$xhtml = false;
// FSHL
$fshl = new FSHL\Highlighter(new FSHL\Output\Html());
$fshl->setLexer(new FSHL\Lexer\Php());
// Texy
$this->texy = new \Texy();
$this->texy->allowedTags = array_flip($this->config->allowedHtml);
$this->texy->allowed['list/definition'] = false;
$this->texy->allowed['phrase/em-alt'] = false;
$this->texy->allowed['longwords'] = false;
$this->texy->allowed['typography'] = false;
$this->texy->linkModule->shorten = false;
// Highlighting <code>, <pre>
$this->texy->addHandler('beforeParse', function($texy, &$text, $singleLine) {
$text = preg_replace('~<code>(.+?)</code>~', '#code#\\1#/code#', $text);
});
$this->texy->registerLinePattern(
function($parser, $matches, $name) use ($fshl) {
return \TexyHtml::el('code', $fshl->highlight($matches[1]));
},
'~#code#(.+?)#/code#~',
'codeInlineSyntax'
);
$this->texy->registerBlockPattern(
function($parser, $matches, $name) use ($fshl) {
if ('code' === $matches[1]) {
$lines = array_filter(explode("\n", $matches[2]));
if (!empty($lines)) {
$firstLine = array_shift($lines);
$indent = '';
$li = 0;
while (isset($firstLine[$li]) && preg_match('~\s~', $firstLine[$li])) {
foreach ($lines as $line) {
if (!isset($line[$li]) || $firstLine[$li] !== $line[$li]) {
break 2;
}
}
$indent .= $firstLine[$li++];
}
if (!empty($indent)) {
$matches[2] = str_replace(
"\n" . $indent,
"\n",
0 === strpos($matches[2], $indent) ? substr($matches[2], $li) : $matches[2]
);
}
}
$content = $fshl->highlight($matches[2]);
} else {
$content = htmlspecialchars($matches[2]);
}
$content = $parser->getTexy()->protect($content, \Texy::CONTENT_BLOCK);
return \TexyHtml::el('pre', $content);
},
'~<(code|pre)>(.+?)</\1>~s',
'codeBlockSyntax'
);
// Common operations
$this->registerHelperLoader('Nette\Templating\Helpers::loader');
// PHP source highlight
$this->registerHelper('highlightPHP', function($source, $context) use ($that, $fshl) {
return $that->resolveLink($that->getTypeName($source), $context) ?: $fshl->highlight((string) $source);
});
$this->registerHelper('highlightValue', function($definition, $context) use ($that) {
return $that->highlightPHP(preg_replace('~^(?:[ ]{4}|\t)~m', '', $definition), $context);
});
// Urls
$this->registerHelper('packageUrl', new Nette\Callback($this, 'getPackageUrl'));
$this->registerHelper('namespaceUrl', new Nette\Callback($this, 'getNamespaceUrl'));
$this->registerHelper('groupUrl', new Nette\Callback($this, 'getGroupUrl'));
$this->registerHelper('classUrl', new Nette\Callback($this, 'getClassUrl'));
$this->registerHelper('methodUrl', new Nette\Callback($this, 'getMethodUrl'));
$this->registerHelper('propertyUrl', new Nette\Callback($this, 'getPropertyUrl'));
$this->registerHelper('constantUrl', new Nette\Callback($this, 'getConstantUrl'));
$this->registerHelper('functionUrl', new Nette\Callback($this, 'getFunctionUrl'));
$this->registerHelper('elementUrl', new Nette\Callback($this, 'getElementUrl'));
$this->registerHelper('sourceUrl', new Nette\Callback($this, 'getSourceUrl'));
$this->registerHelper('manualUrl', new Nette\Callback($this, 'getManualUrl'));
// Packages & namespaces
$this->registerHelper('packageLinks', new Nette\Callback($this, 'getPackageLinks'));
$this->registerHelper('namespaceLinks', new Nette\Callback($this, 'getNamespaceLinks'));
$this->registerHelper('subgroupName', function($groupName) {
if ($pos = strrpos($groupName, '\\')) {
return substr($groupName, $pos + 1);
}
return $groupName;
});
// Types
$this->registerHelper('typeLinks', new Nette\Callback($this, 'getTypeLinks'));
// Docblock descriptions
$this->registerHelper('description', function($annotation, $context) use ($that) {
$description = trim(strpbrk($annotation, "\n\r\t $"));
if ($context instanceof ReflectionParameter) {
$description = preg_replace('~^(\\$' . $context->getName() . '(?:,\\.{3})?)(\s+|$)~i', '\\2', $description, 1);
$context = $context->getDeclaringFunction();
}
return $that->doc($description, $context);
});
$this->registerHelper('shortDescription', function($element, $block = false) use ($that) {
return $that->doc($element->getShortDescription(), $element, $block);
});
$this->registerHelper('longDescription', function($element) use ($that) {
$long = $element->getLongDescription();
// Merge lines
$long = preg_replace_callback('~(?:<(code|pre)>.+?</\1>)|([^<]*)~s', function($matches) {
return !empty($matches[2])
? preg_replace('~\n(?:\t|[ ])+~', ' ', $matches[2])
: $matches[0];
}, $long);
return $that->doc($long, $element, true);
});
// Individual annotations processing
$this->registerHelper('annotation', function($value, $name, $context) use ($that, $generator) {
switch ($name) {
case 'param':
case 'return':
case 'throws':
$description = $that->description($value, $context);
return sprintf('<code>%s</code>%s', $that->getTypeLinks($value, $context), $description ? '<br>' . $description : '');
case 'license':
list($url, $description) = $that->split($value);
return $that->link($url, $description ?: $url);
case 'link':
list($url, $description) = $that->split($value);
if (Nette\Utils\Validators::isUrl($url)) {
return $that->link($url, $description ?: $url);
}
break;
case 'see':
$doc = array();
foreach (preg_split('~\\s*,\\s*~', $value) as $link) {
if (null !== $generator->resolveElement($link, $context)) {
$doc[] = sprintf('<code>%s</code>', $that->getTypeLinks($link, $context));
} else {
$doc[] = $that->doc($link, $context);
}
}
return implode(', ', $doc);
case 'uses':
case 'usedby':
list($link, $description) = $that->split($value);
$separator = $context instanceof ReflectionClass || !$description ? ' ' : '<br>';
if (null !== $generator->resolveElement($link, $context)) {
return sprintf('<code>%s</code>%s%s', $that->getTypeLinks($link, $context), $separator, $description);
}
break;
default:
break;
}
// Default
return $that->doc($value, $context);
});
$todo = $this->config->todo;
$internal = $this->config->internal;
$this->registerHelper('annotationFilter', function(array $annotations, array $filter = array()) use ($todo, $internal) {
// Filtered, unsupported or deprecated annotations
static $filtered = array(
'package', 'subpackage', 'property', 'property-read', 'property-write', 'method', 'abstract',
'access', 'final', 'filesource', 'global', 'name', 'static', 'staticvar'
);
foreach ($filtered as $annotation) {
unset($annotations[$annotation]);
}
// Custom filter
foreach ($filter as $annotation) {
unset($annotations[$annotation]);
}
// Show/hide internal
if (!$internal) {
unset($annotations['internal']);
}
// Show/hide tasks
if (!$todo) {
unset($annotations['todo']);
}
return $annotations;
});
$this->registerHelper('annotationSort', function(array $annotations) {
uksort($annotations, function($one, $two) {
static $order = array(
'deprecated' => 0, 'category' => 1, 'copyright' => 2, 'license' => 3, 'author' => 4, 'version' => 5,
'since' => 6, 'see' => 7, 'uses' => 8, 'usedby' => 9, 'link' => 10, 'internal' => 11,
'example' => 12, 'tutorial' => 13, 'todo' => 14
);
if (isset($order[$one], $order[$two])) {
return $order[$one] - $order[$two];
} elseif (isset($order[$one])) {
return -1;
} elseif (isset($order[$two])) {
return 1;
} else {
return strcasecmp($one, $two);
}
});
return $annotations;
});
$this->registerHelper('annotationBeautify', function($annotation) {
static $names = array(
'usedby' => 'Used by'
);
if (isset($names[$annotation])) {
return $names[$annotation];
}
return Nette\Utils\Strings::firstUpper($annotation);
});
// Static files versioning
$destination = $this->config->destination;
$this->registerHelper('staticFile', function($name) use ($destination) {
static $versions = array();
$filename = $destination . DIRECTORY_SEPARATOR . $name;
if (!isset($versions[$filename]) && is_file($filename)) {
$versions[$filename] = sprintf('%u', crc32(file_get_contents($filename)));
}
if (isset($versions[$filename])) {
$name .= '?' . $versions[$filename];
}
return $name;
});
// Source anchors
$this->registerHelper('sourceAnchors', function($source) {
// Classes, interfaces, traits and exceptions
$source = preg_replace_callback('~(<span\\s+class="php-keyword1">(?:class|interface|trait)</span>\\s+)(\\w+)~i', function($matches) {
$link = sprintf('<a id="%1$s" href="#%1$s">%1$s</a>', $matches[2]);
return $matches[1] . $link;
}, $source);
// Methods and functions
$source = preg_replace_callback('~(<span\\s+class="php-keyword1">function</span>\\s+)(\\w+)~i', function($matches) {
$link = sprintf('<a id="_%1$s" href="#_%1$s">%1$s</a>', $matches[2]);
return $matches[1] . $link;
}, $source);
// Constants
$source = preg_replace_callback('~(<span class="php-keyword1">const</span>)(.*?)(;)~is', function($matches) {
$links = preg_replace_callback('~(\\s|,)([A-Z_]+)(\\s+=)~', function($matches) {
return $matches[1] . sprintf('<a id="%1$s" href="#%1$s">%1$s</a>', $matches[2]) . $matches[3];
}, $matches[2]);
return $matches[1] . $links . $matches[3];
}, $source);
// Properties
$source = preg_replace_callback('~(<span\\s+class="php-keyword1">(?:private|protected|public|var|static)</span>\\s+)(<span\\s+class="php-var">.*?)(;)~is', function($matches) {
$links = preg_replace_callback('~(<span\\s+class="php-var">)(\\$\\w+)~i', function($matches) {
return $matches[1] . sprintf('<a id="%1$s" href="#%1$s">%1$s</a>', $matches[2]);
}, $matches[2]);
return $matches[1] . $links . $matches[3];
}, $source);
return $source;
});
$this->registerHelper('urlize', array($this, 'urlize'));
$this->registerHelper('relativePath', array($generator, 'getRelativePath'));
$this->registerHelper('resolveElement', array($generator, 'resolveElement'));
$this->registerHelper('getClass', array($generator, 'getClass'));
}
/**
* Returns unified type value definition (class name or member data type).
*
* @param string $name
* @param boolean $trimNamespaceSeparator
* @return string
*/
public function getTypeName($name, $trimNamespaceSeparator = true)
{
static $names = array(
'int' => 'integer',
'bool' => 'boolean',
'double' => 'float',
'void' => '',
'FALSE' => 'false',
'TRUE' => 'true',
'NULL' => 'null',
'callback' => 'callable'
);
// Simple type
if (isset($names[$name])) {
return $names[$name];
}
// Class, constant or function
return $trimNamespaceSeparator ? ltrim($name, '\\') : $name;
}
/**
* Returns links for types.
*
* @param string $annotation
* @param \ApiGen\ReflectionElement $context
* @return string
*/
public function getTypeLinks($annotation, ReflectionElement $context)
{
$links = array();
list($types) = $this->split($annotation);
if (!empty($types) && '$' === $types{0}) {
$types = null;
}
if (empty($types)) {
$types = 'mixed';
}
foreach (explode('|', $types) as $type) {
$type = $this->getTypeName($type, false);
$links[] = $this->resolveLink($type, $context) ?: $this->escapeHtml(ltrim($type, '\\'));
}
return implode('|', $links);
}
/**
* Returns links for package/namespace and its parent packages.
*
* @param string $package
* @param boolean $last
* @return string
*/
public function getPackageLinks($package, $last = true)
{
if (empty($this->packages)) {
return $package;
}
$links = array();
$parent = '';
foreach (explode('\\', $package) as $part) {
$parent = ltrim($parent . '\\' . $part, '\\');
$links[] = $last || $parent !== $package
? $this->link($this->getPackageUrl($parent), $part)
: $this->escapeHtml($part);
}
return implode('\\', $links);
}
/**
* Returns links for namespace and its parent namespaces.
*
* @param string $namespace
* @param boolean $last
* @return string
*/
public function getNamespaceLinks($namespace, $last = true)
{
if (empty($this->namespaces)) {
return $namespace;
}
$links = array();
$parent = '';
foreach (explode('\\', $namespace) as $part) {
$parent = ltrim($parent . '\\' . $part, '\\');
$links[] = $last || $parent !== $namespace
? $this->link($this->getNamespaceUrl($parent), $part)
: $this->escapeHtml($part);
}
return implode('\\', $links);
}
/**
* Returns a link to a namespace summary file.
*
* @param string $namespaceName Namespace name
* @return string
*/
public function getNamespaceUrl($namespaceName)
{
return sprintf($this->config->template['templates']['main']['namespace']['filename'], $this->urlize($namespaceName));
}
/**
* Returns a link to a package summary file.
*
* @param string $packageName Package name
* @return string
*/
public function getPackageUrl($packageName)
{
return sprintf($this->config->template['templates']['main']['package']['filename'], $this->urlize($packageName));
}
/**
* Returns a link to a group summary file.
*
* @param string $groupName Group name
* @return string
*/
public function getGroupUrl($groupName)
{
if (!empty($this->packages)) {
return $this->getPackageUrl($groupName);
}
return $this->getNamespaceUrl($groupName);
}
/**
* Returns a link to class summary file.
*
* @param string|\ApiGen\ReflectionClass $class Class reflection or name
* @return string
*/
public function getClassUrl($class)
{
$className = $class instanceof ReflectionClass ? $class->getName() : $class;
return sprintf($this->config->template['templates']['main']['class']['filename'], $this->urlize($className));
}
/**
* Returns a link to method in class summary file.
*
* @param \ApiGen\ReflectionMethod $method Method reflection
* @param \ApiGen\ReflectionClass $class Method declaring class
* @return string
*/
public function getMethodUrl(ReflectionMethod $method, ReflectionClass $class = null)
{
$className = null !== $class ? $class->getName() : $method->getDeclaringClassName();
return $this->getClassUrl($className) . '#' . ($method->isMagic() ? 'm' : '') . '_' . ($method->getOriginalName() ?: $method->getName());
}
/**
* Returns a link to property in class summary file.
*
* @param \ApiGen\ReflectionProperty $property Property reflection
* @param \ApiGen\ReflectionClass $class Property declaring class
* @return string
*/
public function getPropertyUrl(ReflectionProperty $property, ReflectionClass $class = null)
{
$className = null !== $class ? $class->getName() : $property->getDeclaringClassName();
return $this->getClassUrl($className) . '#' . ($property->isMagic() ? 'm' : '') . '$' . $property->getName();
}
/**
* Returns a link to constant in class summary file or to constant summary file.
*
* @param \ApiGen\ReflectionConstant $constant Constant reflection
* @return string
*/
public function getConstantUrl(ReflectionConstant $constant)
{
// Class constant
if ($className = $constant->getDeclaringClassName()) {
return $this->getClassUrl($className) . '#' . $constant->getName();
}
// Constant in namespace or global space
return sprintf($this->config->template['templates']['main']['constant']['filename'], $this->urlize($constant->getName()));
}
/**
* Returns a link to function summary file.
*
* @param \ApiGen\ReflectionFunction $function Function reflection
* @return string
*/
public function getFunctionUrl(ReflectionFunction $function)
{
return sprintf($this->config->template['templates']['main']['function']['filename'], $this->urlize($function->getName()));
}
/**
* Returns a link to element summary file.
*
* @param \ApiGen\ReflectionElement $element Element reflection
* @return string
*/
public function getElementUrl(ReflectionElement $element)
{
if ($element instanceof ReflectionClass) {
return $this->getClassUrl($element);
} elseif ($element instanceof ReflectionMethod) {
return $this->getMethodUrl($element);
} elseif ($element instanceof ReflectionProperty) {
return $this->getPropertyUrl($element);
} elseif ($element instanceof ReflectionConstant) {
return $this->getConstantUrl($element);
} elseif ($element instanceof ReflectionFunction) {
return $this->getFunctionUrl($element);
}
}
/**
* Returns a link to a element source code.
*
* @param \ApiGen\ReflectionElement $element Element reflection
* @param boolean $withLine Include file line number into the link
* @return string
*/
public function getSourceUrl(ReflectionElement $element, $withLine = true)
{
if ($element instanceof ReflectionClass || $element instanceof ReflectionFunction || ($element instanceof ReflectionConstant && null === $element->getDeclaringClassName())) {
$elementName = $element->getName();
if ($element instanceof ReflectionClass) {
$file = 'class-';
} elseif ($element instanceof ReflectionConstant) {
$file = 'constant-';
} elseif ($element instanceof ReflectionFunction) {
$file = 'function-';
}
} else {
$elementName = $element->getDeclaringClassName();
$file = 'class-';
}
$file .= $this->urlize($elementName);
$lines = null;
if ($withLine) {
$lines = $element->getStartLine() !== $element->getEndLine() ? sprintf('%s-%s', $element->getStartLine(), $element->getEndLine()) : $element->getStartLine();
}
return sprintf($this->config->template['templates']['main']['source']['filename'], $file) . (null !== $lines ? '#' . $lines : '');
}
/**
* Returns a link to a element documentation at php.net.
*
* @param \ApiGen\ReflectionBase $element Element reflection
* @return string
*/
public function getManualUrl(ReflectionBase $element)
{
static $manual = 'http://php.net/manual';
static $reservedClasses = array('stdClass', 'Closure', 'Directory');
// Extension
if ($element instanceof ReflectionExtension) {
$extensionName = strtolower($element->getName());
if ('core' === $extensionName) {
return $manual;
}
if ('date' === $extensionName) {
$extensionName = 'datetime';
}
return sprintf('%s/book.%s.php', $manual, $extensionName);
}
// Class and its members
$class = $element instanceof ReflectionClass ? $element : $element->getDeclaringClass();
if (in_array($class->getName(), $reservedClasses)) {
return $manual . '/reserved.classes.php';
}
$className = strtolower($class->getName());
$classUrl = sprintf('%s/class.%s.php', $manual, $className);
$elementName = strtolower(strtr(ltrim($element->getName(), '_'), '_', '-'));
if ($element instanceof ReflectionClass) {
return $classUrl;
} elseif ($element instanceof ReflectionMethod) {
return sprintf('%s/%s.%s.php', $manual, $className, $elementName);
} elseif ($element instanceof ReflectionProperty) {
return sprintf('%s#%s.props.%s', $classUrl, $className, $elementName);
} elseif ($element instanceof ReflectionConstant) {
return sprintf('%s#%s.constants.%s', $classUrl, $className, $elementName);
}
}
/**
* Tries to parse a definition of a class/method/property/constant/function and returns the appropriate link if successful.
*
* @param string $definition Definition
* @param \ApiGen\ReflectionElement $context Link context
* @return string|null
*/
public function resolveLink($definition, ReflectionElement $context)
{
if (empty($definition)) {
return null;
}
$suffix = '';
if ('[]' === substr($definition, -2)) {
$definition = substr($definition, 0, -2);
$suffix = '[]';
}
$element = $this->generator->resolveElement($definition, $context, $expectedName);
if (null === $element) {
return $expectedName;
}
$classes = array();
if ($element->isDeprecated()) {
$classes[] = 'deprecated';
}
if (!$element->isValid()) {
$classes[] = 'invalid';
}
if ($element instanceof ReflectionClass) {
$link = $this->link($this->getClassUrl($element), $element->getName(), true, $classes);
} elseif ($element instanceof ReflectionConstant && null === $element->getDeclaringClassName()) {
$text = $element->inNamespace()
? $this->escapeHtml($element->getNamespaceName()) . '\\<b>' . $this->escapeHtml($element->getShortName()) . '</b>'
: '<b>' . $this->escapeHtml($element->getName()) . '</b>';
$link = $this->link($this->getConstantUrl($element), $text, false, $classes);
} elseif ($element instanceof ReflectionFunction) {
$link = $this->link($this->getFunctionUrl($element), $element->getName() . '()', true, $classes);
} else {
$text = $this->escapeHtml($element->getDeclaringClassName());
if ($element instanceof ReflectionProperty) {
$url = $this->propertyUrl($element);
$text .= '::<var>$' . $this->escapeHtml($element->getName()) . '</var>';
} elseif ($element instanceof ReflectionMethod) {
$url = $this->methodUrl($element);
$text .= '::' . $this->escapeHtml($element->getName()) . '()';
} elseif ($element instanceof ReflectionConstant) {
$url = $this->constantUrl($element);
$text .= '::<b>' . $this->escapeHtml($element->getName()) . '</b>';
}
$link = $this->link($url, $text, false, $classes);
}
return sprintf('<code>%s</code>', $link . $suffix);
}
/**
* Resolves links in documentation.
*
* @param string $text Processed documentation text
* @param \ApiGen\ReflectionElement $context Reflection object
* @return string
*/
private function resolveLinks($text, ReflectionElement $context)
{
$that = $this;
return preg_replace_callback('~{@(?:link|see)\\s+([^}]+)}~', function ($matches) use ($context, $that) {
// Texy already added <a> so it has to be stripped
list($url, $description) = $that->split(strip_tags($matches[1]));
if (Nette\Utils\Validators::isUrl($url)) {
return $that->link($url, $description ?: $url);
}
return $that->resolveLink($matches[1], $context) ?: $matches[1];
}, $text);
}
/**
* Resolves internal annotation.
*
* @param string $text
* @return string
*/
private function resolveInternal($text)
{
$internal = $this->config->internal;
return preg_replace_callback('~\\{@(\\w+)(?:(?:\\s+((?>(?R)|[^{}]+)*)\\})|\\})~', function($matches) use ($internal) {
// Replace only internal
if ('internal' !== $matches[1]) {
return $matches[0];
}
return $internal && isset($matches[2]) ? $matches[2] : '';
}, $text);
}
/**
* Formats text as documentation block or line.
*
* @param string $text Text
* @param \ApiGen\ReflectionElement $context Reflection object
* @param boolean $block Parse text as block
* @return string
*/
public function doc($text, ReflectionElement $context, $block = false)
{
return $this->resolveLinks($this->texy->process($this->resolveInternal($text), !$block), $context);
}
/**
* Parses annotation value.
*
* @param string $value
* @return array
*/
public function split($value)
{
return preg_split('~\s+|$~', $value, 2);
}
/**
* Returns link.
*
* @param string $url
* @param string $text
* @param boolean $escape If the text should be escaped
* @param array $classes List of classes
* @return string
*/
public function link($url, $text, $escape = true, array $classes = array())
{
$class = !empty($classes) ? sprintf(' class="%s"', implode(' ', $classes)) : '';
return sprintf('<a href="%s"%s>%s</a>', $url, $class, $escape ? $this->escapeHtml($text) : $text);
}
/**
* Converts string to url safe characters.
*
* @param string $string
* @return string
*/
public function urlize($string)
{
return preg_replace('~[^\w]~', '.', $string);
}
}

90
apigen/ApiGen/Tree.php Normal file
View File

@ -0,0 +1,90 @@
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use RecursiveTreeIterator, RuntimeException;
/**
* Customized recursive tree iterator.
*/
class Tree extends RecursiveTreeIterator
{
/**
* Has a sibling on the same level.
*
* @var string
*/
const HAS_NEXT = '1';
/**
* Last item on the current level.
*
* @var string
*/
const LAST = '0';
/**
* Reflections in the tree.
*
* @var \ArrayObject
*/
private $reflections;
/**
* Constructor.
*
* @param array $treePart Part of the tree
* @param \ArrayObject $reflections Array of reflections in the tree part
*/
public function __construct(array $treePart, \ArrayObject $reflections)
{
parent::__construct(
new \RecursiveArrayIterator($treePart),
RecursiveTreeIterator::BYPASS_KEY,
null,
\RecursiveIteratorIterator::SELF_FIRST
);
$this->setPrefixPart(RecursiveTreeIterator::PREFIX_END_HAS_NEXT, self::HAS_NEXT);
$this->setPrefixPart(RecursiveTreeIterator::PREFIX_END_LAST, self::LAST);
$this->rewind();
$this->reflections = $reflections;
}
/**
* Returns if the current item has a sibling on the same level.
*
* @return boolean
*/
public function hasSibling()
{
$prefix = $this->getPrefix();
return !empty($prefix) && self::HAS_NEXT === substr($prefix, -1);
}
/**
* Returns the current reflection.
*
* @return \ApiGen\Reflection
* @throws \UnexpectedValueException If current is not reflection array.
*/
public function current()
{
$className = $this->key();
if (!isset($this->reflections[$className])) {
throw new RuntimeException(sprintf('Class "%s" is not in the reflection array', $className));
}
return $this->reflections[$className];
}
}

128
apigen/CHANGELOG.md Normal file
View File

@ -0,0 +1,128 @@
## ApiGen 2.8.0 (2012-09-08) ##
* Added support for @property and @method annotations
* Added support for variable length parameters
* Enabled selection of more rows in source code
* Templates can specify minimum and maximum required ApiGen version
* Added template for 404 page
* Improved support for malformed @param annotations
* Fixed excluding files and directories and detecting non accessible files and directories
* Fixed internal error when no timezone is specified in php.ini
* Fixed autocomplate in Opera browser
* Nette framework updated to version 2.0.5
* TokenReflection library updated to version 1.3.1
* FSHL library updated to version 2.1.0
## ApiGen 2.7.0 (2012-07-15) ##
* Support of custom template macros and helpers
* Information about overridden methods in class method list
* Template UX fixes
* Fixed bugs causing ApiGen to crash
* TokenReflection library updated to version 1.3.0
* Bootstrap2 based template
* Removed template with frames
## ApiGen 2.6.1 (2012-03-27) ##
* Fixed resolving element names in annotations
* Nette framework updated to version 2.0.1
* TokenReflection library updated to version 1.2.2
## ApiGen 2.6.0 (2012-03-11) ##
* Better error reporting, especially about duplicate classes, functions and constants
* Character set autodetection is on by default
* Changed visualization of deprecated elements
* Improved packages parsing and visualization
* Improved @license and @link visualization
* Improved ```<code>``` parsing
* Added option ```--extensions``` to specify file extensions of parsed files
* Minor visualization improvements
* Fixed autocomplete for classes in namespaces
* TokenReflection library updated to version 1.2.0
## ApiGen 2.5.0 (2012-02-12) ##
* Added option ```--groups``` for grouping classes, interfaces, traits and exceptions in the menu
* Added option ```--autocomplete``` for choosing elements in the search autocomplete
* Inheriting some annotations from the file-level docblock
* @uses annotations create a @usedby annotation in the target documentation
* Added warning for unknown options
* Added support of comma-separated values for @see
* Changed all path options to be relative to the configuration file
* Fixed dependencies check
* Nette framework updated to 2.0.0 stable version
* TokenReflection library updated to version 1.1.0
## ApiGen 2.4.1 (2012-01-25) ##
* TokenReflection library updated to version 1.0.2
* Nette framework updated to version 2.0.0RC1
## ApiGen 2.4.0 (2011-12-24) ##
* TokenReflection library updated to version 1.0.0
* Fixed support for older PHP versions of the 5.3 branch
* Option ```templateConfig``` is relative to the config file (was relative to cwd)
## ApiGen 2.3.0 (2011-11-13) ##
* Added support for default configuration file
* Added link to download documentation as ZIP archive
* Added option ```--charset``` and autodetection of charsets
* Added support for @ignore annotation
* Added PHAR support
* Added support for ClassName[]
* Added memory usage reporting in progressbar
* Improved templates for small screens
* Changed option name ```--undocumented``` to ```--report```
* FSHL library updated to version 2.0.1
## ApiGen 2.2.1 (2011-10-26) ##
* Fixed processing of magic constants
* Fixed resize.png
* TokenReflection library updated to version 1.0.0RC2
## ApiGen 2.2.0 (2011-10-16) ##
* Added an option to check for updates
* Added an option to initially display elements in alphabetical order
* Added an option to generate the robots.txt file
* Added required extensions check
* Changed reporting of undocumented elements to the checkstyle format
* Improved deprecated elements highlighting
* Highlighting the linked source code line
* Unknown annotations are sorted alphabetically
* Fixed class parameter description parsing
* Fixed command line options parsing
* Fixed include path setting of the GitHub version
* Fixed frames template
## ApiGen 2.1.0 (2011-09-04) ##
* Experimental support of PHP 5.4 traits
* Added option ```--colors```
* Added template with frames
* Added templates option to make element details expanded by default
## ApiGen 2.0.3 (2011-08-22) ##
* @param, @return and @throw annotations are inherited
## ApiGen 2.0.2 (2011-07-21) ##
* Fixed inherited methods listing
* Interfaces are not labeled "Abstract interface"
* Fixed Google CSE ID validation
* Fixed filtering by ```--exclude``` and ```--skip-doc-path```
* Fixed exception output when using ```--debug```
## ApiGen 2.0.1 (2011-07-17) ##
* Updated TokenReflection library to 1.0.0beta5
* Requires FSHL 2.0.0RC
* Fixed url in footer
## ApiGen 2.0.0 (2011-06-28) ##

32
apigen/LICENSE.md Normal file
View File

@ -0,0 +1,32 @@
# Licenses #
You may use ApiGen under the terms of either the New BSD License or the GNU General Public License (GPL) version 2 or 3.
The BSD License is recommended for most projects. It is easy to understand and it places almost no restrictions on what you can do with the framework. If the GPL fits better to your project, you can use the framework under this license.
You don't have to notify anyone which license you are using. You can freely use ApiGen in commercial projects as long as the copyright header remains intact.
## New BSD License ##
Copyright (c) 2010 [David Grudl](http://davidgrudl.com)
Copyright (c) 2011-2012 [Jaroslav Hanslík](https://github.com/kukulich)
Copyright (c) 2011-2012 [Ondřej Nešpor](https://github.com/Andrewsville)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of "ApiGen" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## GNU General Public License ##
GPL licenses are very very long, so instead of including them here we offer you URLs with full text:
* [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html)
* [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html)

285
apigen/README.md Normal file
View File

@ -0,0 +1,285 @@
# Welcome to ApiGen #
ApiGen is the tool for creating professional API documentation from PHP source code, similar to discontinued phpDocumentor/phpDoc.
ApiGen has support for PHP 5.3 namespaces, packages, linking between documentation, cross referencing to PHP standard classes and general documentation, creation of highlighted source code and experimental support for PHP 5.4 **traits**.
## Support & Bug Reports ##
For all support questions please use our [mailing list](https://groups.google.com/group/apigen). For bug reports and issues the [issue tracker](https://github.com/apigen/apigen/issues) is available. Changes between versions are described in the [change log](https://github.com/apigen/apigen/blob/master/CHANGELOG.md).
## Features ##
* Our own [TokenReflection library](https://github.com/Andrewsville/PHP-Token-Reflection) is used to describe the source code. It is **safe** (documented source code does not get included and thus parsed) and **simple** (you do not need to include or autoload all libraries you use in your source code).
* Detailed documentation of classes, functions and constants.
* Highlighted source code.
* Support of namespaces and packages with subpackages.
* Experimental support of traits.
* A page with trees of classes, interfaces, traits and exceptions.
* A page with a list of deprecated elements.
* A page with Todo tasks.
* Link to download documentation as ZIP archive.
* Checkstyle report of poorly documented elements.
* Support for docblock templates.
* Support for @inheritdoc.
* Support for {@link}.
* Active links in @see and @uses tags.
* Documentation of used internal PHP classes.
* Links to the start line in the highlighted source code for every described element.
* List of direct and indirect known subclasses, implementers and users for every class/interface/trait/exception.
* Check for a new version.
* Google CSE support with suggest.
* Google Analytics support.
* Support for multiple/custom templates.
* Sitemap and opensearch support.
* Support for different charsets and line endings.
* Lots of configuration options (see below).
## Installation ##
The preferred installation way is using the PEAR package but there are three more ways how to install ApiGen.
### PEAR ###
PEAR is a distribution system for PHP packages. It is bundled with PHP since the 4.3 version and it is easy to use.
The PEAR package contains only ApiGen itself. Its dependencies (Nette, Texy, FSHL and TokenReflection) have to be installed separately. But do not panic, the PEAR installer can take care of it.
The easiest way is to use the PEAR auto discovery feature. In that case all you have to do is to type two commands.
```
pear config-set auto_discover 1
pear install pear.apigen.org/apigen
```
If you don't want to use the auto discovery, you have to add PEAR channels of all ApiGen libraries manually. In this case you can install ApiGen by typing these commands.
```
pear channel-discover pear.apigen.org
pear channel-discover pear.nette.org
pear channel-discover pear.texy.info
pear channel-discover pear.kukulich.cz
pear channel-discover pear.andrewsville.cz
pear install apigen/ApiGen
```
If you encounter a message like `WARNING: channel "pear.apigen.org" has updated its protocols, use "pear channel-update pear.apigen.org" to update`, you need to tell PEAR to update its information about the ApiGen channel using the suggested command.
```
pear channel-update pear.apigen.org
```
### Standalone package ###
Using the standalone package is even easier than using the PEAR installer but it does not handle updates automatically.
To download the actual release visit the [Downloads section](https://github.com/apigen/apigen/downloads). There you find separate packages for each release in two formats - zip and tar.gz. These packages are prepared by the ApiGen team and are truly standalone; they contain all required libraries in appropriate versions. You just need to extract the contents of an archive and you can start using ApiGen.
### GitHub built archive ###
GitHub allows you to download any repository as a zip or tar.gz archive. You can use this feature to download an archive with the current version of ApiGen. However this approach has one disadvantage. Such archive (in contrast to the standalone packages) does not contain required libraries. They are included as git submodules in the repository and GitHub simply ignores them when generating the archive. It means that you will have to obtain required libraries manually.
### Cloning the repository ###
The last way how to install ApiGen is simply to clone our repository. If you do so, remember to fetch and rebase to get new versions and do not forget to update submodules in the libs directory.
## Usage ##
```
apigen --config <path> [options]
apigen --source <path> --destination <path> [options]
```
As you can see, you can use ApiGen either by providing individual parameters via the command line or using a config file. Moreover you can combine the two methods and the command line parameters will have precedence over those in the config file.
Every configuration option has to be followed by its value. And it is exactly the same to write ```--config=file.conf``` and ```--config file.conf```. The only exceptions are boolean options (those with yes|no values). When using these options on the command line you do not have to provide the "yes" value explicitly. If ommited, it is assumed that you wanted to turn the option on. So using ```--debug=yes``` and ```--debug``` does exactly the same (and the opposite is ```--debug=no```).
Some options can have multiple values. To do so, you can either use them multiple times or separate their values by a comma. It means that ```--source=file1.php --source=file2.php``` and ```--source=file1.php,file2.php``` is exactly the same.
### Options ###
```--config|-c <file>```
Path to the config file.
```--source|-s <directory|file>``` **required**
Path to the directory or file to be processed. You can use the parameter multiple times to provide a list of directories or files. All types of PHAR archives are supported (requires the PHAR extension). To process gz/bz2 compressed archives you need the appropriate extension (see requirements).
```--destination|-d <directory>``` **required**
Documentation will be generated into this directory.
```--extensions <list>```
List of allowed file extensions, default is "php".
```--exclude <mask>```
Directories and files matching this file mask will not be parsed. You can exclude for example tests from processing this way. This parameter is case sensitive and can be used multiple times.
```--skip-doc-path <mask>```
```--skip-doc-prefix <value>```
Using this parameters you can tell ApiGen not to generate documentation for elements from certain files or with certain name prefix. Such classes will appear in class trees, but will not create a link to their documentation. These parameters are case sensitive and can be used multiple times.
```--charset <list>```
Character set of source files, default is "auto" that lets ApiGen choose from all supported character sets. However if you use only one characters set across your source files you should set it explicitly to avoid autodetection because it can be tricky (and is not completely realiable). Moreover autodetection slows down the process of generating documentation. You can also use the parameter multiple times to provide a list of all used character sets in your documentation. In that case ApiGen will choose one of provided character sets for each file.
```--main <value>```
Elements with this name prefix will be considered as the "main project" (the rest will be considered as libraries).
```--title <value>```
Title of the generated documentation.
```--base-url <value>```
Documentation base URL used in the sitemap. Only needed if you plan to make your documentation public.
```--google-cse-id <value>```
If you have a Google CSE ID, the search box will use it when you do not enter an exact class, constant or function name.
```--google-cse-label <value>```
This will be the default label when using Google CSE.
```--google-analytics <value>```
A Google Analytics tracking code. If provided, an ansynchronous tracking code will be placed into every generated page.
```--template-config <file>```
Template config file, default is the config file of ApiGen default template.
```--allowed-html <list>```
List of allowed HTML tags in documentation separated by comma. Default value is "b,i,a,ul,ol,li,p,br,var,samp,kbd,tt".
```--groups <value>```
How should elements be grouped in the menu. Possible options are "auto", "namespaces", "packages" and "none". Default value is "auto" (namespaces are used if the source code uses them, packages otherwise).
```--autocomplete <list>```
List of element types that will appear in the search input autocomplete. Possible values are "classes", "constants", "functions", "methods", "properties" and "classconstants". Default value is "classes,constants,functions".
```--access-levels <list>```
Access levels of methods and properties that should get their documentation parsed. Default value is "public,protected" (don't generate private class members).
```--internal <yes|no>```
Generate documentation for elements marked as internal (```@internal``` without description) and display parts of the documentation that are marked as internal (```@internal with description ...``` or inline ```{@internal ...}```), default is "No".
```--php <yes|no>```
Generate documentation for PHP internal classes, default is "Yes".
```--tree <yes|no>```
Generate tree view of classes, interfaces, traits and exceptions, default is "Yes".
```--deprecated <yes|no>```
Generate documentation for deprecated elements, default is "No".
```--todo <yes|no>```
Generate a list of tasks, default is "No".
```--source-code <yes|no>```
Generate highlighted source code for user defined elements, default is "Yes".
```--download <yes|no>```
Add a link to download documentation as a ZIP archive, default is "No".
```--report <file>```
Save a checkstyle report of poorly documented elements into a file.
```--wipeout <yes|no>```
Delete files generated in the previous run, default is "Yes".
```--quiet <yes|no>```
Do not print any messages to the console, default is "No".
```--progressbar <yes|no>```
Display progressbars, default is "Yes".
```--colors <yes|no>```
Use colors, default "No" on Windows, "Yes" on other systems. Windows doesn't support colors in console however you can enable it with [Ansicon](http://adoxa.110mb.com/ansicon/).
```--update-check <yes|no>```
Check for a new version of ApiGen, default is "Yes".
```--debug <yes|no>```
Display additional information (exception trace) in case of an error, default is "No".
```--help|-h ```
Display the list of possible options.
Only ```--source``` and ```--destination``` parameters are required. You can provide them via command line or a configuration file.
### Config files ###
Instead of providing individual parameters via the command line, you can prepare a config file for later use. You can use all the above listed parameters (with one exception: the ```--config``` option) only without dashes and with an uppercase letter after each dash (so ```--access-level``` becomes ```accessLevel```).
ApiGen uses the [NEON file format](http://ne-on.org) for all its config files. You can try the [online parser](http://ne-on.org) to debug your config files and see how they get parsed.
Then you can call ApiGen with a single parameter ```--config``` specifying the config file to load.
```
apigen --config <path> [options]
```
Even when using a config file, you can still provide additional parameters via the command line. Such parameters will have precedence over parameters from the config file.
Keep in mind, that any values in the config file will be **overwritten** by values from the command line. That means that providing the ```--source``` parameter values both in the config file and via the command line will not result in using all the provided values but only those from the command line.
If you provide no command line parameters at all, ApiGen will try to load a default config file called ```apigen.neon``` in the current working directory. If found it will work as if you used the ```--config``` option. Note that when using any command line option, you have to specify the config file if you have one. ApiGen will try to load one automatically only when no command line parameters are used. Option names have to be in camelCase in config files (```--template-config``` on the command line becomes ```templateConfig``` in a config file). You can see a full list of configuration options with short descriptions in the example config file [apigen.neon.example](https://github.com/apigen/apigen/blob/master/apigen.neon.example).
### Example ###
We are generating documentation for the Nella Framework. We want Nette and Doctrine to be parsed as well because we want their classes to appear in class trees, lists of parent classes and their members in lists of inherited properties, methods and constants. However we do not want to generate their full documentation along with highlighted source codes. And we do not want to process any "test" directories, because there might be classes that do not belong to the project actually.
```
apigen --source ~/nella/Nella --source ~/doctrine2/lib/Doctrine --source ~/doctrine2/lib/vendor --source ~/nette/Nette --skip-doc-path "~/doctrine2/*" --skip-doc-prefix Nette --exclude "*/tests/*" --destination ~/docs/ --title "Nella Framework"
```
## Requirements ##
ApiGen requires PHP 5.3 or later. Four libraries it uses ([Nette](https://github.com/nette/nette), [Texy](https://github.com/dg/texy), [TokenReflection](https://github.com/Andrewsville/PHP-Token-Reflection) and [FSHL](https://github.com/kukulich/fshl)) require four additional PHP extensions: [tokenizer](http://php.net/manual/book.tokenizer.php), [mbstring](http://php.net/manual/book.mbstring.php), [iconv](http://php.net/manual/book.iconv.php) and [json](http://php.net/manual/book.json.php). For documenting PHAR archives you need the [phar extension](http://php.net/manual/book.phar.php) and for documenting gz or bz2 compressed PHARs, you need the [zlib](http://php.net/manual/book.zlib.php) or [bz2](http://php.net/manual/book.bzip2.php) extension respectively. To generate the ZIP file with documentation you need the [zip extension](http://php.net/manual/book.zip.php).
When generating documentation of large libraries (Zend Framework for example) we recommend not to have the Xdebug PHP extension loaded (it does not need to be used, it significantly slows down the generating process even when only loaded).
## Authors ##
* [Jaroslav Hanslík](https://github.com/kukulich)
* [Ondřej Nešpor](https://github.com/Andrewsville)
* [David Grudl](https://github.com/dg)
## Usage examples ##
* [Doctrine](http://www.doctrine-project.org/api/orm/2.2/index.html)
* [Nette Framework](http://api.nette.org/2.0/)
* [TokenReflection library](http://andrewsville.github.com/PHP-Token-Reflection/)
* [FSHL library](http://fshl.kukulich.cz/api/)
* [Nella Framework](http://api.nellafw.org/)
* Jyxo PHP Libraries, both [namespaced](http://jyxo.github.com/php/) and [non-namespaced](http://jyxo.github.com/php-no-namespace/)
Besides from these publicly visible examples there are companies that use ApiGen to generate their inhouse documentation: [Medio Interactive](http://www.medio.cz/), [Wikidi](http://wikidi.com/).

16
apigen/apigen.bat Executable file
View File

@ -0,0 +1,16 @@
@echo off
REM ApiGen 2.8.0 - API documentation generator for PHP 5.3+
REM
REM Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
REM Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
REM Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
REM
REM For the full copyright and license information, please view
REM the file LICENCE.md that was distributed with this source code.
REM
IF EXIST "@php_bin@" (
"@php_bin@" "@bin_dir@\apigen" %*
) ELSE (
"php.exe" "%~dp0apigen.php" %*
)

View File

@ -0,0 +1,67 @@
# Source file or directory to parse
source:
# Directory where to save the generated documentation
destination:
# List of allowed file extensions
extensions: [php]
# Mask to exclude file or directory from processing
exclude:
# Don't generate documentation for classes from file or directory with this mask
skipDocPath:
# Don't generate documentation for classes with this name prefix
skipDocPrefix:
# Character set of source files
charset: auto
# Main project name prefix
main:
# Title of generated documentation
title:
# Documentation base URL
baseUrl:
# Google Custom Search ID
googleCseId:
# Google Custom Search label
googleCseLabel:
# Google Analytics tracking code
googleAnalytics:
# Template config file
templateConfig: './templates/default/config.neon'
# Grouping of classes
groups: auto
# List of allowed HTML tags in documentation
allowedHtml: [b, i, a, ul, ol, li, p, br, var, samp, kbd, tt]
# Element types for search input autocomplete
autocomplete: [classes, constants, functions]
# Generate documentation for methods and properties with given access level
accessLevels: [public, protected]
# Generate documentation for elements marked as internal and display internal documentation parts
internal: No
# Generate documentation for PHP internal classes
php: Yes
# Generate tree view of classes, interfaces and exceptions
tree: Yes
# Generate documentation for deprecated classes, methods, properties and constants
deprecated: No
# Generate documentation of tasks
todo: No
# Generate highlighted source code files
sourceCode: Yes
# Add a link to download documentation as a ZIP archive
download: No
# Save a checkstyle report of poorly documented elements into a file
report:
# Wipe out the destination directory first
wipeout: Yes
# Don't display scanning and generating messages
quiet: No
# Display progressbars
progressbar: Yes
# Use colors
colors: No
# Check for update
updateCheck: Yes
# Display additional information in case of an error
debug: No

254
apigen/apigen.php Normal file
View File

@ -0,0 +1,254 @@
#!/usr/bin/env php
<?php
/**
* ApiGen 2.8.0 - API documentation generator for PHP 5.3+
*
* Copyright (c) 2010-2011 David Grudl (http://davidgrudl.com)
* Copyright (c) 2011-2012 Jaroslav Hanslík (https://github.com/kukulich)
* Copyright (c) 2011-2012 Ondřej Nešpor (https://github.com/Andrewsville)
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*/
namespace ApiGen;
use Nette\Diagnostics\Debugger;
use TokenReflection;
// Safe locale and timezone
setlocale(LC_ALL, 'C');
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
if (false === strpos('@php_dir@', '@php_dir')) {
// PEAR package
@include '@php_dir@/Nette/loader.php';
@include '@php_dir@/Texy/texy.php';
} else {
// Downloaded package
set_include_path(
__DIR__ . PATH_SEPARATOR .
__DIR__ . '/libs/FSHL' . PATH_SEPARATOR .
__DIR__ . '/libs/TokenReflection' . PATH_SEPARATOR .
get_include_path()
);
@include __DIR__ . '/libs/Nette/Nette/loader.php';
@include __DIR__ . '/libs/Texy/texy/texy.php';
}
// Autoload
spl_autoload_register(function($class) {
$class = trim($class, '\\');
require sprintf('%s.php', str_replace('\\', DIRECTORY_SEPARATOR, $class));
});
try {
// Check dependencies
foreach (array('json', 'iconv', 'mbstring', 'tokenizer') as $extension) {
if (!extension_loaded($extension)) {
printf("Required extension missing: %s\n", $extension);
die(1);
}
}
if (!class_exists('Nette\\Diagnostics\\Debugger')) {
echo "Required dependency missing: Nette Framework\n";
die(1);
}
if (!class_exists('Texy')) {
echo "Required dependency missing: Texy library\n";
die(1);
}
if (!class_exists('FSHL\\Highlighter')) {
echo "Required dependency missing: FSHL library\n";
die(1);
}
if (!class_exists('TokenReflection\\Broker')) {
echo "Required dependency missing: TokenReflection library\n";
die(1);
}
Debugger::$strictMode = true;
Debugger::$onFatalError[] = function() {
echo "\nFor more information turn on the debug mode using the --debug option.\n";
};
Debugger::enable(Debugger::PRODUCTION, false);
$start = new \DateTime();
$options = $_SERVER['argv'];
array_shift($options);
$config = new Config();
$config->processCliOptions($options);
$generator = new Generator($config);
// Help
if ($config->isHelpRequested()) {
echo $generator->colorize($generator->getHeader());
echo $generator->colorize($config->getHelp());
die();
}
// Prepare configuration
$config->prepare();
if ($config->debug) {
Debugger::$onFatalError = array();
Debugger::enable(Debugger::DEVELOPMENT, false);
}
$generator->output($generator->getHeader());
// Check for update (only in production mode)
if ($config->updateCheck && !$config->debug) {
ini_set('default_socket_timeout', 5);
$latestVersion = @file_get_contents('http://pear.apigen.org/rest/r/apigen/latest.txt');
if (false !== $latestVersion && version_compare(trim($latestVersion), Generator::VERSION, '>')) {
$generator->output(sprintf("New version @header@%s@c available\n\n", $latestVersion));
}
}
// Scan
if (count($config->source) > 1) {
$generator->output(sprintf("Scanning\n @value@%s@c\n", implode("\n ", $config->source)));
} else {
$generator->output(sprintf("Scanning @value@%s@c\n", $config->source[0]));
}
if (count($config->exclude) > 1) {
$generator->output(sprintf("Excluding\n @value@%s@c\n", implode("\n ", $config->exclude)));
} elseif (!empty($config->exclude)) {
$generator->output(sprintf("Excluding @value@%s@c\n", $config->exclude[0]));
}
$parsed = $generator->parse();
if (count($parsed->errors) > 1) {
$generator->output(sprintf("@error@Found %d errors@c\n\n", count($parsed->errors)));
$no = 1;
foreach ($parsed->errors as $e) {
if ($e instanceof TokenReflection\Exception\ParseException) {
$generator->output(sprintf("@error@%d.@c The TokenReflection library threw an exception while parsing the file @value@%s@c.\n", $no, $e->getFileName()));
if ($config->debug) {
$generator->output("\nThis can have two reasons: a) the source code in the file is not valid or b) you have just found a bug in the TokenReflection library.\n\n");
$generator->output("If the license allows it please send the whole file or at least the following fragment describing where exacly is the problem along with the backtrace to apigen@apigen.org. Thank you!\n\n");
$token = $e->getToken();
$sender = $e->getSender();
if (!empty($token)) {
$generator->output(
sprintf(
"The cause of the exception \"%s\" was the @value@%s@c token (line @count@%d@c) in following part of %s source code:\n\n",
$e->getMessage(),
$e->getTokenName(),
$e->getExceptionLine(),
$sender && $sender->getName() ? '@value@' . $sender->getPrettyName() . '@c' : 'the'
)
);
} else {
$generator->output(
sprintf(
"The exception \"%s\" was thrown when processing %s source code:\n\n",
$e->getMessage(),
$sender && $sender->getName() ? '@value@' . $sender->getPrettyName() . '@c' : 'the'
)
);
}
$generator->output($e->getSourcePart(true) . "\n\nThe exception backtrace is following:\n\n" . $e->getTraceAsString() . "\n\n");
}
} elseif ($e instanceof TokenReflection\Exception\FileProcessingException) {
$generator->output(sprintf("@error@%d.@c %s\n", $no, $e->getMessage()));
if ($config->debug) {
$generator->output("\n" . $e->getDetail() . "\n\n");
}
} else {
$generator->output(sprintf("@error@%d.@c %s\n", $no, $e->getMessage()));
if ($config->debug) {
$trace = $e->getTraceAsString();
while ($e = $e->getPrevious()) {
$generator->output(sprintf("\n%s", $e->getMessage()));
$trace = $e->getTraceAsString();
}
$generator->output(sprintf("\n%s\n\n", $trace));
}
}
$no++;
}
if (!$config->debug) {
$generator->output("\nEnable the debug mode (@option@--debug@c) to see more details.\n\n");
}
}
$generator->output(sprintf("Found @count@%d@c classes, @count@%d@c constants, @count@%d@c functions and other @count@%d@c used PHP internal classes\n", $parsed->classes, $parsed->constants, $parsed->functions, $parsed->internalClasses));
$generator->output(sprintf("Documentation for @count@%d@c classes, @count@%d@c constants, @count@%d@c functions and other @count@%d@c used PHP internal classes will be generated\n", $parsed->documentedClasses, $parsed->documentedConstants, $parsed->documentedFunctions, $parsed->documentedInternalClasses));
// Generating
$generator->output(sprintf("Using template config file @value@%s@c\n", $config->templateConfig));
if ($config->wipeout && is_dir($config->destination)) {
$generator->output("Wiping out destination directory\n");
if (!$generator->wipeOutDestination()) {
throw new \RuntimeException('Cannot wipe out destination directory');
}
}
$generator->output(sprintf("Generating to directory @value@%s@c\n", $config->destination));
$skipping = array_merge($config->skipDocPath, $config->skipDocPrefix);
if (count($skipping) > 1) {
$generator->output(sprintf("Will not generate documentation for\n @value@%s@c\n", implode("\n ", $skipping)));
} elseif (!empty($skipping)) {
$generator->output(sprintf("Will not generate documentation for @value@%s@c\n", $skipping[0]));
}
$generator->generate();
// End
$end = new \DateTime();
$interval = $end->diff($start);
$parts = array();
if ($interval->h > 0) {
$parts[] = sprintf('@count@%d@c hours', $interval->h);
}
if ($interval->i > 0) {
$parts[] = sprintf('@count@%d@c min', $interval->i);
}
if ($interval->s > 0) {
$parts[] = sprintf('@count@%d@c sec', $interval->s);
}
if (empty($parts)) {
$parts[] = sprintf('@count@%d@c sec', 1);
}
$duration = implode(' ', $parts);
$generator->output(sprintf("Done. Total time: %s, used: @count@%d@c MB RAM\n", $duration, round(memory_get_peak_usage(true) / 1024 / 1024)));
} catch (ConfigException $e) {
// Configuration error
echo $generator->colorize($generator->getHeader() . sprintf("\n@error@%s@c\n\n", $e->getMessage()) . $config->getHelp());
die(2);
} catch (\Exception $e) {
// Everything else
if ($config->debug) {
do {
echo $generator->colorize(sprintf("\n%s(%d): @error@%s@c", $e->getFile(), $e->getLine(), $e->getMessage()));
$trace = $e->getTraceAsString();
} while ($e = $e->getPrevious());
printf("\n\n%s\n", $trace);
} else {
echo $generator->colorize(sprintf("\n@error@%s@c\n", $e->getMessage()));
}
die(1);
}

View File

@ -0,0 +1,624 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL;
/**
* Generator of lexer cache files.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Generator
{
/**
* Delimiter will be returned to the stream (back to the previous position).
*
* @var integer
*/
const BACK = -1;
/**
* Style from current state will be applied on the received delimiter.
*
* @var integer
*/
const CURRENT = 0;
/**
* Style from the new state will be applied on the received delimiter.
*
* @var integer
*/
const NEXT = 1;
/**
* State leading to the current state.
*
* @var string
*/
const STATE_SELF = '_SELF';
/**
* State to return to previous state.
*
* @var string
*/
const STATE_RETURN = '_RETURN';
/**
* State to quit the current state.
*
* @var string
*/
const STATE_QUIT = '_QUIT';
/**
* Default state flag.
*
* @var integer
*/
const STATE_FLAG_NONE = 0;
/**
* State flag for keyword.
*
* @var integer
*/
const STATE_FLAG_KEYWORD = 0x0001;
/**
* State flag for recursion.
*
* @var integer
*/
const STATE_FLAG_RECURSION = 0x0004;
/**
* State flag for new language.
*
* @var integer
*/
const STATE_FLAG_NEWLEXER = 0x0008;
/**
* Array index for state diagram.
*
* @var integer
*/
const STATE_INDEX_DIAGRAM = 0;
/**
* Array index for state flags.
*
* @var integer
*/
const STATE_INDEX_FLAGS = 1;
/**
* Array index for state class.
*
* @var integer
*/
const STATE_INDEX_CLASS = 2;
/**
* Array index for state data.
*
* @var integer
*/
const STATE_INDEX_DATA = 3;
/**
* Array index for new state in state diagram.
*
* @var integer
*/
const STATE_DIAGRAM_INDEX_STATE = 0;
/**
* Array index for mode in state diagram.
*
* @var integer
*/
const STATE_DIAGRAM_INDEX_MODE = 1;
/**
* Array index for keyword class.
*
* @var interger
*/
const KEYWORD_INDEX_CLASS = 0;
/**
* Array index for list of keywords.
*
* @var interger
*/
const KEYWORD_INDEX_LIST = 1;
/**
* Array index for information if keywords are case-sensitive.
*
* @var interger
*/
const KEYWORD_INDEX_CASE_SENSITIVE = 2;
/**
* Flag case-sensitive.
*
* @var boolean
*/
const CASE_SENSITIVE = true;
/**
* Flag case-insensitive.
*
* @var boolean
*/
const CASE_INSENSITIVE = false;
/**
* Current lexer.
*
* @var \FSHL\Lexer
*/
private $lexer = null;
/**
* Current lexer name.
*
* @var string
*/
private $lexerName;
/**
* Generated source for given lexer.
*
* @var string
*/
private $source;
/**
* List of CSS classes of current lexer.
*
* @var array
*/
private $classes = array();
/**
* List of states.
*
* @var array
*/
private $states = array();
/**
* List of flags for all states.
*
* @var array
*/
private $flags = array();
/**
* Data for all states.
*
* @var array
*/
private $data = array();
/**
* List of delimiters.
*
* @var array
*/
private $delimiters = array();
/**
* Transitions table.
*
* @var array
*/
private $trans = array();
/**
* Initializes the generator for a given lexer.
*
* @param \FSHL\Lexer $lexer
*/
public function __construct(Lexer $lexer)
{
$this->lexer = $lexer;
$this->lexerName = $lexer->getLanguage();
$this->source = $this->generate();
}
/**
* Returns the generated source.
*
* @return string
*/
public function getSource()
{
return $this->source;
}
/**
* Saves the generated source to a lexer cache file.
*
* @return \FSHL\Generator
* @throws \RuntimeException If the file could not be saved.
*/
public function saveToCache()
{
$file = __DIR__ . '/Lexer/Cache/' . $this->lexerName . '.php';
if (false === @file_put_contents($file, $this->getSource())) {
throw new \RuntimeException(sprintf('Cannot save source to "%s"', $file));
}
require_once $file;
return $this;
}
/**
* Generates the source.
*
* @return string
*/
private function generate()
{
$this->optimize();
$constructor = '';
$constructor .= $this->getVarSource('$this->language', $this->lexer->getLanguage());
$constructor .= $this->getVarSource('$this->trans', $this->trans);
$constructor .= $this->getVarSource('$this->initialState', $this->states[$this->lexer->getInitialState()]);
$constructor .= $this->getVarSource('$this->returnState', $this->states[self::STATE_RETURN]);
$constructor .= $this->getVarSource('$this->quitState', $this->states[self::STATE_QUIT]);
$constructor .= $this->getVarSource('$this->flags', $this->flags);
$constructor .= $this->getVarSource('$this->data', $this->data);
$constructor .= $this->getVarSource('$this->classes', $this->classes);
$constructor .= $this->getVarSource('$this->keywords', $this->lexer->getKeywords());
$functions = '';
foreach ($this->delimiters as $state => $delimiter) {
if (null !== $delimiter) {
$functions .= $this->generateState($state);
}
}
return <<<SOURCE
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\\Lexer\\Cache;
/**
* Optimized and cached {$this->lexerName} lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \\FSHL\\Generator
* @see \\FSHL\\Lexer\\{$this->lexerName}
*/
class {$this->lexerName}
{
/**
* Language name.
*
* @var array
*/
public \$language;
/**
* Transitions table.
*
* @var array
*/
public \$trans;
/**
* Id of the initial state.
*
* @var integer
*/
public \$initialState;
/**
* Id of the return state.
*
* @var integer
*/
public \$returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public \$quitState;
/**
* List of flags for all states.
*
* @var array
*/
public \$flags;
/**
* Data for all states.
*
* @var array
*/
public \$data;
/**
* List of CSS classes.
*
* @var array
*/
public \$classes;
/**
* List of keywords.
*
* @var array
*/
public \$keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$constructor
}
$functions
}
SOURCE;
}
/**
* Generates a state code.
*
* @param integer $state
* @return string
*/
private function generateState($state)
{
// Delimiter => Condition
static $commonDelimiters = array(
'ALL' => true,
'LINE' => "\n",
'TAB' => "\t",
'SPACE' => 'preg_match(\'~^\\s+~\', $part, $matches)',
'!SPACE' => 'preg_match(\'~^\\\\S+~\', $part, $matches)',
'ALPHA' => 'preg_match(\'~^[a-z]+~i\', $part, $matches)',
'!ALPHA' => 'preg_match(\'~^[^a-z]+~i\', $part, $matches)',
'ALNUM' => 'preg_match(\'~^[a-z\\\\d]+~i\', $part, $matches)',
'!ALNUM' => 'preg_match(\'~^[^a-z\\\\d]+~i\', $part, $matches)',
'ALNUM_' => 'preg_match(\'~^\\\\w+~\', $part, $matches)',
'!ALNUM_' => 'preg_match(\'~^\\\\W+~\', $part, $matches)',
'NUM' => 'preg_match(\'~^\\\\d+~\', $part, $matches)',
'!NUM' => 'preg_match(\'~^\\\\D+~\', $part, $matches)',
'HEXNUM' => 'preg_match(\'~^[a-f\\\\d]+~i\', $part, $matches)',
'!HEXNUM' => 'preg_match(\'~^[^a-f\\\\d]+~i\', $part, $matches)',
'DOTNUM' => 'preg_match(\'~^\\.\\\\d+~\', $part, $matches)',
'!DOTNUM' => 'preg_match(\'~^(?:[^\\.]|\\.\\\\D)~\', $part, $matches)'
);
$allDelimiters = array_merge($commonDelimiters, $this->lexer->getDelimiters());
$conditionsSource = '';
$delimiters = array();
foreach ($this->delimiters[$state] as $no => $delimiter) {
if ('ALL' === $delimiter) {
$conditionSource = <<<CONDITION
return array($no, \$letter, \$buffer);
CONDITION;
} else {
if (isset($allDelimiters[$delimiter]) && 0 === strpos($allDelimiters[$delimiter], 'preg_match')) {
$delimiterSource = '$matches[0]';
$condition = $allDelimiters[$delimiter];
} else {
if (isset($allDelimiters[$delimiter])) {
$delimiter = $allDelimiters[$delimiter];
}
$delimiters[$no] = $delimiter;
$delimiterSource = sprintf('$delimiters[%d]', $no);
if (1 === strlen($delimiter)) {
$condition = sprintf('$delimiters[%d] === $letter', $no);
} else {
$condition = sprintf('0 === strpos($part, $delimiters[%d])', $no);
}
}
$conditionSource = <<<CONDITION
if ($condition) {
return array($no, $delimiterSource, \$buffer);
}
CONDITION;
}
$conditionsSource .= $conditionSource;
}
$partSource = preg_match('~\\$part~', $conditionsSource) ? 'substr($text, $textPos, 10)' : '';
if (preg_match('~\\$letter~', $conditionsSource)) {
$letterSource = '$text[$textPos]';
$bufferSource = '$letter';
} else {
$letterSource = '';
$bufferSource = '$text[$textPos]';
}
$source = '
/**
* Finds a delimiter for state ' . array_search($state, $this->states) . '.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter' . $state . '($text, $textLength, $textPos)
{
' . (!empty($delimiters) ? sprintf('static $delimiters = %s;', $this->getVarValueSource($delimiters)) : '') . '
$buffer = false;
while ($textPos < $textLength) {
' . (!empty($partSource) ? sprintf('$part = %s;', $partSource) : '') . '
' . (!empty($letterSource) ? sprintf('$letter = %s;', $letterSource) : '') . '
' . $conditionsSource . '
$buffer .= ' . $bufferSource . ';
$textPos++;
}
return array(-1, -1, $buffer);
}
';
// Removes traling whitespaces and unnecessary empty lines
$source = preg_replace('~\n{3,}~', "\n\n", preg_replace('~\t+\n~', "\n", $source));
return $source;
}
/**
* Optimizes the lexer definition.
*
* @return \FSHL\Generator
* @throws \RuntimeException If the lexer definition is wrong.
*/
private function optimize()
{
$i = 0;
foreach (array_keys($this->lexer->getStates()) as $stateName) {
if (self::STATE_QUIT === $stateName) {
continue;
}
$this->states[$stateName] = $i;
$i++;
}
$this->states[self::STATE_RETURN] = $i++;
$this->states[self::STATE_QUIT] = $i++;
foreach ($this->lexer->getStates() as $stateName => $state) {
$stateId = $this->states[$stateName];
$this->classes[$stateId] = $state[self::STATE_INDEX_CLASS];
$this->flags[$stateId] = $state[self::STATE_INDEX_FLAGS];
$this->data[$stateId] = $state[self::STATE_INDEX_DATA];
if (is_array($state[self::STATE_INDEX_DIAGRAM])) {
$i = 0;
foreach ($state[self::STATE_INDEX_DIAGRAM] as $delimiter => $trans) {
$transName = $trans[self::STATE_DIAGRAM_INDEX_STATE];
if (self::STATE_SELF === $transName) {
$transName = array_search($stateId, $this->states);
}
if (!isset($this->states[$transName])) {
throw new \RuntimeException(sprintf('Unknown state in transition %s [%s] => %s', $stateName, $delimiter, $transName));
}
$this->delimiters[$stateId][$i] = $delimiter;
$trans[self::STATE_DIAGRAM_INDEX_STATE] = $this->states[$transName];
$this->trans[$stateId][$i] = $trans;
$i++;
}
} else {
$this->delimiters[$stateId] = null;
$this->trans[$stateId] = null;
}
}
if (!isset($this->states[$this->lexer->getInitialState()])) {
throw new \RuntimeException(sprintf('Unknown initial state "%s"', $this->lexer->getInitialState()));
}
return $this;
}
/**
* Returns a variable source.
*
* @param string $name
* @param mixed $value
* @return string
*/
private function getVarSource($name, $value)
{
return sprintf("\t\t%s = %s;\n", $name, $this->getVarValueSource($value));
}
/**
* Returns a variable value source.
*
* @param mixed $value
* @param integer $level
* @return string
*/
private function getVarValueSource($value, $level = 0)
{
if (is_array($value)) {
$tmp = '';
$line = 0;
$total = 0;
foreach ($value as $k => $v) {
if ($line > 25) {
$tmp .= ",\n\t\t" . str_repeat("\t", $level);
$line = 0;
} elseif (0 !== $total) {
$tmp .= ', ';
}
$tmp .= $this->getVarValueSource($k, $level + 1) . ' => ' . $this->getVarValueSource($v, $level + 1);
$line++;
$total++;
}
return "array(\n\t\t\t" . str_repeat("\t", $level) . $tmp . "\n" . str_repeat("\t", $level) . "\t\t)";
} elseif (is_string($value) && preg_match('~[\\t\\n\\r]~', $value)) {
$export = var_export($value, true);
$export = str_replace(array("\t", "\n", "\r"), array('\t', '\n', '\r'), $export);
return '"' . substr($export, 1, -1) . '"';
} else {
return var_export($value, true);
}
}
}

View File

@ -0,0 +1,482 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL;
/**
* Highlighter.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Highlighter
{
/**
* No options.
*
* @var integer
*/
const OPTION_DEFAULT = 0x0000;
/**
* Tab indentation option.
*
* @var integer
*/
const OPTION_TAB_INDENT = 0x0010;
/**
* Line counter option.
*
* @var integer
*/
const OPTION_LINE_COUNTER = 0x0020;
/**
* Output mode.
*
* @var \FSHL\Output
*/
private $output = null;
/**
* Options.
*
* @var integer
*/
private $options;
/**
* Tab indent width.
*
* @var integer
*/
private $tabIndentWidth;
/**
* List of already used lexers.
*
* @var array
*/
private $lexers = array();
/**
* Current lexer.
*
* @var \FSHL\Lexer
*/
private $lexer = null;
/**
* Table for tab indentation.
*
* @var array
*/
private $tabs = array();
/**
* States stack.
*
* @var array
*/
private $stack = array();
/**
* Prepares the highlighter.
*
* @param \FSHL\Output $output
* @param integer $options
* @param integer $tabIndentWidth
*/
public function __construct(Output $output, $options = self::OPTION_DEFAULT, $tabIndentWidth = 4)
{
$this->setOutput($output)
->setOptions($options, $tabIndentWidth);
}
/**
* Highlightes a string.
*
* @param string $text
* @param \FSHL\Lexer $lexer
* @return string
* @throws \RuntimeException If no lexer is set.
*/
public function highlight($text, Lexer $lexer = null)
{
// Sets the lexer
$initialLexer = $this->lexer;
if (null !== $lexer) {
$this->setLexer($lexer);
}
// No lexer
if (null === $this->lexer) {
throw new \RuntimeException('No lexer set');
}
// Prepares the text
$text = str_replace(array("\r\n", "\r"), "\n", (string) $text);
$textLength = strlen($text);
$textPos = 0;
// Parses the text
$output = array();
$fragment = '';
$maxLineWidth = 0;
$line = 1;
$char = 0;
if ($this->options & self::OPTION_LINE_COUNTER) {
// Right aligment of line counter
$maxLineWidth = strlen(substr_count($text, "\n") + 1);
$fragment .= $this->line($line, $maxLineWidth);
}
$newLexerName = $lexerName = $this->lexer->language;
$newState = $state = $this->lexer->initialState;
$this->stack = array();
while (true) {
list($transitionId, $delimiter, $buffer) = $this->lexer->{'findDelimiter' . $state}($text, $textLength, $textPos);
// Some data may be collected before getPart reaches the delimiter, we must output this before other processing
if (false !== $buffer) {
$bufferLength = strlen($buffer);
$textPos += $bufferLength;
$char += $bufferLength;
$fragment .= $this->template($buffer, $state);
if (isset($fragment[8192])) {
$output[] = $fragment;
$fragment = '';
}
}
if (-1 === $transitionId) {
// End of stream
break;
}
// Processes received delimiter as string
$prevLine = $line;
$prevChar = $char;
$prevTextPos = $textPos;
$delimiterLength = strlen($delimiter);
$textPos += $delimiterLength;
$char += $delimiterLength;
// Adds line counter and tab indentation
$addLine = false;
if ("\n" === $delimiter[$delimiterLength - 1]) {
// Line counter
$line++;
$char = 0;
if ($this->options & self::OPTION_LINE_COUNTER) {
$addLine = true;
$actualLine = $line;
}
} elseif ("\t" === $delimiter && ($this->options & self::OPTION_TAB_INDENT)) {
// Tab indentation
$i = $char % $this->tabIndentWidth;
$delimiter = $this->tabs[$i][0];
$char += $this->tabs[$i][1];
}
// Gets new state from the transitions table
$newState = $this->lexer->trans[$state][$transitionId][Generator::STATE_DIAGRAM_INDEX_STATE];
if ($newState === $this->lexer->returnState) {
// Chooses mode of delimiter processing
if (Generator::BACK === $this->lexer->trans[$state][$transitionId][Generator::STATE_DIAGRAM_INDEX_MODE]) {
$line = $prevLine;
$char = $prevChar;
$textPos = $prevTextPos;
} else {
$fragment .= $this->template($delimiter, $state);
if ($addLine) {
$fragment .= $this->line($actualLine, $maxLineWidth);
}
if (isset($fragment[8192])) {
$output[] = $fragment;
$fragment = '';
}
}
// Get state from the context stack
if ($item = $this->popState()) {
list($newLexerName, $state) = $item;
// If previous context was in a different lexer, switch the lexer too
if ($newLexerName !== $lexerName) {
$this->setLexerByName($newLexerName);
$lexerName = $newLexerName;
}
} else {
$state = $this->lexer->initialState;
}
continue;
}
// Chooses mode of delimiter processing
$type = $this->lexer->trans[$state][$transitionId][Generator::STATE_DIAGRAM_INDEX_MODE];
if (Generator::BACK === $type) {
$line = $prevLine;
$char = $prevChar;
$textPos = $prevTextPos;
} else {
$fragment .= $this->template($delimiter, Generator::NEXT === $type ? $newState : $state);
if ($addLine) {
$fragment .= $this->line($actualLine, $maxLineWidth);
}
if (isset($fragment[8192])) {
$output[] = $fragment;
$fragment = '';
}
}
// Switches between lexers (transition to embedded language)
if ($this->lexer->flags[$newState] & Generator::STATE_FLAG_NEWLEXER) {
if ($newState === $this->lexer->quitState) {
// Returns to the previous lexer
if ($item = $this->popState()) {
list($newLexerName, $state) = $item;
if ($newLexerName !== $lexerName) {
$this->setLexerByName($newLexerName);
$lexerName = $newLexerName;
}
} else {
$state = $this->lexer->initialState;
}
} else {
// Switches to the embedded language
$newLexerName = $this->lexer->data[$newState];
$this->pushState($lexerName, $this->lexer->trans[$newState] ? $newState : $state);
$this->setLexerByName($newLexerName);
$lexerName = $newLexerName;
$state = $this->lexer->initialState;
}
continue;
}
// If newState is marked with recursion flag (alias call), push current state to the context stack
if (($this->lexer->flags[$newState] & Generator::STATE_FLAG_RECURSION) && $state !== $newState) {
$this->pushState($lexerName, $state);
}
// Change the state
$state = $newState;
}
// Adds template end
$fragment .= $this->output->template('', null);
$output[] = $fragment;
// Restore lexer
$this->lexer = $initialLexer;
return implode('', $output);
}
/**
* Sets the output mode.
*
* @param \FSHL\Output $output
* @return \FSHL\Highlighter
*/
public function setOutput(Output $output)
{
$this->output = $output;
return $this;
}
/**
* Sets options.
*
* @param integer $options
* @param integer $tabIndentWidth
* @return \FSHL\Highlighter
*/
public function setOptions($options = self::OPTION_DEFAULT, $tabIndentWidth = 4)
{
$this->options = $options;
if (($this->options & self::OPTION_TAB_INDENT) && $tabIndentWidth > 0) {
// Precalculate a table for tab indentation
$t = ' ';
$ti = 0;
for ($i = $tabIndentWidth; $i; $i--) {
$this->tabs[$i % $tabIndentWidth] = array($t, $ti++);
$t .= ' ';
}
$this->tabIndentWidth = $tabIndentWidth;
} else {
$this->options &= ~self::OPTION_TAB_INDENT;
}
return $this;
}
/**
* Sets the default lexer.
*
* @param \FSHL\Lexer $lexer
* @return \FSHL\Highlighter
*/
public function setLexer(Lexer $lexer)
{
// Generates the lexer cache on fly, if the lexer cache doesn't exist
if (!$this->findCache($lexer->getLanguage())) {
$this->generateCache($lexer);
}
return $this;
}
/**
* Sets the current lexer by name.
*
* @param string $lexerName
* @return \FSHL\Highlighter
* @throws \InvalidArgumentException If the class for given lexer doesn't exist.
*/
private function setLexerByName($lexerName)
{
// Generates the lexer cache on fly, if the lexer cache doesn't exist
if (!$this->findCache($lexerName)) {
// Finds the lexer
$lexerClass = '\\FSHL\\Lexer\\' . $lexerName;
if (!class_exists($lexerClass)) {
throw new \InvalidArgumentException(sprintf('The class for "%s" lexer doesn\'t exist', $lexerName));
}
$lexer = new $lexerClass();
// Generates the lexer cache on fly
$this->generateCache($lexer);
}
return $this;
}
/**
* Tries to find the lexer cache.
*
* @param string $lexerName
* @return boolean
*/
private function findCache($lexerName)
{
// Lexer has been used before
if (isset($this->lexers[$lexerName])) {
$this->lexer = $this->lexers[$lexerName];
return true;
}
// Loads lexer cache
$lexerCacheClass = '\\FSHL\\Lexer\\Cache\\' . $lexerName;
if (class_exists($lexerCacheClass)) {
$this->lexers[$lexerName] = new $lexerCacheClass();
$this->lexer = $this->lexers[$lexerName];
return true;
}
return false;
}
/**
* Generates the lexer cache on fly.
*
* @param \FSHL\Lexer $lexer
* @return \FSHL\Highlighter
*/
private function generateCache(Lexer $lexer)
{
$generator = new Generator($lexer);
try {
$generator->saveToCache();
} catch (\RuntimeException $e) {
$file = tempnam(sys_get_temp_dir(), 'fshl');
file_put_contents($file, $generator->getSource());
require_once $file;
unlink($file);
}
$lexerName = $lexer->getLanguage();
$lexerCacheClass = '\\FSHL\\Lexer\\Cache\\' . $lexerName;
$this->lexers[$lexerName] = new $lexerCacheClass();
$this->lexer = $this->lexers[$lexerName];
return $this;
}
/**
* Outputs a word.
*
* @param string $part
* @param string $state
* @return string
*/
private function template($part, $state)
{
if ($this->lexer->flags[$state] & Generator::STATE_FLAG_KEYWORD) {
$normalized = Generator::CASE_SENSITIVE === $this->lexer->keywords[Generator::KEYWORD_INDEX_CASE_SENSITIVE] ? $part : strtolower($part);
if (isset($this->lexer->keywords[Generator::KEYWORD_INDEX_LIST][$normalized])) {
return $this->output->keyword($part, $this->lexer->keywords[Generator::KEYWORD_INDEX_CLASS] . $this->lexer->keywords[Generator::KEYWORD_INDEX_LIST][$normalized]);
}
}
return $this->output->template($part, $this->lexer->classes[$state]);
}
/**
* Outputs a line.
*
* @param integer $line
* @param integer $maxLineWidth
* @return string
*/
private function line($line, $maxLineWidth)
{
return $this->output->template(str_pad($line, $maxLineWidth, ' ', STR_PAD_LEFT) . ': ', 'line');
}
/**
* Pushes a state to the context stack.
*
* @param string $lexerName
* @param string $state
* @return \FSHL\Highlighter
*/
private function pushState($lexerName, $state)
{
array_unshift($this->stack, array($lexerName, $state));
return $this;
}
/**
* Pops a state from the context stack.
*
* @return array|null
*/
private function popState()
{
return array_shift($this->stack);
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL;
/**
* Lexer interface.
*
* @subpackage Lexer
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
interface Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage();
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState();
/**
* Returns states.
*
* @return array
*/
public function getStates();
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters();
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords();
}

View File

@ -0,0 +1,543 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Cpp lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Cpp
*/
class Cpp
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Cpp';
$this->trans = array(
0 => array(
0 => array(
0 => 0, 1 => 1
), 1 => array(
0 => 0, 1 => 1
), 2 => array(
0 => 1, 1 => -1
), 3 => array(
0 => 8, 1 => 1
), 4 => array(
0 => 4, 1 => 1
), 5 => array(
0 => 2, 1 => 1
), 6 => array(
0 => 2, 1 => 1
), 7 => array(
0 => 5, 1 => 1
), 8 => array(
0 => 6, 1 => 1
), 9 => array(
0 => 7, 1 => 1
)
), 1 => array(
0 => array(
0 => 9, 1 => -1
)
), 2 => array(
0 => array(
0 => 3, 1 => 1
), 1 => array(
0 => 2, 1 => 1
), 2 => array(
0 => 2, 1 => 1
), 3 => array(
0 => 9, 1 => -1
)
), 3 => array(
0 => array(
0 => 3, 1 => 1
), 1 => array(
0 => 9, 1 => -1
)
), 4 => array(
0 => array(
0 => 4, 1 => 1
), 1 => array(
0 => 4, 1 => 1
), 2 => array(
0 => 4, 1 => 1
), 3 => array(
0 => 9, 1 => -1
)
), 5 => array(
0 => array(
0 => 9, 1 => 0
), 1 => array(
0 => 5, 1 => 1
), 2 => array(
0 => 5, 1 => 1
), 3 => array(
0 => 5, 1 => 1
), 4 => array(
0 => 5, 1 => 1
)
), 6 => array(
0 => array(
0 => 9, 1 => 0
), 1 => array(
0 => 6, 1 => 1
), 2 => array(
0 => 6, 1 => 1
), 3 => array(
0 => 6, 1 => 1
)
), 7 => array(
0 => array(
0 => 7, 1 => 1
), 1 => array(
0 => 7, 1 => 1
), 2 => array(
0 => 9, 1 => 0
)
), 8 => array(
0 => array(
0 => 9, 1 => -1
), 1 => array(
0 => 8, 1 => 1
)
)
);
$this->initialState = 0;
$this->returnState = 9;
$this->quitState = 10;
$this->flags = array(
0 => 0, 1 => 5, 2 => 4, 3 => 0, 4 => 4, 5 => 4, 6 => 4, 7 => 4, 8 => 4
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL
);
$this->classes = array(
0 => NULL, 1 => NULL, 2 => 'cpp-num', 3 => 'cpp-num', 4 => 'cpp-preproc', 5 => 'cpp-quote', 6 => 'cpp-quote', 7 => 'cpp-comment', 8 => 'cpp-comment'
);
$this->keywords = array(
0 => 'cpp-keywords', 1 => array(
'bool' => 1, 'break' => 1, 'case' => 1, 'catch' => 1, 'char' => 1, 'class' => 1, 'const' => 1, 'const_cast' => 1, 'continue' => 1, 'default' => 1, 'delete' => 1, 'deprecated' => 1, 'dllexport' => 1, 'dllimport' => 1, 'do' => 1, 'double' => 1, 'dynamic_cast' => 1, 'else' => 1, 'enum' => 1, 'explicit' => 1, 'extern' => 1, 'false' => 1, 'float' => 1, 'for' => 1, 'friend' => 1, 'goto' => 1,
'if' => 1, 'inline' => 1, 'int' => 1, 'long' => 1, 'mutable' => 1, 'naked' => 1, 'namespace' => 1, 'new' => 1, 'noinline' => 1, 'noreturn' => 1, 'nothrow' => 1, 'novtable' => 1, 'operator' => 1, 'private' => 1, 'property' => 1, 'protected' => 1, 'public' => 1, 'register' => 1, 'reinterpret_cast' => 1, 'return' => 1, 'selectany' => 1, 'short' => 1, 'signed' => 1, 'sizeof' => 1, 'static' => 1, 'static_cast' => 1,
'struct' => 1, 'switch' => 1, 'template' => 1, 'this' => 1, 'thread' => 1, 'throw' => 1, 'true' => 1, 'try' => 1, 'typedef' => 1, 'typeid' => 1, 'typename' => 1, 'union' => 1, 'unsigned' => 1, 'using' => 1, 'uuid' => 1, 'virtual' => 1, 'void' => 1, 'volatile' => 1, '__wchar_t' => 1, 'wchar_t' => 1, 'while' => 1, '__abstract' => 1, '__alignof' => 1, '__asm' => 1, '__assume' => 1, '__based' => 1,
'__box' => 1, '__cdecl' => 1, '__declspec' => 1, '__delegate' => 1, '__event' => 1, '__except' => 1, '__fastcall' => 1, '__finally' => 1, '__forceinline' => 1, '__gc' => 1, '__hook' => 1, '__identifier' => 1, '__if_exists' => 1, '__if_not_exists' => 1, '__inline' => 1, '__int8' => 1, '__int16' => 1, '__int32' => 1, '__int64' => 1, '__interface' => 1, '__leave' => 1, '__m64' => 1, '__m128' => 1, '__m128d' => 1, '__m128i' => 1, '__multiple_inheritance' => 1,
'__nogc' => 1, '__noop' => 1, '__pin' => 1, '__property' => 1, '__raise' => 1, '__sealed' => 1, '__single_inheritance' => 1, '__stdcall' => 1, '__super' => 1, '__try_cast' => 1, '__try' => 1, '__unhook' => 1, '__uuidof' => 1, '__value' => 1, '__virtual_inheritance' => 1, '__w64' => 1
), 2 => true
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 3 => '//', 4 => '#', 7 => '"', 8 => '\'', 9 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^[a-z]+~i', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if (preg_match('~^\\d+~', $part, $matches)) {
return array(5, $matches[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(6, $matches[0], $buffer);
}
if ($delimiters[7] === $letter) {
return array(7, $delimiters[7], $buffer);
}
if ($delimiters[8] === $letter) {
return array(8, $delimiters[8], $buffer);
}
if (0 === strpos($part, $delimiters[9])) {
return array(9, $delimiters[9], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state KEYWORD.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^\\W+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NUMBER.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'x', 1 => 'f'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
return array(3, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEXA.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'L'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^[^a-f\\d]+~i', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state PREPROC.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\\\n", 1 => "\t", 2 => "\\\r\n", 3 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\\\\', 2 => '\\"', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\'', 1 => '\\\'', 2 => "\n", 3 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_BLOCK.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '*/'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,794 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Css lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Css
*/
class Css
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Css';
$this->trans = array(
0 => array(
0 => array(
0 => 10, 1 => 1
), 1 => array(
0 => 3, 1 => 1
), 2 => array(
0 => 3, 1 => 1
), 3 => array(
0 => 4, 1 => 1
), 4 => array(
0 => 5, 1 => 1
), 5 => array(
0 => 7, 1 => 1
), 6 => array(
0 => 12, 1 => 1
), 7 => array(
0 => 1, 1 => 1
), 8 => array(
0 => 2, 1 => 1
), 9 => array(
0 => 0, 1 => 1
), 10 => array(
0 => 0, 1 => 1
), 11 => array(
0 => 15, 1 => 1
), 12 => array(
0 => 13, 1 => 1
)
), 1 => array(
0 => array(
0 => 8, 1 => 1
), 1 => array(
0 => 9, 1 => 0
), 2 => array(
0 => 1, 1 => 0
), 3 => array(
0 => 1, 1 => 1
), 4 => array(
0 => 1, 1 => 1
), 5 => array(
0 => 14, 1 => 0
), 6 => array(
0 => 12, 1 => 1
)
), 2 => array(
0 => array(
0 => 14, 1 => -1
), 1 => array(
0 => 12, 1 => 1
)
), 3 => array(
0 => array(
0 => 14, 1 => 1
), 1 => array(
0 => 14, 1 => -1
), 2 => array(
0 => 14, 1 => -1
), 3 => array(
0 => 6, 1 => 1
), 4 => array(
0 => 12, 1 => 1
)
), 4 => array(
0 => array(
0 => 14, 1 => -1
), 1 => array(
0 => 14, 1 => -1
), 2 => array(
0 => 14, 1 => -1
), 3 => array(
0 => 6, 1 => 1
), 4 => array(
0 => 12, 1 => 1
)
), 5 => array(
0 => array(
0 => 14, 1 => -1
), 1 => array(
0 => 14, 1 => -1
), 2 => array(
0 => 14, 1 => -1
), 3 => array(
0 => 6, 1 => 1
), 4 => array(
0 => 12, 1 => 1
)
), 6 => array(
0 => array(
0 => 14, 1 => -1
), 1 => array(
0 => 14, 1 => -1
)
), 7 => array(
0 => array(
0 => 8, 1 => 1
), 1 => array(
0 => 9, 1 => 0
), 2 => array(
0 => 7, 1 => 0
), 3 => array(
0 => 7, 1 => 1
), 4 => array(
0 => 7, 1 => 1
), 5 => array(
0 => 14, 1 => 0
), 6 => array(
0 => 12, 1 => 1
)
), 8 => array(
0 => array(
0 => 14, 1 => -1
), 1 => array(
0 => 14, 1 => -1
), 2 => array(
0 => 8, 1 => 1
), 3 => array(
0 => 8, 1 => 1
), 4 => array(
0 => 12, 1 => 1
)
), 9 => array(
0 => array(
0 => 11, 1 => 1
), 1 => array(
0 => 14, 1 => -1
), 2 => array(
0 => 10, 1 => 1
), 3 => array(
0 => 14, 1 => -1
), 4 => array(
0 => 14, 1 => -1
), 5 => array(
0 => 9, 1 => 1
), 6 => array(
0 => 9, 1 => 1
), 7 => array(
0 => 12, 1 => 1
)
), 10 => array(
0 => array(
0 => 14, 1 => 0
), 1 => array(
0 => 9, 1 => 1
)
), 11 => array(
0 => array(
0 => 14, 1 => -1
)
), 12 => array(
0 => array(
0 => 12, 1 => 1
), 1 => array(
0 => 12, 1 => 1
), 2 => array(
0 => 14, 1 => 0
)
), 13 => NULL, 15 => NULL
);
$this->initialState = 0;
$this->returnState = 14;
$this->quitState = 15;
$this->flags = array(
0 => 0, 1 => 4, 2 => 4, 3 => 4, 4 => 4, 5 => 4, 6 => 4, 7 => 4, 8 => 4, 9 => 4, 10 => 4, 11 => 4, 12 => 4, 13 => 8, 15 => 8
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL, 9 => NULL, 10 => NULL, 11 => NULL, 12 => NULL, 13 => 'Php', 15 => NULL
);
$this->classes = array(
0 => NULL, 1 => 'css-at-rule', 2 => 'css-at-rule', 3 => 'css-tag', 4 => 'css-id', 5 => 'css-class', 6 => 'css-pseudo', 7 => NULL, 8 => 'css-property', 9 => 'css-value', 10 => 'css-func', 11 => 'css-color', 12 => 'css-comment', 13 => 'xlang', 15 => 'html-tag'
);
$this->keywords = array(
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
2 => '*', 3 => '#', 4 => '.', 5 => '{', 6 => '/*', 7 => '@media', 8 => '@', 9 => "\n", 10 => "\t", 11 => '</'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~[a-z]+\s*\(~iA', $text, $matches, 0, $textPos)) {
return array(0, $matches[0], $buffer);
}
if (preg_match('~^[a-z\\d]+~i', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if (0 === strpos($part, $delimiters[6])) {
return array(6, $delimiters[6], $buffer);
}
if (0 === strpos($part, $delimiters[7])) {
return array(7, $delimiters[7], $buffer);
}
if ($delimiters[8] === $letter) {
return array(8, $delimiters[8], $buffer);
}
if ($delimiters[9] === $letter) {
return array(9, $delimiters[9], $buffer);
}
if ($delimiters[10] === $letter) {
return array(10, $delimiters[10], $buffer);
}
if (0 === strpos($part, $delimiters[11])) {
return array(11, $delimiters[11], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(12, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state MEDIA.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
static $delimiters = array(
1 => ':', 2 => ';', 3 => "\n", 4 => "\t", 5 => ')', 6 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~[-a-z]+~iA', $text, $matches, 0, $textPos)) {
return array(0, $matches[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if (0 === strpos($part, $delimiters[6])) {
return array(6, $delimiters[6], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state AT_RULE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
1 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^\s+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state TAG.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '{', 1 => ',', 3 => ':', 4 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^\s+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state ID.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '{', 1 => ',', 3 => ':', 4 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^\s+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state CLASS.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '{', 2 => ',', 3 => ':', 4 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^\s+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state PSEUDO.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
1 => ','
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~^\s+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state DEF.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
1 => ':', 2 => ';', 3 => "\n", 4 => "\t", 5 => '}', 6 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~[-a-z]+~iA', $text, $matches, 0, $textPos)) {
return array(0, $matches[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if (0 === strpos($part, $delimiters[6])) {
return array(6, $delimiters[6], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state PROPERTY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
static $delimiters = array(
0 => ':', 1 => '}', 2 => "\n", 3 => "\t", 4 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state VALUE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter9($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '#', 1 => ';', 3 => ')', 4 => '}', 5 => "\n", 6 => "\t", 7 => '/*'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~[a-z]+\s*\(~iA', $text, $matches, 0, $textPos)) {
return array(2, $matches[0], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if ($delimiters[6] === $letter) {
return array(6, $delimiters[6], $buffer);
}
if (0 === strpos($part, $delimiters[7])) {
return array(7, $delimiters[7], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state FUNC.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter10($text, $textLength, $textPos)
{
static $delimiters = array(
0 => ')'
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
return array(1, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COLOR.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter11($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^[^a-f\\d]+~i', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter12($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '*/'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,672 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Html lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Html
*/
class Html
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Html';
$this->trans = array(
0 => array(
0 => array(
0 => 10, 1 => 1
), 1 => array(
0 => 11, 1 => 1
), 2 => array(
0 => 0, 1 => 0
), 3 => array(
0 => 2, 1 => 1
), 4 => array(
0 => 1, 1 => 1
), 5 => array(
0 => 0, 1 => 1
), 6 => array(
0 => 0, 1 => 1
)
), 1 => array(
0 => array(
0 => 0, 1 => 0
), 1 => array(
0 => 0, 1 => 0
), 2 => array(
0 => 0, 1 => 0
)
), 2 => array(
0 => array(
0 => 0, 1 => 0
), 1 => array(
0 => 3, 1 => 1
), 2 => array(
0 => 4, 1 => 0
), 3 => array(
0 => 4, 1 => 0
), 4 => array(
0 => 6, 1 => 0
), 5 => array(
0 => 6, 1 => 0
), 6 => array(
0 => 11, 1 => 1
)
), 3 => array(
0 => array(
0 => 8, 1 => 1
), 1 => array(
0 => 9, 1 => 1
), 2 => array(
0 => 2, 1 => -1
), 3 => array(
0 => 2, 1 => -1
), 4 => array(
0 => 11, 1 => 1
), 5 => array(
0 => 3, 1 => 1
), 6 => array(
0 => 3, 1 => 1
)
), 4 => array(
0 => array(
0 => 8, 1 => 1
), 1 => array(
0 => 9, 1 => 1
), 2 => array(
0 => 5, 1 => 1
), 3 => array(
0 => 11, 1 => 1
), 4 => array(
0 => 3, 1 => 1
), 5 => array(
0 => 3, 1 => 1
)
), 5 => array(
0 => array(
0 => 12, 1 => 0
)
), 6 => array(
0 => array(
0 => 8, 1 => 1
), 1 => array(
0 => 9, 1 => 1
), 2 => array(
0 => 7, 1 => 1
), 3 => array(
0 => 11, 1 => 1
), 4 => array(
0 => 3, 1 => 1
), 5 => array(
0 => 3, 1 => 1
)
), 7 => array(
0 => array(
0 => 12, 1 => 0
)
), 8 => array(
0 => array(
0 => 12, 1 => 0
), 1 => array(
0 => 11, 1 => 1
), 2 => array(
0 => 8, 1 => 1
), 3 => array(
0 => 8, 1 => 1
)
), 9 => array(
0 => array(
0 => 12, 1 => 0
), 1 => array(
0 => 11, 1 => 1
), 2 => array(
0 => 9, 1 => 1
), 3 => array(
0 => 9, 1 => 1
)
), 10 => array(
0 => array(
0 => 10, 1 => 1
), 1 => array(
0 => 10, 1 => 1
), 2 => array(
0 => 0, 1 => 0
), 3 => array(
0 => 11, 1 => 1
)
), 11 => NULL
);
$this->initialState = 0;
$this->returnState = 12;
$this->quitState = 13;
$this->flags = array(
0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 8, 6 => 0, 7 => 8, 8 => 4, 9 => 4, 10 => 0, 11 => 8
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => 'Css', 6 => NULL, 7 => 'Javascript', 8 => NULL, 9 => NULL, 10 => NULL, 11 => 'Php'
);
$this->classes = array(
0 => NULL, 1 => 'html-entity', 2 => 'html-tag', 3 => 'html-tagin', 4 => 'html-tagin', 5 => 'html-tag', 6 => 'html-tagin', 7 => 'html-tag', 8 => 'html-quote', 9 => 'html-quote', 10 => 'html-comment', 11 => 'xlang'
);
$this->keywords = array(
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '<!--', 2 => '<?', 3 => '<', 4 => '&', 5 => "\n", 6 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if ($delimiters[6] === $letter) {
return array(6, $delimiters[6], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state ENTITY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
static $delimiters = array(
0 => ';', 1 => '&'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^\s+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state TAG.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '>', 2 => 'style', 3 => 'STYLE', 4 => 'script', 5 => 'SCRIPT'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^\s+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
if (0 === strpos($part, $delimiters[5])) {
return array(5, $delimiters[5], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(6, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state TAGIN.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\'', 2 => '/>', 3 => '>', 5 => "\n", 6 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(4, $matches[0], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if ($delimiters[6] === $letter) {
return array(6, $delimiters[6], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state STYLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\'', 2 => '>', 4 => "\n", 5 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(3, $matches[0], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state CSS.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '>'
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state SCRIPT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\'', 2 => '>', 4 => "\n", 5 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(3, $matches[0], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state JAVASCRIPT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '>'
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 2 => "\n", 3 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter9($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\'', 2 => "\n", 3 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter10($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '-->'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(3, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,706 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached HtmlOnly lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\HtmlOnly
*/
class HtmlOnly
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'HtmlOnly';
$this->trans = array(
0 => array(
0 => array(
0 => 12, 1 => 1
), 1 => array(
0 => 0, 1 => 0
), 2 => array(
0 => 2, 1 => 1
), 3 => array(
0 => 1, 1 => 1
), 4 => array(
0 => 0, 1 => 1
), 5 => array(
0 => 0, 1 => 1
)
), 1 => array(
0 => array(
0 => 0, 1 => 0
), 1 => array(
0 => 0, 1 => 0
), 2 => array(
0 => 0, 1 => 0
)
), 2 => array(
0 => array(
0 => 0, 1 => 0
), 1 => array(
0 => 3, 1 => 1
), 2 => array(
0 => 4, 1 => 0
), 3 => array(
0 => 4, 1 => 0
), 4 => array(
0 => 7, 1 => 0
), 5 => array(
0 => 7, 1 => 0
)
), 3 => array(
0 => array(
0 => 10, 1 => 1
), 1 => array(
0 => 11, 1 => 1
), 2 => array(
0 => 2, 1 => -1
), 3 => array(
0 => 2, 1 => -1
), 4 => array(
0 => 3, 1 => 1
), 5 => array(
0 => 3, 1 => 1
)
), 4 => array(
0 => array(
0 => 10, 1 => 1
), 1 => array(
0 => 11, 1 => 1
), 2 => array(
0 => 5, 1 => -1
), 3 => array(
0 => 4, 1 => 1
), 4 => array(
0 => 4, 1 => 1
)
), 5 => array(
0 => array(
0 => 6, 1 => 0
)
), 6 => array(
0 => array(
0 => 6, 1 => 1
), 1 => array(
0 => 6, 1 => 1
), 2 => array(
0 => 2, 1 => 1
), 3 => array(
0 => 2, 1 => 1
)
), 7 => array(
0 => array(
0 => 10, 1 => 1
), 1 => array(
0 => 11, 1 => 1
), 2 => array(
0 => 8, 1 => -1
), 3 => array(
0 => 7, 1 => 1
), 4 => array(
0 => 7, 1 => 1
)
), 8 => array(
0 => array(
0 => 9, 1 => 0
)
), 9 => array(
0 => array(
0 => 9, 1 => 1
), 1 => array(
0 => 9, 1 => 1
), 2 => array(
0 => 2, 1 => 1
), 3 => array(
0 => 2, 1 => 1
)
), 10 => array(
0 => array(
0 => 13, 1 => 0
)
), 11 => array(
0 => array(
0 => 13, 1 => 0
)
), 12 => array(
0 => array(
0 => 12, 1 => 1
), 1 => array(
0 => 12, 1 => 1
), 2 => array(
0 => 0, 1 => 0
)
)
);
$this->initialState = 0;
$this->returnState = 13;
$this->quitState = 14;
$this->flags = array(
0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 4, 11 => 4, 12 => 0
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL, 9 => NULL, 10 => NULL, 11 => NULL, 12 => NULL
);
$this->classes = array(
0 => NULL, 1 => 'html-entity', 2 => 'html-tag', 3 => 'html-tagin', 4 => 'html-tagin', 5 => 'html-tag', 6 => NULL, 7 => 'html-tagin', 8 => 'html-tag', 9 => NULL, 10 => 'html-quote', 11 => 'html-quote', 12 => 'html-comment'
);
$this->keywords = array(
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '<!--', 1 => '<?', 2 => '<', 3 => '&', 4 => "\n", 5 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state ENTITY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
static $delimiters = array(
0 => ';', 1 => '&'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^\s+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state TAG.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '>', 2 => 'style', 3 => 'STYLE', 4 => 'script', 5 => 'SCRIPT'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^\s+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
if (0 === strpos($part, $delimiters[5])) {
return array(5, $delimiters[5], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state TAGIN.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\'', 2 => '/>', 3 => '>', 4 => "\n", 5 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state STYLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\'', 2 => '>', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state STYLE_END.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '>'
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state CSS.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '</style', 3 => '</STYLE'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state SCRIPT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\'', 2 => '>', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state SCRIPT_END.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '>'
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state JAVASCRIPT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter9($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '</script', 3 => '</SCRIPT'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter10($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"'
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter11($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\''
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter12($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '-->'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,479 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Java lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Java
*/
class Java
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Java';
$this->trans = array(
0 => array(
0 => array(
0 => 1, 1 => -1
), 1 => array(
0 => 2, 1 => 1
), 2 => array(
0 => 2, 1 => 1
), 3 => array(
0 => 4, 1 => 1
), 4 => array(
0 => 5, 1 => 1
), 5 => array(
0 => 6, 1 => 1
), 6 => array(
0 => 7, 1 => 1
), 7 => array(
0 => 0, 1 => 1
), 8 => array(
0 => 0, 1 => 1
)
), 1 => array(
0 => array(
0 => 8, 1 => -1
)
), 2 => array(
0 => array(
0 => 3, 1 => 1
), 1 => array(
0 => 2, 1 => 1
), 2 => array(
0 => 8, 1 => -1
)
), 3 => array(
0 => array(
0 => 8, 1 => -1
)
), 4 => array(
0 => array(
0 => 8, 1 => 0
), 1 => array(
0 => 4, 1 => 1
), 2 => array(
0 => 4, 1 => 1
), 3 => array(
0 => 4, 1 => 1
), 4 => array(
0 => 4, 1 => 1
)
), 5 => array(
0 => array(
0 => 8, 1 => 0
), 1 => array(
0 => 5, 1 => 1
), 2 => array(
0 => 5, 1 => 1
), 3 => array(
0 => 5, 1 => 1
), 4 => array(
0 => 5, 1 => 1
)
), 6 => array(
0 => array(
0 => 6, 1 => 1
), 1 => array(
0 => 6, 1 => 1
), 2 => array(
0 => 8, 1 => 0
)
), 7 => array(
0 => array(
0 => 8, 1 => -1
), 1 => array(
0 => 7, 1 => 1
)
)
);
$this->initialState = 0;
$this->returnState = 8;
$this->quitState = 9;
$this->flags = array(
0 => 0, 1 => 5, 2 => 4, 3 => 0, 4 => 4, 5 => 4, 6 => 4, 7 => 4
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL
);
$this->classes = array(
0 => NULL, 1 => NULL, 2 => 'java-num', 3 => 'java-num', 4 => 'java-quote', 5 => 'java-quote', 6 => 'java-comment', 7 => 'java-comment'
);
$this->keywords = array(
0 => 'java-keywords', 1 => array(
'abstract' => 1, 'double' => 1, 'int' => 1, 'strictfp' => 1, 'boolean' => 1, 'else' => 1, 'interface' => 1, 'super' => 1, 'break' => 1, 'extends' => 1, 'long' => 1, 'switch' => 1, 'byte' => 1, 'final' => 1, 'native' => 1, 'synchronized' => 1, 'case' => 1, 'finally' => 1, 'new' => 1, 'this' => 1, 'catch' => 1, 'float' => 1, 'package' => 1, 'throw' => 1, 'char' => 1, 'for' => 1,
'private' => 1, 'throws' => 1, 'class' => 1, 'goto' => 1, 'protected' => 1, 'transient' => 1, 'const' => 1, 'if' => 1, 'public' => 1, 'try' => 1, 'continue' => 1, 'implements' => 1, 'return' => 1, 'void' => 1, 'default' => 1, 'import' => 1, 'short' => 1, 'volatile' => 1, 'do' => 1, 'instanceof' => 1, 'static' => 1, 'while' => 1
), 2 => true
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
3 => '"', 4 => '\'', 5 => '/*', 6 => '//', 7 => "\n", 8 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~^[a-z]+~i', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
if (preg_match('~^\\d+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if (0 === strpos($part, $delimiters[5])) {
return array(5, $delimiters[5], $buffer);
}
if (0 === strpos($part, $delimiters[6])) {
return array(6, $delimiters[6], $buffer);
}
if ($delimiters[7] === $letter) {
return array(7, $delimiters[7], $buffer);
}
if ($delimiters[8] === $letter) {
return array(8, $delimiters[8], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state KEYWORD.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^\\W+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NUMBER.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'x'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
return array(2, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEXA.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^[^a-f\\d]+~i', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\\\\', 2 => '\\"', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\'', 1 => '\\\\', 2 => '\\\'', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_BLOCK.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '*/'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,507 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Javascript lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Javascript
*/
class Javascript
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Javascript';
$this->trans = array(
0 => array(
0 => array(
0 => 0, 1 => 1
), 1 => array(
0 => 0, 1 => 1
), 2 => array(
0 => 1, 1 => -1
), 3 => array(
0 => 2, 1 => 1
), 4 => array(
0 => 2, 1 => 1
), 5 => array(
0 => 1, 1 => 0
), 6 => array(
0 => 4, 1 => 1
), 7 => array(
0 => 5, 1 => 1
), 8 => array(
0 => 6, 1 => 1
), 9 => array(
0 => 7, 1 => 1
), 10 => array(
0 => 8, 1 => 1
), 11 => array(
0 => 9, 1 => 1
), 12 => array(
0 => 11, 1 => 1
)
), 1 => array(
0 => array(
0 => 10, 1 => -1
)
), 2 => array(
0 => array(
0 => 3, 1 => 1
), 1 => array(
0 => 2, 1 => 1
), 2 => array(
0 => 10, 1 => -1
)
), 3 => array(
0 => array(
0 => 10, 1 => -1
)
), 4 => array(
0 => array(
0 => 10, 1 => 0
), 1 => array(
0 => 9, 1 => 1
)
), 5 => array(
0 => array(
0 => 10, 1 => 0
), 1 => array(
0 => 9, 1 => 1
)
), 6 => array(
0 => array(
0 => 6, 1 => 1
), 1 => array(
0 => 6, 1 => 1
), 2 => array(
0 => 10, 1 => 0
), 3 => array(
0 => 9, 1 => 1
)
), 7 => array(
0 => array(
0 => 10, 1 => -1
), 1 => array(
0 => 7, 1 => 1
), 2 => array(
0 => 9, 1 => 1
)
), 8 => array(
0 => array(
0 => 10, 1 => -1
)
), 9 => NULL, 11 => NULL
);
$this->initialState = 0;
$this->returnState = 10;
$this->quitState = 11;
$this->flags = array(
0 => 0, 1 => 5, 2 => 4, 3 => 0, 4 => 4, 5 => 4, 6 => 4, 7 => 4, 8 => 0, 9 => 8, 11 => 8
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL, 9 => 'Php', 11 => NULL
);
$this->classes = array(
0 => 'js-out', 1 => 'js-out', 2 => 'js-num', 3 => 'js-num', 4 => 'js-quote', 5 => 'js-quote', 6 => 'js-comment', 7 => 'js-comment', 8 => 'js-quote', 9 => 'xlang', 11 => 'html-tag'
);
$this->keywords = array(
0 => 'js-keywords', 1 => array(
'abstract' => 1, 'boolean' => 1, 'break' => 1, 'byte' => 1, 'case' => 1, 'catch' => 1, 'char' => 1, 'class' => 1, 'const' => 1, 'continue' => 1, 'debugger' => 1, 'default' => 1, 'delete' => 1, 'do' => 1, 'double' => 1, 'else' => 1, 'enum' => 1, 'export' => 1, 'extends' => 1, 'false' => 1, 'final' => 1, 'finally' => 1, 'float' => 1, 'for' => 1, 'function' => 1, 'goto' => 1,
'if' => 1, 'implements' => 1, 'import' => 1, 'in' => 1, 'instanceof' => 1, 'int' => 1, 'interface' => 1, 'long' => 1, 'native' => 1, 'new' => 1, 'null' => 1, 'package' => 1, 'private' => 1, 'protected' => 1, 'public' => 1, 'return' => 1, 'short' => 1, 'static' => 1, 'super' => 1, 'switch' => 1, 'synchronized' => 1, 'this' => 1, 'throw' => 1, 'throws' => 1, 'transient' => 1, 'true' => 1,
'try' => 1, 'typeof' => 1, 'var' => 1, 'void' => 1, 'volatile' => 1, 'while' => 1, 'with' => 1, 'document' => 2, 'getAttribute' => 2, 'getElementsByTagName' => 2, 'getElementById' => 2
), 2 => true
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 5 => '.', 6 => '"', 7 => '\'', 8 => '/*', 9 => '//', 12 => '</'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^[a-z]+~i', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
if (preg_match('~^\\d+~', $part, $matches)) {
return array(3, $matches[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(4, $matches[0], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if ($delimiters[6] === $letter) {
return array(6, $delimiters[6], $buffer);
}
if ($delimiters[7] === $letter) {
return array(7, $delimiters[7], $buffer);
}
if (0 === strpos($part, $delimiters[8])) {
return array(8, $delimiters[8], $buffer);
}
if (0 === strpos($part, $delimiters[9])) {
return array(9, $delimiters[9], $buffer);
}
if (preg_match('~/.*?[^\\\\]/[gim]*~A', $text, $matches, 0, $textPos)) {
return array(10, $matches[0], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(11, $matches[0], $buffer);
}
if (0 === strpos($part, $delimiters[12])) {
return array(12, $delimiters[12], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state KEYWORD.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^\\W+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NUMBER.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'x'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
return array(2, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEXA.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^[^a-f\\d]+~i', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"'
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\''
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_BLOCK.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '*/'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(3, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~<\\?(php|=|(?!xml))~A', $text, $matches, 0, $textPos)) {
return array(2, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state REGEXP.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
return array(0, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,162 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Minimal lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Minimal
*/
class Minimal
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Minimal';
$this->trans = array(
0 => array(
0 => array(
0 => 0, 1 => 1
), 1 => array(
0 => 0, 1 => 1
)
)
);
$this->initialState = 0;
$this->returnState = 1;
$this->quitState = 2;
$this->flags = array(
0 => 0
);
$this->data = array(
0 => NULL
);
$this->classes = array(
0 => NULL
);
$this->keywords = array(
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,710 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Neon lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Neon
*/
class Neon
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Neon';
$this->trans = array(
0 => array(
0 => array(
0 => 1, 1 => 1
), 1 => array(
0 => 2, 1 => 1
), 2 => array(
0 => 7, 1 => 1
), 3 => array(
0 => 3, 1 => 1
), 4 => array(
0 => 0, 1 => 1
), 5 => array(
0 => 0, 1 => 1
)
), 1 => array(
0 => array(
0 => 6, 1 => 1
), 1 => array(
0 => 6, 1 => 1
), 2 => array(
0 => 1, 1 => 1
), 3 => array(
0 => 2, 1 => 1
), 4 => array(
0 => 3, 1 => 1
), 5 => array(
0 => 1, 1 => 1
), 6 => array(
0 => 1, 1 => 1
)
), 2 => array(
0 => array(
0 => 6, 1 => 1
), 1 => array(
0 => 6, 1 => 1
), 2 => array(
0 => 4, 1 => 1
)
), 3 => array(
0 => array(
0 => 4, 1 => 1
)
), 4 => array(
0 => array(
0 => 0, 1 => 1
), 1 => array(
0 => 2, 1 => 1
), 2 => array(
0 => 7, 1 => 1
), 3 => array(
0 => 8, 1 => 1
), 4 => array(
0 => 9, 1 => 1
), 5 => array(
0 => 6, 1 => 1
), 6 => array(
0 => 6, 1 => 1
), 7 => array(
0 => 6, 1 => 1
), 8 => array(
0 => 6, 1 => 1
), 9 => array(
0 => 6, 1 => 1
), 10 => array(
0 => 6, 1 => 1
), 11 => array(
0 => 6, 1 => 1
), 12 => array(
0 => 5, 1 => 1
), 13 => array(
0 => 11, 1 => 1
), 14 => array(
0 => 11, 1 => 1
), 15 => array(
0 => 10, 1 => 1
), 16 => array(
0 => 12, 1 => 1
), 17 => array(
0 => 4, 1 => 1
)
), 5 => array(
0 => array(
0 => 10, 1 => 1
), 1 => array(
0 => 7, 1 => 1
), 2 => array(
0 => 0, 1 => 1
)
), 6 => array(
0 => array(
0 => 13, 1 => -1
)
), 7 => array(
0 => array(
0 => 0, 1 => -1
), 1 => array(
0 => 7, 1 => 1
)
), 8 => array(
0 => array(
0 => 13, 1 => 0
), 1 => array(
0 => 10, 1 => 1
), 2 => array(
0 => 8, 1 => 1
)
), 9 => array(
0 => array(
0 => 13, 1 => 0
), 1 => array(
0 => 10, 1 => 1
), 2 => array(
0 => 9, 1 => 1
)
), 10 => array(
0 => array(
0 => 13, 1 => 0
)
), 11 => array(
0 => array(
0 => 11, 1 => 1
), 1 => array(
0 => 13, 1 => -1
)
), 12 => array(
0 => array(
0 => 13, 1 => -1
)
)
);
$this->initialState = 0;
$this->returnState = 13;
$this->quitState = 14;
$this->flags = array(
0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 4, 7 => 0, 8 => 4, 9 => 4, 10 => 4, 11 => 4, 12 => 4
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL, 9 => NULL, 10 => NULL, 11 => NULL, 12 => NULL
);
$this->classes = array(
0 => NULL, 1 => 'neon-section', 2 => 'neon-key', 3 => 'neon-sep', 4 => 'neon-value', 5 => 'neon-value', 6 => 'neon-sep', 7 => 'neon-comment', 8 => 'neon-quote', 9 => 'neon-quote', 10 => 'neon-var', 11 => 'neon-num', 12 => 'neon-ref'
);
$this->keywords = array(
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
2 => '#', 3 => '-', 4 => "\n", 5 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if (preg_match('~[\\w.]+(?=(\\s*<\\s*[\\w.]+)?\\s*:\\s*\n)~Ai', $text, $matches, 0, $textPos)) {
return array(0, $matches[0], $buffer);
}
if (preg_match('~[\\w.]+(?=\\s*(?::|=))~Ai', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state SECTION.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '<', 1 => ':', 4 => '-', 5 => "\n", 6 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~[\\w.]+(?=(\\s*<\\s*[\\w.]+)?\\s*:\\s*\n)~Ai', $text, $matches, 0, $textPos)) {
return array(2, $matches[0], $buffer);
}
if (preg_match('~[\\w.]+(?=\\s*(?::|=))~Ai', $text, $matches, 0, $textPos)) {
return array(3, $matches[0], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if ($delimiters[6] === $letter) {
return array(6, $delimiters[6], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state KEY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => ':', 1 => '='
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
return array(2, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state LIST.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
return array(0, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state VALUE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 2 => '#', 3 => '"', 4 => '\'', 5 => '[', 6 => ']', 7 => '{', 8 => '}', 9 => '=', 10 => ',', 11 => ':', 16 => '@', 17 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~[\\w.]+(?=\\s*(?::|=))~Ai', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if ($delimiters[6] === $letter) {
return array(6, $delimiters[6], $buffer);
}
if ($delimiters[7] === $letter) {
return array(7, $delimiters[7], $buffer);
}
if ($delimiters[8] === $letter) {
return array(8, $delimiters[8], $buffer);
}
if ($delimiters[9] === $letter) {
return array(9, $delimiters[9], $buffer);
}
if ($delimiters[10] === $letter) {
return array(10, $delimiters[10], $buffer);
}
if ($delimiters[11] === $letter) {
return array(11, $delimiters[11], $buffer);
}
if (preg_match('~[a-z](?![,\\]}#\n])~Ai', $text, $matches, 0, $textPos)) {
return array(12, $matches[0], $buffer);
}
if (preg_match('~^\\d+~', $part, $matches)) {
return array(13, $matches[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(14, $matches[0], $buffer);
}
if (preg_match('~%\\w+(?=%)~Ai', $text, $matches, 0, $textPos)) {
return array(15, $matches[0], $buffer);
}
if ($delimiters[16] === $letter) {
return array(16, $delimiters[16], $buffer);
}
if ($delimiters[17] === $letter) {
return array(17, $delimiters[17], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state TEXT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
1 => '#', 2 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if (preg_match('~%\\w+(?=%)~Ai', $text, $matches, 0, $textPos)) {
return array(0, $matches[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state SEPARATOR.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
return array(0, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 2 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~%\\w+(?=%)~Ai', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter9($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\'', 2 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~%\\w+(?=%)~Ai', $text, $matches, 0, $textPos)) {
return array(1, $matches[0], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state VARIABLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter10($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '%'
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NUMBER.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter11($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
return array(1, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state REFERENCE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter12($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^\\W+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,992 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Php lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Php
*/
class Php
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Php';
$this->trans = array(
0 => array(
0 => array(
0 => 5, 1 => 1
), 1 => array(
0 => 10, 1 => 1
), 2 => array(
0 => 7, 1 => 1
), 3 => array(
0 => 2, 1 => -1
), 4 => array(
0 => 2, 1 => -1
), 5 => array(
0 => 13, 1 => 1
), 6 => array(
0 => 13, 1 => 1
), 7 => array(
0 => 0, 1 => 1
), 8 => array(
0 => 0, 1 => 1
), 9 => array(
0 => 4, 1 => 1
), 10 => array(
0 => 3, 1 => 1
), 11 => array(
0 => 4, 1 => 1
), 12 => array(
0 => 17, 1 => 1
), 13 => array(
0 => 1, 1 => -1
), 14 => array(
0 => 11, 1 => 1
), 15 => array(
0 => 8, 1 => 1
)
), 1 => array(
0 => array(
0 => 16, 1 => 0
), 1 => array(
0 => 16, 1 => 0
), 2 => array(
0 => 16, 1 => 0
)
), 2 => array(
0 => array(
0 => 16, 1 => -1
)
), 3 => array(
0 => array(
0 => 3, 1 => 1
), 1 => array(
0 => 3, 1 => 1
), 2 => array(
0 => 16, 1 => 0
)
), 4 => array(
0 => array(
0 => 16, 1 => -1
), 1 => array(
0 => 4, 1 => 1
), 2 => array(
0 => 16, 1 => 0
)
), 5 => array(
0 => array(
0 => 16, 1 => -1
), 1 => array(
0 => 5, 1 => 1
), 2 => array(
0 => 5, 1 => 1
), 3 => array(
0 => 5, 1 => 1
)
), 6 => array(
0 => array(
0 => 16, 1 => 0
), 1 => array(
0 => 16, 1 => -1
)
), 7 => array(
0 => array(
0 => 16, 1 => 0
), 1 => array(
0 => 7, 1 => 1
), 2 => array(
0 => 7, 1 => 1
), 3 => array(
0 => 5, 1 => 1
), 4 => array(
0 => 6, 1 => 1
), 5 => array(
0 => 7, 1 => 1
), 6 => array(
0 => 7, 1 => 1
)
), 8 => array(
0 => array(
0 => 9, 1 => 1
), 1 => array(
0 => 8, 1 => 1
), 2 => array(
0 => 8, 1 => 1
), 3 => array(
0 => 5, 1 => 1
), 4 => array(
0 => 6, 1 => 1
)
), 9 => array(
0 => array(
0 => 0, 1 => 0
), 1 => array(
0 => 8, 1 => -1
)
), 10 => array(
0 => array(
0 => 16, 1 => 0
), 1 => array(
0 => 10, 1 => 1
), 2 => array(
0 => 10, 1 => 1
), 3 => array(
0 => 10, 1 => 1
), 4 => array(
0 => 10, 1 => 1
)
), 11 => array(
0 => array(
0 => 12, 1 => 1
), 1 => array(
0 => 11, 1 => 1
)
), 12 => array(
0 => array(
0 => 0, 1 => 0
), 1 => array(
0 => 11, 1 => -1
)
), 13 => array(
0 => array(
0 => 14, 1 => 1
), 1 => array(
0 => 14, 1 => 1
), 2 => array(
0 => 15, 1 => 1
), 3 => array(
0 => 13, 1 => 1
), 4 => array(
0 => 13, 1 => 1
), 5 => array(
0 => 16, 1 => -1
)
), 14 => array(
0 => array(
0 => 14, 1 => 0
), 1 => array(
0 => 14, 1 => 0
), 2 => array(
0 => 16, 1 => -1
)
), 15 => array(
0 => array(
0 => 16, 1 => -1
)
), 17 => NULL
);
$this->initialState = 0;
$this->returnState = 16;
$this->quitState = 17;
$this->flags = array(
0 => 0, 1 => 4, 2 => 5, 3 => 4, 4 => 4, 5 => 4, 6 => 4, 7 => 4, 8 => 0, 9 => 0, 10 => 4, 11 => 0, 12 => 0, 13 => 4, 14 => 0, 15 => 0, 17 => 8
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL, 9 => NULL, 10 => NULL, 11 => NULL, 12 => NULL, 13 => NULL, 14 => NULL, 15 => NULL, 17 => NULL
);
$this->classes = array(
0 => NULL, 1 => 'xlang', 2 => NULL, 3 => 'php-comment', 4 => 'php-comment', 5 => 'php-var', 6 => 'php-var', 7 => 'php-quote', 8 => 'php-quote', 9 => 'php-quote', 10 => 'php-quote', 11 => 'php-quote', 12 => 'php-quote', 13 => 'php-num', 14 => 'php-num', 15 => 'php-num', 17 => 'xlang'
);
$this->keywords = array(
0 => 'php-keyword', 1 => array(
'abstract' => 1, 'and' => 1, 'array' => 1, 'as' => 1, 'break' => 1, 'callable' => 1, 'case' => 1, 'catch' => 1, 'class' => 1, 'clone' => 1, 'const' => 1, 'continue' => 1, 'declare' => 1, 'default' => 1, 'do' => 1, 'else' => 1, 'elseif' => 1, 'enddeclare' => 1, 'endfor' => 1, 'endforeach' => 1, 'endif' => 1, 'endswitch' => 1, 'endwhile' => 2, 'extends' => 1, 'final' => 1, 'for' => 1,
'foreach' => 1, 'function' => 1, 'global' => 1, 'goto' => 1, 'if' => 1, 'implements' => 1, 'interface' => 1, 'instanceof' => 1, 'insteadof' => 1, 'namespace' => 1, 'new' => 1, 'or' => 1, 'private' => 1, 'protected' => 1, 'public' => 1, 'static' => 1, 'switch' => 1, 'throw' => 1, 'trait' => 1, 'try' => 1, 'use' => 1, 'var' => 1, 'while' => 1, 'xor' => 1, '__CLASS__' => 1, '__DIR__' => 1,
'__FILE__' => 1, '__LINE__' => 1, '__FUNCTION__' => 1, '__METHOD__' => 1, '__NAMESPACE__' => 1, '__TRAIT__' => 1, 'die' => 1, 'echo' => 1, 'empty' => 1, 'exit' => 1, 'eval' => 2, 'include' => 1, 'include_once' => 1, 'isset' => 1, 'list' => 1, 'require' => 1, 'require_once' => 1, 'return' => 1, 'print' => 1, 'unset' => 1, 'true' => 1, 'false' => 1, 'null' => 1, 'abs' => 2, 'acos' => 2, 'acosh' => 2,
'ada_afetch' => 2, 'ada_autocommit' => 2, 'ada_close' => 2, 'ada_commit' => 2, 'ada_connect' => 2, 'ada_exec' => 2, 'ada_fetchrow' => 2, 'ada_fieldname' => 2, 'ada_fieldnum' => 2, 'ada_fieldtype' => 2, 'ada_freeresult' => 2, 'ada_numfields' => 2, 'ada_numrows' => 2, 'ada_result' => 2, 'ada_resultall' => 2, 'ada_rollback' => 2, 'addcslashes' => 2, 'addslashes' => 2, 'aggregate' => 2, 'aggregate_methods' => 2, 'aggregate_methods_by_list' => 2, 'aggregate_methods_by_regexp' => 2, 'aggregate_properties' => 2, 'aggregate_properties_by_list' => 2, 'aggregate_properties_by_regexp' => 2, 'aggregation_info' => 2,
'apache_child_terminate' => 2, 'apache_get_modules' => 2, 'apache_get_version' => 2, 'apache_getenv' => 2, 'apache_lookup_uri' => 2, 'apache_note' => 2, 'apache_request_headers' => 2, 'apache_response_headers' => 2, 'apache_setenv' => 2, 'apc_add' => 2, 'apc_bin_dump' => 2, 'apc_bin_dumpfile' => 2, 'apc_bin_load' => 2, 'apc_bin_loadfile' => 2, 'apc_cache_info' => 2, 'apc_cas' => 2, 'apc_clear_cache' => 2, 'apc_compile_file' => 2, 'apc_dec' => 2, 'apc_define_constants' => 2, 'apc_delete' => 2, 'apc_delete_file' => 2, 'apc_exists' => 2, 'apc_fetch' => 2, 'apc_inc' => 2, 'apc_load_constants' => 2,
'apc_sma_info' => 2, 'apc_store' => 2, 'array_change_key_case' => 2, 'array_chunk' => 2, 'array_combine' => 2, 'array_count_values' => 2, 'array_diff' => 2, 'array_diff_assoc' => 2, 'array_diff_key' => 2, 'array_diff_uassoc' => 2, 'array_diff_ukey' => 2, 'array_fill' => 2, 'array_fill_keys' => 2, 'array_filter' => 2, 'array_flip' => 2, 'array_intersect' => 2, 'array_intersect_assoc' => 2, 'array_intersect_key' => 2, 'array_intersect_uassoc' => 2, 'array_intersect_ukey' => 2, 'array_key_exists' => 2, 'array_keys' => 2, 'array_map' => 2, 'array_merge' => 2, 'array_merge_recursive' => 2, 'array_multisort' => 2,
'array_pad' => 2, 'array_pop' => 2, 'array_product' => 2, 'array_push' => 2, 'array_rand' => 2, 'array_reduce' => 2, 'array_replace' => 2, 'array_replace_recursive' => 2, 'array_reverse' => 2, 'array_search' => 2, 'array_shift' => 2, 'array_slice' => 2, 'array_splice' => 2, 'array_sum' => 2, 'array_udiff' => 2, 'array_udiff_assoc' => 2, 'array_udiff_uassoc' => 2, 'array_uintersect' => 2, 'array_uintersect_assoc' => 2, 'array_uintersect_uassoc' => 2, 'array_unique' => 2, 'array_unshift' => 2, 'array_values' => 2, 'array_walk' => 2, 'array_walk_recursive' => 2, 'arsort' => 2,
'asin' => 2, 'asinh' => 2, 'asort' => 2, 'aspell_check' => 2, 'aspell_check-raw' => 2, 'aspell_new' => 2, 'aspell_suggest' => 2, 'assert' => 2, 'assert_options' => 2, 'atan' => 2, 'atan2' => 2, 'atanh' => 2, 'base64_decode' => 2, 'base64_encode' => 2, 'base_convert' => 2, 'basename' => 2, 'bcadd' => 2, 'bccomp' => 2, 'bcdiv' => 2, 'bcmod' => 2, 'bcmul' => 2, 'bcompiler_load' => 2, 'bcompiler_load_exe' => 2, 'bcompiler_parse_class' => 2, 'bcompiler_read' => 2, 'bcompiler_write_class' => 2,
'bcompiler_write_constant' => 2, 'bcompiler_write_exe_footer' => 2, 'bcompiler_write_file' => 2, 'bcompiler_write_footer' => 2, 'bcompiler_write_function' => 2, 'bcompiler_write_functions_from_file' => 2, 'bcompiler_write_header' => 2, 'bcompiler_write_included_filename' => 2, 'bcpow' => 2, 'bcpowmod' => 2, 'bcscale' => 2, 'bcsqrt' => 2, 'bcsub' => 2, 'bin2hex' => 2, 'bind_textdomain_codeset' => 2, 'bindec' => 2, 'bindtextdomain' => 2, 'bitset_empty' => 2, 'bitset_equal' => 2, 'bitset_excl' => 2, 'bitset_fill' => 2, 'bitset_from_array' => 2, 'bitset_from_hash' => 2, 'bitset_from_string' => 2, 'bitset_in' => 2, 'bitset_incl' => 2,
'bitset_intersection' => 2, 'bitset_invert' => 2, 'bitset_is_empty' => 2, 'bitset_subset' => 2, 'bitset_to_array' => 2, 'bitset_to_hash' => 2, 'bitset_to_string' => 2, 'bitset_union' => 2, 'blenc_encrypt' => 2, 'bzclose' => 2, 'bzcompress' => 2, 'bzdecompress' => 2, 'bzerrno' => 2, 'bzerror' => 2, 'bzerrstr' => 2, 'bzflush' => 2, 'bzopen' => 2, 'bzread' => 2, 'bzwrite' => 2, 'cal_days_in_month' => 2, 'cal_from_jd' => 2, 'cal_info' => 2, 'cal_to_jd' => 2, 'call_user_func' => 2, 'call_user_func_array' => 2, 'call_user_method' => 2,
'call_user_method_array' => 2, 'ceil' => 2, 'chdir' => 2, 'checkdate' => 2, 'checkdnsrr' => 2, 'chgrp' => 2, 'chmod' => 2, 'chop' => 2, 'chown' => 2, 'chr' => 2, 'chunk_split' => 2, 'class_alias' => 2, 'class_exists' => 2, 'class_implements' => 2, 'class_parents' => 2, 'classkit_aggregate_methods' => 2, 'classkit_doc_comments' => 2, 'classkit_import' => 2, 'classkit_method_add' => 2, 'classkit_method_copy' => 2, 'classkit_method_redefine' => 2, 'classkit_method_remove' => 2, 'classkit_method_rename' => 2, 'clearstatcache' => 2, 'closedir' => 2, 'closelog' => 2,
'collator_asort' => 2, 'collator_compare' => 2, 'collator_create' => 2, 'collator_get_attribute' => 2, 'collator_get_error_code' => 2, 'collator_get_error_message' => 2, 'collator_get_locale' => 2, 'collator_get_sort_key' => 2, 'collator_get_strength' => 2, 'collator_set_attribute' => 2, 'collator_set_strength' => 2, 'collator_sort' => 2, 'collator_sort_with_sort_keys' => 2, 'com_create_guid' => 2, 'com_event_sink' => 2, 'com_get_active_object' => 2, 'com_load_typelib' => 2, 'com_message_pump' => 2, 'com_print_typeinfo' => 2, 'compact' => 2, 'confirm_phpdoc_compiled' => 2, 'connection_aborted' => 2, 'connection_status' => 2, 'connection_timeout' => 2, 'constant' => 2, 'contained' => 2,
'convert_cyr_string' => 2, 'convert_uudecode' => 2, 'convert_uuencode' => 2, 'copy' => 2, 'cos' => 2, 'cosh' => 2, 'count' => 2, 'count_chars' => 2, 'cpdf_add_annotation' => 2, 'cpdf_add_outline' => 2, 'cpdf_arc' => 2, 'cpdf_begin_text' => 2, 'cpdf_circle' => 2, 'cpdf_clip' => 2, 'cpdf_close' => 2, 'cpdf_closepath' => 2, 'cpdf_closepath_fill_stroke' => 2, 'cpdf_closepath_stroke' => 2, 'cpdf_continue_text' => 2, 'cpdf_curveto' => 2, 'cpdf_end_text' => 2, 'cpdf_fill' => 2, 'cpdf_fill_stroke' => 2, 'cpdf_finalize' => 2, 'cpdf_finalize_page' => 2, 'cpdf_global_set_document_limits' => 2,
'cpdf_import_jpeg' => 2, 'cpdf_lineto' => 2, 'cpdf_moveto' => 2, 'cpdf_newpath' => 2, 'cpdf_open' => 2, 'cpdf_output_buffer' => 2, 'cpdf_page_init' => 2, 'cpdf_place_inline_image' => 2, 'cpdf_rect' => 2, 'cpdf_restore' => 2, 'cpdf_rlineto' => 2, 'cpdf_rmoveto' => 2, 'cpdf_rotate' => 2, 'cpdf_rotate_text' => 2, 'cpdf_save' => 2, 'cpdf_save_to_file' => 2, 'cpdf_scale' => 2, 'cpdf_set_action_url' => 2, 'cpdf_set_char_spacing' => 2, 'cpdf_set_creator' => 2, 'cpdf_set_current_page' => 2, 'cpdf_set_font' => 2, 'cpdf_set_font_directories' => 2, 'cpdf_set_font_map_file' => 2, 'cpdf_set_horiz_scaling' => 2, 'cpdf_set_keywords' => 2,
'cpdf_set_leading' => 2, 'cpdf_set_page_animation' => 2, 'cpdf_set_subject' => 2, 'cpdf_set_text_matrix' => 2, 'cpdf_set_text_pos' => 2, 'cpdf_set_text_rendering' => 2, 'cpdf_set_text_rise' => 2, 'cpdf_set_title' => 2, 'cpdf_set_viewer_preferences' => 2, 'cpdf_set_word_spacing' => 2, 'cpdf_setdash' => 2, 'cpdf_setflat' => 2, 'cpdf_setgray' => 2, 'cpdf_setgray_fill' => 2, 'cpdf_setgray_stroke' => 2, 'cpdf_setlinecap' => 2, 'cpdf_setlinejoin' => 2, 'cpdf_setlinewidth' => 2, 'cpdf_setmiterlimit' => 2, 'cpdf_setrgbcolor' => 2, 'cpdf_setrgbcolor_fill' => 2, 'cpdf_setrgbcolor_stroke' => 2, 'cpdf_show' => 2, 'cpdf_show_xy' => 2, 'cpdf_stringwidth' => 2, 'cpdf_stroke' => 2,
'cpdf_text' => 2, 'cpdf_translate' => 2, 'crack_check' => 2, 'crack_closedict' => 2, 'crack_getlastmessage' => 2, 'crack_opendict' => 2, 'crc32' => 2, 'create_function' => 2, 'crypt' => 2, 'ctype_alnum' => 2, 'ctype_alpha' => 2, 'ctype_cntrl' => 2, 'ctype_digit' => 2, 'ctype_graph' => 2, 'ctype_lower' => 2, 'ctype_print' => 2, 'ctype_punct' => 2, 'ctype_space' => 2, 'ctype_upper' => 2, 'ctype_xdigit' => 2, 'curl_close' => 2, 'curl_copy_handle' => 2, 'curl_errno' => 2, 'curl_error' => 2, 'curl_exec' => 2, 'curl_getinfo' => 2,
'curl_init' => 2, 'curl_multi_add_handle' => 2, 'curl_multi_close' => 2, 'curl_multi_exec' => 2, 'curl_multi_getcontent' => 2, 'curl_multi_info_read' => 2, 'curl_multi_init' => 2, 'curl_multi_remove_handle' => 2, 'curl_multi_select' => 2, 'curl_setopt' => 2, 'curl_setopt_array' => 2, 'curl_version' => 2, 'current' => 2, 'cvsclient_connect' => 2, 'cvsclient_log' => 2, 'cvsclient_login' => 2, 'cvsclient_retrieve' => 2, 'date' => 2, 'date_add' => 2, 'date_create' => 2, 'date_create_from_format' => 2, 'date_date_set' => 2, 'date_default_timezone_get' => 2, 'date_default_timezone_set' => 2, 'date_diff' => 2, 'date_format' => 2,
'date_get_last_errors' => 2, 'date_interval_create_from_date_string' => 2, 'date_interval_format' => 2, 'date_isodate_set' => 2, 'date_modify' => 2, 'date_offset_get' => 2, 'date_parse' => 2, 'date_parse_from_format' => 2, 'date_sub' => 2, 'date_sun_info' => 2, 'date_sunrise' => 2, 'date_sunset' => 2, 'date_time_set' => 2, 'date_timestamp_get' => 2, 'date_timestamp_set' => 2, 'date_timezone_get' => 2, 'date_timezone_set' => 2, 'datefmt_create' => 2, 'datefmt_format' => 2, 'datefmt_get_calendar' => 2, 'datefmt_get_datetype' => 2, 'datefmt_get_error_code' => 2, 'datefmt_get_error_message' => 2, 'datefmt_get_locale' => 2, 'datefmt_get_pattern' => 2, 'datefmt_get_timetype' => 2,
'datefmt_get_timezone_id' => 2, 'datefmt_is_lenient' => 2, 'datefmt_localtime' => 2, 'datefmt_parse' => 2, 'datefmt_set_calendar' => 2, 'datefmt_set_lenient' => 2, 'datefmt_set_pattern' => 2, 'datefmt_set_timezone_id' => 2, 'db_id_list' => 2, 'dba_close' => 2, 'dba_delete' => 2, 'dba_exists' => 2, 'dba_fetch' => 2, 'dba_firstkey' => 2, 'dba_handlers' => 2, 'dba_insert' => 2, 'dba_key_split' => 2, 'dba_list' => 2, 'dba_nextkey' => 2, 'dba_open' => 2, 'dba_optimize' => 2, 'dba_popen' => 2, 'dba_replace' => 2, 'dba_sync' => 2, 'dbase_add_record' => 2, 'dbase_close' => 2,
'dbase_create' => 2, 'dbase_delete_record' => 2, 'dbase_get_header_info' => 2, 'dbase_get_record' => 2, 'dbase_get_record_with_names' => 2, 'dbase_numfields' => 2, 'dbase_numrecords' => 2, 'dbase_open' => 2, 'dbase_pack' => 2, 'dbase_replace_record' => 2, 'dbg_get_all_contexts' => 2, 'dbg_get_all_module_names' => 2, 'dbg_get_all_source_lines' => 2, 'dbg_get_context_name' => 2, 'dbg_get_loaded_zendextensions' => 2, 'dbg_get_module_name' => 2, 'dbg_get_profiler_results' => 2, 'dbg_get_source_context' => 2, 'dblist' => 2, 'dbmclose' => 2, 'dbmdelete' => 2, 'dbmexists' => 2, 'dbmfetch' => 2, 'dbmfirstkey' => 2, 'dbminsert' => 2, 'dbmnextkey' => 2,
'dbmopen' => 2, 'dbmreplace' => 2, 'dbx_close' => 2, 'dbx_compare' => 2, 'dbx_connect' => 2, 'dbx_error' => 2, 'dbx_escape_string' => 2, 'dbx_fetch_row' => 2, 'dbx_query' => 2, 'dbx_sort' => 2, 'dcgettext' => 2, 'dcngettext' => 2, 'deaggregate' => 2, 'debug_backtrace' => 2, 'debug_print_backtrace' => 2, 'debug_zval_dump' => 2, 'debugbreak' => 2, 'debugger_off' => 2, 'debugger_on' => 2, 'decbin' => 2, 'dechex' => 2, 'decoct' => 2, 'define' => 2, 'define_syslog_variables' => 2, 'defined' => 2, 'deg2rad' => 2,
'delete' => 2, 'dgettext' => 2, 'dio_close' => 2, 'dio_open' => 2, 'dio_read' => 2, 'dio_seek' => 2, 'dio_stat' => 2, 'dio_write' => 2, 'dir' => 2, 'dirname' => 2, 'disk_free_space' => 2, 'disk_total_space' => 2, 'diskfreespace' => 2, 'dl' => 2, 'dngettext' => 2, 'dns_check_record' => 2, 'dns_get_mx' => 2, 'dns_get_record' => 2, 'docblock_token_name' => 2, 'docblock_tokenize' => 2, 'dom_import_simplexml' => 2, 'domxml_add_root' => 2, 'domxml_attributes' => 2, 'domxml_children' => 2, 'domxml_doc_add_root' => 2, 'domxml_doc_document_element' => 2,
'domxml_doc_get_element_by_id' => 2, 'domxml_doc_get_elements_by_tagname' => 2, 'domxml_doc_get_root' => 2, 'domxml_doc_set_root' => 2, 'domxml_doc_validate' => 2, 'domxml_doc_xinclude' => 2, 'domxml_dump_mem' => 2, 'domxml_dump_mem_file' => 2, 'domxml_dump_node' => 2, 'domxml_dumpmem' => 2, 'domxml_elem_get_attribute' => 2, 'domxml_elem_set_attribute' => 2, 'domxml_get_attribute' => 2, 'domxml_getattr' => 2, 'domxml_html_dump_mem' => 2, 'domxml_new_child' => 2, 'domxml_new_doc' => 2, 'domxml_new_xmldoc' => 2, 'domxml_node' => 2, 'domxml_node_add_namespace' => 2, 'domxml_node_attributes' => 2, 'domxml_node_children' => 2, 'domxml_node_get_content' => 2, 'domxml_node_has_attributes' => 2, 'domxml_node_new_child' => 2, 'domxml_node_set_content' => 2,
'domxml_node_set_namespace' => 2, 'domxml_node_unlink_node' => 2, 'domxml_open_file' => 2, 'domxml_open_mem' => 2, 'domxml_parser' => 2, 'domxml_parser_add_chunk' => 2, 'domxml_parser_cdata_section' => 2, 'domxml_parser_characters' => 2, 'domxml_parser_comment' => 2, 'domxml_parser_end' => 2, 'domxml_parser_end_document' => 2, 'domxml_parser_end_element' => 2, 'domxml_parser_entity_reference' => 2, 'domxml_parser_get_document' => 2, 'domxml_parser_namespace_decl' => 2, 'domxml_parser_processing_instruction' => 2, 'domxml_parser_start_document' => 2, 'domxml_parser_start_element' => 2, 'domxml_root' => 2, 'domxml_set_attribute' => 2, 'domxml_setattr' => 2, 'domxml_substitute_entities_default' => 2, 'domxml_unlink_node' => 2, 'domxml_version' => 2, 'domxml_xmltree' => 2, 'doubleval' => 2,
'each' => 2, 'easter_date' => 2, 'easter_days' => 2, 'end' => 2, 'ereg' => 2, 'ereg_replace' => 2, 'eregi' => 2, 'eregi_replace' => 2, 'error_get_last' => 2, 'error_log' => 2, 'error_reporting' => 2, 'escapeshellarg' => 2, 'escapeshellcmd' => 2, 'event_deschedule' => 2, 'event_dispatch' => 2, 'event_free' => 2, 'event_handle_signal' => 2, 'event_have_events' => 2, 'event_init' => 2, 'event_new' => 2, 'event_pending' => 2, 'event_priority_set' => 2, 'event_schedule' => 2, 'event_set' => 2, 'event_timeout' => 2, 'exec' => 2,
'exif_imagetype' => 2, 'exif_read_data' => 2, 'exif_tagname' => 2, 'exif_thumbnail' => 2, 'exp' => 2, 'explode' => 2, 'expm1' => 2, 'extension_loaded' => 2, 'extract' => 2, 'ezmlm_hash' => 2, 'fbird_add_user' => 2, 'fbird_affected_rows' => 2, 'fbird_backup' => 2, 'fbird_blob_add' => 2, 'fbird_blob_cancel' => 2, 'fbird_blob_close' => 2, 'fbird_blob_create' => 2, 'fbird_blob_echo' => 2, 'fbird_blob_get' => 2, 'fbird_blob_import' => 2, 'fbird_blob_info' => 2, 'fbird_blob_open' => 2, 'fbird_close' => 2, 'fbird_commit' => 2, 'fbird_commit_ret' => 2, 'fbird_connect' => 2,
'fbird_db_info' => 2, 'fbird_delete_user' => 2, 'fbird_drop_db' => 2, 'fbird_errcode' => 2, 'fbird_errmsg' => 2, 'fbird_execute' => 2, 'fbird_fetch_assoc' => 2, 'fbird_fetch_object' => 2, 'fbird_fetch_row' => 2, 'fbird_field_info' => 2, 'fbird_free_event_handler' => 2, 'fbird_free_query' => 2, 'fbird_free_result' => 2, 'fbird_gen_id' => 2, 'fbird_maintain_db' => 2, 'fbird_modify_user' => 2, 'fbird_name_result' => 2, 'fbird_num_fields' => 2, 'fbird_num_params' => 2, 'fbird_param_info' => 2, 'fbird_pconnect' => 2, 'fbird_prepare' => 2, 'fbird_query' => 2, 'fbird_restore' => 2, 'fbird_rollback' => 2, 'fbird_rollback_ret' => 2,
'fbird_server_info' => 2, 'fbird_service_attach' => 2, 'fbird_service_detach' => 2, 'fbird_set_event_handler' => 2, 'fbird_trans' => 2, 'fbird_wait_event' => 2, 'fclose' => 2, 'fdf_add_doc_javascript' => 2, 'fdf_add_template' => 2, 'fdf_close' => 2, 'fdf_create' => 2, 'fdf_enum_values' => 2, 'fdf_errno' => 2, 'fdf_error' => 2, 'fdf_get_ap' => 2, 'fdf_get_attachment' => 2, 'fdf_get_encoding' => 2, 'fdf_get_file' => 2, 'fdf_get_flags' => 2, 'fdf_get_opt' => 2, 'fdf_get_status' => 2, 'fdf_get_value' => 2, 'fdf_get_version' => 2, 'fdf_header' => 2, 'fdf_next_field_name' => 2, 'fdf_open' => 2,
'fdf_open_string' => 2, 'fdf_remove_item' => 2, 'fdf_save' => 2, 'fdf_save_string' => 2, 'fdf_set_ap' => 2, 'fdf_set_encoding' => 2, 'fdf_set_file' => 2, 'fdf_set_flags' => 2, 'fdf_set_javascript_action' => 2, 'fdf_set_on_import_javascript' => 2, 'fdf_set_opt' => 2, 'fdf_set_status' => 2, 'fdf_set_submit_form_action' => 2, 'fdf_set_target_frame' => 2, 'fdf_set_value' => 2, 'fdf_set_version' => 2, 'feof' => 2, 'fflush' => 2, 'fgetc' => 2, 'fgetcsv' => 2, 'fgets' => 2, 'fgetss' => 2, 'file' => 2, 'file_exists' => 2, 'file_get_contents' => 2, 'file_put_contents' => 2,
'fileatime' => 2, 'filectime' => 2, 'filegroup' => 2, 'fileinode' => 2, 'filemtime' => 2, 'fileowner' => 2, 'fileperms' => 2, 'filepro' => 2, 'filepro_fieldcount' => 2, 'filepro_fieldname' => 2, 'filepro_fieldtype' => 2, 'filepro_fieldwidth' => 2, 'filepro_retrieve' => 2, 'filepro_rowcount' => 2, 'filesize' => 2, 'filetype' => 2, 'filter_has_var' => 2, 'filter_id' => 2, 'filter_input' => 2, 'filter_input_array' => 2, 'filter_list' => 2, 'filter_var' => 2, 'filter_var_array' => 2, 'finfo_buffer' => 2, 'finfo_close' => 2, 'finfo_file' => 2,
'finfo_open' => 2, 'finfo_set_flags' => 2, 'floatval' => 2, 'flock' => 2, 'floor' => 2, 'flush' => 2, 'fmod' => 2, 'fnmatch' => 2, 'fopen' => 2, 'forward_static_call' => 2, 'forward_static_call_array' => 2, 'fpassthru' => 2, 'fprintf' => 2, 'fputcsv' => 2, 'fputs' => 2, 'fread' => 2, 'frenchtojd' => 2, 'fribidi_charset_info' => 2, 'fribidi_get_charsets' => 2, 'fribidi_log2vis' => 2, 'fscanf' => 2, 'fseek' => 2, 'fsockopen' => 2, 'fstat' => 2, 'ftell' => 2, 'ftok' => 2,
'ftp_alloc' => 2, 'ftp_cdup' => 2, 'ftp_chdir' => 2, 'ftp_chmod' => 2, 'ftp_close' => 2, 'ftp_connect' => 2, 'ftp_delete' => 2, 'ftp_exec' => 2, 'ftp_fget' => 2, 'ftp_fput' => 2, 'ftp_get' => 2, 'ftp_get_option' => 2, 'ftp_login' => 2, 'ftp_mdtm' => 2, 'ftp_mkdir' => 2, 'ftp_nb_continue' => 2, 'ftp_nb_fget' => 2, 'ftp_nb_fput' => 2, 'ftp_nb_get' => 2, 'ftp_nb_put' => 2, 'ftp_nlist' => 2, 'ftp_pasv' => 2, 'ftp_put' => 2, 'ftp_pwd' => 2, 'ftp_quit' => 2, 'ftp_raw' => 2,
'ftp_rawlist' => 2, 'ftp_rename' => 2, 'ftp_rmdir' => 2, 'ftp_set_option' => 2, 'ftp_site' => 2, 'ftp_size' => 2, 'ftp_ssl_connect' => 2, 'ftp_systype' => 2, 'ftruncate' => 2, 'func_get_arg' => 2, 'func_get_args' => 2, 'func_num_args' => 2, 'function_exists' => 2, 'fwrite' => 2, 'gc_collect_cycles' => 2, 'gc_disable' => 2, 'gc_enable' => 2, 'gc_enabled' => 2, 'gd_info' => 2, 'get_browser' => 2, 'get_called_class' => 2, 'get_cfg_var' => 2, 'get_class' => 2, 'get_class_methods' => 2, 'get_class_vars' => 2, 'get_current_user' => 2,
'get_declared_classes' => 2, 'get_declared_interfaces' => 2, 'get_declared_traits' => 2, 'get_defined_constants' => 2, 'get_defined_functions' => 2, 'get_defined_vars' => 2, 'get_extension_funcs' => 2, 'get_headers' => 2, 'get_html_translation_table' => 2, 'get_include_path' => 2, 'get_included_files' => 2, 'get_loaded_extensions' => 2, 'get_magic_quotes_gpc' => 2, 'get_magic_quotes_runtime' => 2, 'get_meta_tags' => 2, 'get_object_vars' => 2, 'get_parent_class' => 2, 'get_required_files' => 2, 'get_resource_type' => 2, 'getallheaders' => 2, 'getcwd' => 2, 'getdate' => 2, 'getenv' => 2, 'gethostbyaddr' => 2, 'gethostbyname' => 2, 'gethostbynamel' => 2,
'gethostname' => 2, 'getimagesize' => 2, 'getimagesizefromstring' => 2, 'getlastmod' => 2, 'getmxrr' => 2, 'getmygid' => 2, 'getmyinode' => 2, 'getmypid' => 2, 'getmyuid' => 2, 'getopt' => 2, 'getprotobyname' => 2, 'getprotobynumber' => 2, 'getrandmax' => 2, 'getrusage' => 2, 'getservbyname' => 2, 'getservbyport' => 2, 'gettext' => 2, 'gettimeofday' => 2, 'gettype' => 2, 'glob' => 2, 'gmdate' => 2, 'gmmktime' => 2, 'gmp_abs' => 2, 'gmp_add' => 2, 'gmp_and' => 2, 'gmp_clrbit' => 2,
'gmp_cmp' => 2, 'gmp_com' => 2, 'gmp_div' => 2, 'gmp_div_q' => 2, 'gmp_div_qr' => 2, 'gmp_div_r' => 2, 'gmp_divexact' => 2, 'gmp_fact' => 2, 'gmp_gcd' => 2, 'gmp_gcdext' => 2, 'gmp_hamdist' => 2, 'gmp_init' => 2, 'gmp_intval' => 2, 'gmp_invert' => 2, 'gmp_jacobi' => 2, 'gmp_legendre' => 2, 'gmp_mod' => 2, 'gmp_mul' => 2, 'gmp_neg' => 2, 'gmp_nextprime' => 2, 'gmp_or' => 2, 'gmp_perfect_square' => 2, 'gmp_popcount' => 2, 'gmp_pow' => 2, 'gmp_powm' => 2, 'gmp_prob_prime' => 2,
'gmp_random' => 2, 'gmp_scan0' => 2, 'gmp_scan1' => 2, 'gmp_setbit' => 2, 'gmp_sign' => 2, 'gmp_sqrt' => 2, 'gmp_sqrtrem' => 2, 'gmp_strval' => 2, 'gmp_sub' => 2, 'gmp_xor' => 2, 'gmstrftime' => 2, 'gopher_parsedir' => 2, 'grapheme_extract' => 2, 'grapheme_stripos' => 2, 'grapheme_stristr' => 2, 'grapheme_strlen' => 2, 'grapheme_strpos' => 2, 'grapheme_strripos' => 2, 'grapheme_strrpos' => 2, 'grapheme_strstr' => 2, 'grapheme_substr' => 2, 'gregoriantojd' => 2, 'gzclose' => 2, 'gzcompress' => 2, 'gzdecode' => 2, 'gzdeflate' => 2,
'gzencode' => 2, 'gzeof' => 2, 'gzfile' => 2, 'gzgetc' => 2, 'gzgets' => 2, 'gzgetss' => 2, 'gzinflate' => 2, 'gzopen' => 2, 'gzpassthru' => 2, 'gzputs' => 2, 'gzread' => 2, 'gzrewind' => 2, 'gzseek' => 2, 'gztell' => 2, 'gzuncompress' => 2, 'gzwrite' => 2, 'hash' => 2, 'hash_algos' => 2, 'hash_copy' => 2, 'hash_file' => 2, 'hash_final' => 2, 'hash_hmac' => 2, 'hash_hmac_file' => 2, 'hash_init' => 2, 'hash_update' => 2, 'hash_update_file' => 2,
'hash_update_stream' => 2, 'header' => 2, 'header_register_callback' => 2, 'header_remove' => 2, 'headers_list' => 2, 'headers_sent' => 2, 'hebrev' => 2, 'hebrevc' => 2, 'hex2bin' => 2, 'hexdec' => 2, 'highlight_file' => 2, 'highlight_string' => 2, 'html_doc' => 2, 'html_doc_file' => 2, 'html_entity_decode' => 2, 'htmlentities' => 2, 'htmlspecialchars' => 2, 'htmlspecialchars_decode' => 2, 'http_build_cookie' => 2, 'http_build_query' => 2, 'http_build_str' => 2, 'http_build_url' => 2, 'http_cache_etag' => 2, 'http_cache_last_modified' => 2, 'http_chunked_decode' => 2, 'http_date' => 2,
'http_deflate' => 2, 'http_get' => 2, 'http_get_request_body' => 2, 'http_get_request_body_stream' => 2, 'http_get_request_headers' => 2, 'http_head' => 2, 'http_inflate' => 2, 'http_match_etag' => 2, 'http_match_modified' => 2, 'http_match_request_header' => 2, 'http_negotiate' => 2, 'http_negotiate_charset' => 2, 'http_negotiate_content_type' => 2, 'http_negotiate_language' => 2, 'http_parse_cookie' => 2, 'http_parse_headers' => 2, 'http_parse_message' => 2, 'http_parse_params' => 2, 'http_persistent_handles_clean' => 2, 'http_persistent_handles_count' => 2, 'http_persistent_handles_ident' => 2, 'http_post_data' => 2, 'http_post_fields' => 2, 'http_put_data' => 2, 'http_put_file' => 2, 'http_put_stream' => 2,
'http_redirect' => 2, 'http_request' => 2, 'http_request_body_encode' => 2, 'http_request_method_exists' => 2, 'http_request_method_name' => 2, 'http_request_method_register' => 2, 'http_request_method_unregister' => 2, 'http_response_code' => 2, 'http_send_content_disposition' => 2, 'http_send_content_type' => 2, 'http_send_data' => 2, 'http_send_file' => 2, 'http_send_last_modified' => 2, 'http_send_status' => 2, 'http_send_stream' => 2, 'http_support' => 2, 'http_throttle' => 2, 'hw_array2objrec' => 2, 'hw_children' => 2, 'hw_childrenobj' => 2, 'hw_close' => 2, 'hw_connect' => 2, 'hw_cp' => 2, 'hw_deleteobject' => 2, 'hw_docbyanchor' => 2, 'hw_docbyanchorobj' => 2,
'hw_documentattributes' => 2, 'hw_documentbodytag' => 2, 'hw_documentcontent' => 2, 'hw_documentsetcontent' => 2, 'hw_documentsize' => 2, 'hw_edittext' => 2, 'hw_error' => 2, 'hw_errormsg' => 2, 'hw_free_document' => 2, 'hw_getanchors' => 2, 'hw_getanchorsobj' => 2, 'hw_getandlock' => 2, 'hw_getchildcoll' => 2, 'hw_getchildcollobj' => 2, 'hw_getchilddoccoll' => 2, 'hw_getchilddoccollobj' => 2, 'hw_getobject' => 2, 'hw_getobjectbyquery' => 2, 'hw_getobjectbyquerycoll' => 2, 'hw_getobjectbyquerycollobj' => 2, 'hw_getobjectbyqueryobj' => 2, 'hw_getparents' => 2, 'hw_getparentsobj' => 2, 'hw_getremote' => 2, 'hw_getremotechildren' => 2, 'hw_getsrcbydestobj' => 2,
'hw_gettext' => 2, 'hw_identify' => 2, 'hw_incollections' => 2, 'hw_info' => 2, 'hw_inscoll' => 2, 'hw_insdoc' => 2, 'hw_insertdocument' => 2, 'hw_insertobject' => 2, 'hw_mapid' => 2, 'hw_modifyobject' => 2, 'hw_mv' => 2, 'hw_new_document' => 2, 'hw_objrec2array' => 2, 'hw_outputdocument' => 2, 'hw_pconnect' => 2, 'hw_pipedocument' => 2, 'hw_root' => 2, 'hw_unlock' => 2, 'hw_username' => 2, 'hw_who' => 2, 'hypot' => 2, 'i18n_convert' => 2, 'i18n_discover_encoding' => 2, 'i18n_http_input' => 2, 'i18n_http_output' => 2, 'i18n_internal_encoding' => 2,
'i18n_ja_jp_hantozen' => 2, 'i18n_mime_header_decode' => 2, 'i18n_mime_header_encode' => 2, 'ibase_add_user' => 2, 'ibase_affected_rows' => 2, 'ibase_backup' => 2, 'ibase_bind' => 2, 'ibase_blob_add' => 2, 'ibase_blob_cancel' => 2, 'ibase_blob_close' => 2, 'ibase_blob_create' => 2, 'ibase_blob_echo' => 2, 'ibase_blob_get' => 2, 'ibase_blob_import' => 2, 'ibase_blob_info' => 2, 'ibase_blob_open' => 2, 'ibase_close' => 2, 'ibase_commit' => 2, 'ibase_commit_ret' => 2, 'ibase_connect' => 2, 'ibase_db_info' => 2, 'ibase_delete_user' => 2, 'ibase_drop_db' => 2, 'ibase_errcode' => 2, 'ibase_errmsg' => 2, 'ibase_execute' => 2,
'ibase_fetch_assoc' => 2, 'ibase_fetch_object' => 2, 'ibase_fetch_row' => 2, 'ibase_field_info' => 2, 'ibase_free_event_handler' => 2, 'ibase_free_query' => 2, 'ibase_free_result' => 2, 'ibase_gen_id' => 2, 'ibase_maintain_db' => 2, 'ibase_modify_user' => 2, 'ibase_name_result' => 2, 'ibase_num_fields' => 2, 'ibase_num_params' => 2, 'ibase_param_info' => 2, 'ibase_pconnect' => 2, 'ibase_prepare' => 2, 'ibase_query' => 2, 'ibase_restore' => 2, 'ibase_rollback' => 2, 'ibase_rollback_ret' => 2, 'ibase_server_info' => 2, 'ibase_service_attach' => 2, 'ibase_service_detach' => 2, 'ibase_set_event_handler' => 2, 'ibase_timefmt' => 2, 'ibase_trans' => 2,
'ibase_wait_event' => 2, 'iconv' => 2, 'iconv_get_encoding' => 2, 'iconv_mime_decode' => 2, 'iconv_mime_decode_headers' => 2, 'iconv_mime_encode' => 2, 'iconv_set_encoding' => 2, 'iconv_strlen' => 2, 'iconv_strpos' => 2, 'iconv_strrpos' => 2, 'iconv_substr' => 2, 'id3_get_frame_long_name' => 2, 'id3_get_frame_short_name' => 2, 'id3_get_genre_id' => 2, 'id3_get_genre_list' => 2, 'id3_get_genre_name' => 2, 'id3_get_tag' => 2, 'id3_get_version' => 2, 'id3_remove_tag' => 2, 'id3_set_tag' => 2, 'idate' => 2, 'idn_to_ascii' => 2, 'idn_to_utf8' => 2, 'ifx_affected_rows' => 2, 'ifx_blobinfile_mode' => 2, 'ifx_byteasvarchar' => 2,
'ifx_close' => 2, 'ifx_connect' => 2, 'ifx_copy_blob' => 2, 'ifx_create_blob' => 2, 'ifx_create_char' => 2, 'ifx_do' => 2, 'ifx_error' => 2, 'ifx_errormsg' => 2, 'ifx_fetch_row' => 2, 'ifx_fieldproperties' => 2, 'ifx_fieldtypes' => 2, 'ifx_free_blob' => 2, 'ifx_free_char' => 2, 'ifx_free_result' => 2, 'ifx_free_slob' => 2, 'ifx_get_blob' => 2, 'ifx_get_char' => 2, 'ifx_getsqlca' => 2, 'ifx_htmltbl_result' => 2, 'ifx_nullformat' => 2, 'ifx_num_fields' => 2, 'ifx_num_rows' => 2, 'ifx_pconnect' => 2, 'ifx_prepare' => 2, 'ifx_query' => 2, 'ifx_textasvarchar' => 2,
'ifx_update_blob' => 2, 'ifx_update_char' => 2, 'ifxus_close_slob' => 2, 'ifxus_create_slob' => 2, 'ifxus_open_slob' => 2, 'ifxus_read_slob' => 2, 'ifxus_seek_slob' => 2, 'ifxus_tell_slob' => 2, 'ifxus_write_slob' => 2, 'ignore_user_abort' => 2, 'image2wbmp' => 2, 'image_type_to_extension' => 2, 'image_type_to_mime_type' => 2, 'imagealphablending' => 2, 'imageantialias' => 2, 'imagearc' => 2, 'imagechar' => 2, 'imagecharup' => 2, 'imagecolorallocate' => 2, 'imagecolorallocatealpha' => 2, 'imagecolorat' => 2, 'imagecolorclosest' => 2, 'imagecolorclosestalpha' => 2, 'imagecolorclosesthwb' => 2, 'imagecolordeallocate' => 2, 'imagecolorexact' => 2,
'imagecolorexactalpha' => 2, 'imagecolormatch' => 2, 'imagecolorresolve' => 2, 'imagecolorresolvealpha' => 2, 'imagecolorset' => 2, 'imagecolorsforindex' => 2, 'imagecolorstotal' => 2, 'imagecolortransparent' => 2, 'imageconvolution' => 2, 'imagecopy' => 2, 'imagecopymerge' => 2, 'imagecopymergegray' => 2, 'imagecopyresampled' => 2, 'imagecopyresized' => 2, 'imagecreate' => 2, 'imagecreatefromgd' => 2, 'imagecreatefromgd2' => 2, 'imagecreatefromgd2part' => 2, 'imagecreatefromgif' => 2, 'imagecreatefromjpeg' => 2, 'imagecreatefrompng' => 2, 'imagecreatefromstring' => 2, 'imagecreatefromwbmp' => 2, 'imagecreatefromxbm' => 2, 'imagecreatetruecolor' => 2, 'imagedashedline' => 2,
'imagedestroy' => 2, 'imageellipse' => 2, 'imagefill' => 2, 'imagefilledarc' => 2, 'imagefilledellipse' => 2, 'imagefilledpolygon' => 2, 'imagefilledrectangle' => 2, 'imagefilltoborder' => 2, 'imagefilter' => 2, 'imagefontheight' => 2, 'imagefontwidth' => 2, 'imageftbbox' => 2, 'imagefttext' => 2, 'imagegammacorrect' => 2, 'imagegd' => 2, 'imagegd2' => 2, 'imagegif' => 2, 'imagegrabscreen' => 2, 'imagegrabwindow' => 2, 'imageinterlace' => 2, 'imageistruecolor' => 2, 'imagejpeg' => 2, 'imagelayereffect' => 2, 'imageline' => 2, 'imageloadfont' => 2, 'imagepalettecopy' => 2,
'imagepng' => 2, 'imagepolygon' => 2, 'imagepsbbox' => 2, 'imagepsencodefont' => 2, 'imagepsextendfont' => 2, 'imagepsfreefont' => 2, 'imagepsloadfont' => 2, 'imagepsslantfont' => 2, 'imagepstext' => 2, 'imagerectangle' => 2, 'imagerotate' => 2, 'imagesavealpha' => 2, 'imagesetbrush' => 2, 'imagesetpixel' => 2, 'imagesetstyle' => 2, 'imagesetthickness' => 2, 'imagesettile' => 2, 'imagestring' => 2, 'imagestringup' => 2, 'imagesx' => 2, 'imagesy' => 2, 'imagetruecolortopalette' => 2, 'imagettfbbox' => 2, 'imagettftext' => 2, 'imagetypes' => 2, 'imagewbmp' => 2,
'imagexbm' => 2, 'imap_8bit' => 2, 'imap_alerts' => 2, 'imap_append' => 2, 'imap_base64' => 2, 'imap_binary' => 2, 'imap_body' => 2, 'imap_bodystruct' => 2, 'imap_check' => 2, 'imap_clearflag_full' => 2, 'imap_close' => 2, 'imap_create' => 2, 'imap_createmailbox' => 2, 'imap_delete' => 2, 'imap_deletemailbox' => 2, 'imap_errors' => 2, 'imap_expunge' => 2, 'imap_fetch_overview' => 2, 'imap_fetchbody' => 2, 'imap_fetchheader' => 2, 'imap_fetchmime' => 2, 'imap_fetchstructure' => 2, 'imap_fetchtext' => 2, 'imap_gc' => 2, 'imap_get_quota' => 2, 'imap_get_quotaroot' => 2,
'imap_getacl' => 2, 'imap_getmailboxes' => 2, 'imap_getsubscribed' => 2, 'imap_header' => 2, 'imap_headerinfo' => 2, 'imap_headers' => 2, 'imap_last_error' => 2, 'imap_list' => 2, 'imap_listmailbox' => 2, 'imap_listscan' => 2, 'imap_listsubscribed' => 2, 'imap_lsub' => 2, 'imap_mail' => 2, 'imap_mail_compose' => 2, 'imap_mail_copy' => 2, 'imap_mail_move' => 2, 'imap_mailboxmsginfo' => 2, 'imap_mime_header_decode' => 2, 'imap_msgno' => 2, 'imap_mutf7_to_utf8' => 2, 'imap_num_msg' => 2, 'imap_num_recent' => 2, 'imap_open' => 2, 'imap_ping' => 2, 'imap_qprint' => 2, 'imap_rename' => 2,
'imap_renamemailbox' => 2, 'imap_reopen' => 2, 'imap_rfc822_parse_adrlist' => 2, 'imap_rfc822_parse_headers' => 2, 'imap_rfc822_write_address' => 2, 'imap_savebody' => 2, 'imap_scan' => 2, 'imap_scanmailbox' => 2, 'imap_search' => 2, 'imap_set_quota' => 2, 'imap_setacl' => 2, 'imap_setflag_full' => 2, 'imap_sort' => 2, 'imap_status' => 2, 'imap_subscribe' => 2, 'imap_thread' => 2, 'imap_timeout' => 2, 'imap_uid' => 2, 'imap_undelete' => 2, 'imap_unsubscribe' => 2, 'imap_utf7_decode' => 2, 'imap_utf7_encode' => 2, 'imap_utf8' => 2, 'imap_utf8_to_mutf7' => 2, 'implode' => 2, 'import_request_variables' => 2,
'in_array' => 2, 'inet_ntop' => 2, 'inet_pton' => 2, 'ini_alter' => 2, 'ini_get' => 2, 'ini_get_all' => 2, 'ini_restore' => 2, 'ini_set' => 2, 'interface_exists' => 2, 'intl_error_name' => 2, 'intl_get_error_code' => 2, 'intl_get_error_message' => 2, 'intl_is_failure' => 2, 'intval' => 2, 'ip2long' => 2, 'iptcembed' => 2, 'iptcparse' => 2, 'is_a' => 2, 'is_array' => 2, 'is_bool' => 2, 'is_callable' => 2, 'is_dir' => 2, 'is_double' => 2, 'is_executable' => 2, 'is_file' => 2, 'is_finite' => 2,
'is_float' => 2, 'is_infinite' => 2, 'is_int' => 2, 'is_integer' => 2, 'is_link' => 2, 'is_long' => 2, 'is_nan' => 2, 'is_null' => 2, 'is_numeric' => 2, 'is_object' => 2, 'is_readable' => 2, 'is_real' => 2, 'is_resource' => 2, 'is_scalar' => 2, 'is_soap_fault' => 2, 'is_string' => 2, 'is_subclass_of' => 2, 'is_uploaded_file' => 2, 'is_writable' => 2, 'is_writeable' => 2, 'iterator_apply' => 2, 'iterator_count' => 2, 'iterator_to_array' => 2, 'java_last_exception_clear' => 2, 'java_last_exception_get' => 2, 'jddayofweek' => 2,
'jdmonthname' => 2, 'jdtofrench' => 2, 'jdtogregorian' => 2, 'jdtojewish' => 2, 'jdtojulian' => 2, 'jdtounix' => 2, 'jewishtojd' => 2, 'join' => 2, 'jpeg2wbmp' => 2, 'json_decode' => 2, 'json_encode' => 2, 'json_last_error' => 2, 'juliantojd' => 2, 'key' => 2, 'key_exists' => 2, 'krsort' => 2, 'ksort' => 2, 'lcfirst' => 2, 'lcg_value' => 2, 'ldap_add' => 2, 'ldap_bind' => 2, 'ldap_close' => 2, 'ldap_compare' => 2, 'ldap_connect' => 2, 'ldap_count_entries' => 2, 'ldap_delete' => 2,
'ldap_dn2ufn' => 2, 'ldap_err2str' => 2, 'ldap_errno' => 2, 'ldap_error' => 2, 'ldap_explode_dn' => 2, 'ldap_first_attribute' => 2, 'ldap_first_entry' => 2, 'ldap_first_reference' => 2, 'ldap_free_result' => 2, 'ldap_get_attributes' => 2, 'ldap_get_dn' => 2, 'ldap_get_entries' => 2, 'ldap_get_option' => 2, 'ldap_get_values' => 2, 'ldap_get_values_len' => 2, 'ldap_list' => 2, 'ldap_mod_add' => 2, 'ldap_mod_del' => 2, 'ldap_mod_replace' => 2, 'ldap_modify' => 2, 'ldap_next_attribute' => 2, 'ldap_next_entry' => 2, 'ldap_next_reference' => 2, 'ldap_parse_reference' => 2, 'ldap_parse_result' => 2, 'ldap_read' => 2,
'ldap_rename' => 2, 'ldap_search' => 2, 'ldap_set_option' => 2, 'ldap_sort' => 2, 'ldap_start_tls' => 2, 'ldap_unbind' => 2, 'leak' => 2, 'levenshtein' => 2, 'libxml_clear_errors' => 2, 'libxml_disable_entity_loader' => 2, 'libxml_get_errors' => 2, 'libxml_get_last_error' => 2, 'libxml_set_streams_context' => 2, 'libxml_use_internal_errors' => 2, 'link' => 2, 'linkinfo' => 2, 'locale_accept_from_http' => 2, 'locale_canonicalize' => 2, 'locale_compose' => 2, 'locale_filter_matches' => 2, 'locale_get_all_variants' => 2, 'locale_get_default' => 2, 'locale_get_display_language' => 2, 'locale_get_display_name' => 2, 'locale_get_display_region' => 2, 'locale_get_display_script' => 2,
'locale_get_display_variant' => 2, 'locale_get_keywords' => 2, 'locale_get_primary_language' => 2, 'locale_get_region' => 2, 'locale_get_script' => 2, 'locale_lookup' => 2, 'locale_parse' => 2, 'locale_set_default' => 2, 'localeconv' => 2, 'localtime' => 2, 'log' => 2, 'log10' => 2, 'log1p' => 2, 'long2ip' => 2, 'lstat' => 2, 'ltrim' => 2, 'lzf_compress' => 2, 'lzf_decompress' => 2, 'lzf_optimized_for' => 2, 'magic_quotes_runtime' => 2, 'mail' => 2, 'max' => 2, 'mb_check_encoding' => 2, 'mb_convert_case' => 2, 'mb_convert_encoding' => 2, 'mb_convert_kana' => 2,
'mb_convert_variables' => 2, 'mb_decode_mimeheader' => 2, 'mb_decode_numericentity' => 2, 'mb_detect_encoding' => 2, 'mb_detect_order' => 2, 'mb_encode_mimeheader' => 2, 'mb_encode_numericentity' => 2, 'mb_encoding_aliases' => 2, 'mb_ereg' => 2, 'mb_ereg_match' => 2, 'mb_ereg_replace' => 2, 'mb_ereg_search' => 2, 'mb_ereg_search_getpos' => 2, 'mb_ereg_search_getregs' => 2, 'mb_ereg_search_init' => 2, 'mb_ereg_search_pos' => 2, 'mb_ereg_search_regs' => 2, 'mb_ereg_search_setpos' => 2, 'mb_eregi' => 2, 'mb_eregi_replace' => 2, 'mb_get_info' => 2, 'mb_http_input' => 2, 'mb_http_output' => 2, 'mb_internal_encoding' => 2, 'mb_language' => 2, 'mb_list_encodings' => 2,
'mb_output_handler' => 2, 'mb_parse_str' => 2, 'mb_preferred_mime_name' => 2, 'mb_regex_encoding' => 2, 'mb_regex_set_options' => 2, 'mb_send_mail' => 2, 'mb_split' => 2, 'mb_strcut' => 2, 'mb_strimwidth' => 2, 'mb_stripos' => 2, 'mb_stristr' => 2, 'mb_strlen' => 2, 'mb_strpos' => 2, 'mb_strrchr' => 2, 'mb_strrichr' => 2, 'mb_strripos' => 2, 'mb_strrpos' => 2, 'mb_strstr' => 2, 'mb_strtolower' => 2, 'mb_strtoupper' => 2, 'mb_strwidth' => 2, 'mb_substitute_character' => 2, 'mb_substr' => 2, 'mb_substr_count' => 2, 'mbereg' => 2, 'mbereg_match' => 2,
'mbereg_replace' => 2, 'mbereg_search' => 2, 'mbereg_search_getpos' => 2, 'mbereg_search_getregs' => 2, 'mbereg_search_init' => 2, 'mbereg_search_pos' => 2, 'mbereg_search_regs' => 2, 'mbereg_search_setpos' => 2, 'mberegi' => 2, 'mberegi_replace' => 2, 'mbregex_encoding' => 2, 'mbsplit' => 2, 'mbstrcut' => 2, 'mbstrlen' => 2, 'mbstrpos' => 2, 'mbstrrpos' => 2, 'mbsubstr' => 2, 'mcal_close' => 2, 'mcal_date_compare' => 2, 'mcal_date_valid' => 2, 'mcal_day_of_week' => 2, 'mcal_day_of_year' => 2, 'mcal_days_in_month' => 2, 'mcal_delete_event' => 2, 'mcal_event_init' => 2, 'mcal_event_set_alarm' => 2,
'mcal_event_set_category' => 2, 'mcal_event_set_class' => 2, 'mcal_event_set_description' => 2, 'mcal_event_set_end' => 2, 'mcal_event_set_recur_daily' => 2, 'mcal_event_set_recur_monthly_mday' => 2, 'mcal_event_set_recur_monthly_wday' => 2, 'mcal_event_set_recur_weekly' => 2, 'mcal_event_set_recur_yearly' => 2, 'mcal_event_set_start' => 2, 'mcal_event_set_title' => 2, 'mcal_fetch_current_stream_event' => 2, 'mcal_fetch_event' => 2, 'mcal_is_leap_year' => 2, 'mcal_list_alarms' => 2, 'mcal_list_events' => 2, 'mcal_next_recurrence' => 2, 'mcal_open' => 2, 'mcal_snooze' => 2, 'mcal_store_event' => 2, 'mcal_time_valid' => 2, 'mcrypt_cbc' => 2, 'mcrypt_cfb' => 2, 'mcrypt_create_iv' => 2, 'mcrypt_decrypt' => 2, 'mcrypt_ecb' => 2,
'mcrypt_enc_get_algorithms_name' => 2, 'mcrypt_enc_get_block_size' => 2, 'mcrypt_enc_get_iv_size' => 2, 'mcrypt_enc_get_key_size' => 2, 'mcrypt_enc_get_modes_name' => 2, 'mcrypt_enc_get_supported_key_sizes' => 2, 'mcrypt_enc_is_block_algorithm' => 2, 'mcrypt_enc_is_block_algorithm_mode' => 2, 'mcrypt_enc_is_block_mode' => 2, 'mcrypt_enc_self_test' => 2, 'mcrypt_encrypt' => 2, 'mcrypt_generic' => 2, 'mcrypt_generic_deinit' => 2, 'mcrypt_generic_end' => 2, 'mcrypt_generic_init' => 2, 'mcrypt_get_block_size' => 2, 'mcrypt_get_cipher_name' => 2, 'mcrypt_get_iv_size' => 2, 'mcrypt_get_key_size' => 2, 'mcrypt_list_algorithms' => 2, 'mcrypt_list_modes' => 2, 'mcrypt_module_close' => 2, 'mcrypt_module_get_algo_block_size' => 2, 'mcrypt_module_get_algo_key_size' => 2, 'mcrypt_module_get_supported_key_sizes' => 2, 'mcrypt_module_is_block_algorithm' => 2,
'mcrypt_module_is_block_algorithm_mode' => 2, 'mcrypt_module_is_block_mode' => 2, 'mcrypt_module_open' => 2, 'mcrypt_module_self_test' => 2, 'mcrypt_ofb' => 2, 'md5' => 2, 'md5_file' => 2, 'mdecrypt_generic' => 2, 'memcache_add' => 2, 'memcache_add_server' => 2, 'memcache_close' => 2, 'memcache_connect' => 2, 'memcache_debug' => 2, 'memcache_decrement' => 2, 'memcache_delete' => 2, 'memcache_flush' => 2, 'memcache_get' => 2, 'memcache_get_extended_stats' => 2, 'memcache_get_server_status' => 2, 'memcache_get_stats' => 2, 'memcache_get_version' => 2, 'memcache_increment' => 2, 'memcache_pconnect' => 2, 'memcache_replace' => 2, 'memcache_set' => 2, 'memcache_set_compress_threshold' => 2,
'memcache_set_server_params' => 2, 'memory_get_peak_usage' => 2, 'memory_get_usage' => 2, 'metaphone' => 2, 'method_exists' => 2, 'mhash' => 2, 'mhash_count' => 2, 'mhash_get_block_size' => 2, 'mhash_get_hash_name' => 2, 'mhash_keygen_s2k' => 2, 'microtime' => 2, 'mime_content_type' => 2, 'min' => 2, 'ming_keypress' => 2, 'ming_setcubicthreshold' => 2, 'ming_setscale' => 2, 'ming_useconstants' => 2, 'ming_useswfversion' => 2, 'mkdir' => 2, 'mktime' => 2, 'modifiers' => 2, 'money_format' => 2, 'move_uploaded_file' => 2, 'msgfmt_create' => 2, 'msgfmt_format' => 2, 'msgfmt_format_message' => 2,
'msgfmt_get_error_code' => 2, 'msgfmt_get_error_message' => 2, 'msgfmt_get_locale' => 2, 'msgfmt_get_pattern' => 2, 'msgfmt_parse' => 2, 'msgfmt_parse_message' => 2, 'msgfmt_set_pattern' => 2, 'msql' => 2, 'msql_affected_rows' => 2, 'msql_close' => 2, 'msql_connect' => 2, 'msql_create_db' => 2, 'msql_createdb' => 2, 'msql_data_seek' => 2, 'msql_db_query' => 2, 'msql_dbname' => 2, 'msql_drop_db' => 2, 'msql_dropdb' => 2, 'msql_error' => 2, 'msql_fetch_array' => 2, 'msql_fetch_field' => 2, 'msql_fetch_object' => 2, 'msql_fetch_row' => 2, 'msql_field_flags' => 2, 'msql_field_len' => 2, 'msql_field_name' => 2,
'msql_field_seek' => 2, 'msql_field_table' => 2, 'msql_field_type' => 2, 'msql_fieldflags' => 2, 'msql_fieldlen' => 2, 'msql_fieldname' => 2, 'msql_fieldtable' => 2, 'msql_fieldtype' => 2, 'msql_free_result' => 2, 'msql_freeresult' => 2, 'msql_list_dbs' => 2, 'msql_list_fields' => 2, 'msql_list_tables' => 2, 'msql_listdbs' => 2, 'msql_listfields' => 2, 'msql_listtables' => 2, 'msql_num_fields' => 2, 'msql_num_rows' => 2, 'msql_numfields' => 2, 'msql_numrows' => 2, 'msql_pconnect' => 2, 'msql_query' => 2, 'msql_regcase' => 2, 'msql_result' => 2, 'msql_select_db' => 2, 'msql_selectdb' => 2,
'msql_tablename' => 2, 'mssql_bind' => 2, 'mssql_close' => 2, 'mssql_connect' => 2, 'mssql_data_seek' => 2, 'mssql_execute' => 2, 'mssql_fetch_array' => 2, 'mssql_fetch_assoc' => 2, 'mssql_fetch_batch' => 2, 'mssql_fetch_field' => 2, 'mssql_fetch_object' => 2, 'mssql_fetch_row' => 2, 'mssql_field_length' => 2, 'mssql_field_name' => 2, 'mssql_field_seek' => 2, 'mssql_field_type' => 2, 'mssql_free_result' => 2, 'mssql_free_statement' => 2, 'mssql_get_last_message' => 2, 'mssql_guid_string' => 2, 'mssql_init' => 2, 'mssql_min_error_severity' => 2, 'mssql_min_message_severity' => 2, 'mssql_next_result' => 2, 'mssql_num_fields' => 2, 'mssql_num_rows' => 2,
'mssql_pconnect' => 2, 'mssql_query' => 2, 'mssql_result' => 2, 'mssql_rows_affected' => 2, 'mssql_select_db' => 2, 'mt_getrandmax' => 2, 'mt_rand' => 2, 'mt_srand' => 2, 'mysql' => 2, 'mysql_affected_rows' => 2, 'mysql_change_user' => 2, 'mysql_client_encoding' => 2, 'mysql_close' => 2, 'mysql_connect' => 2, 'mysql_create_db' => 2, 'mysql_createdb' => 2, 'mysql_data_seek' => 2, 'mysql_db_name' => 2, 'mysql_db_query' => 2, 'mysql_dbname' => 2, 'mysql_drop_db' => 2, 'mysql_dropdb' => 2, 'mysql_errno' => 2, 'mysql_error' => 2, 'mysql_escape_string' => 2, 'mysql_fetch_array' => 2,
'mysql_fetch_assoc' => 2, 'mysql_fetch_field' => 2, 'mysql_fetch_lengths' => 2, 'mysql_fetch_object' => 2, 'mysql_fetch_row' => 2, 'mysql_field_flags' => 2, 'mysql_field_len' => 2, 'mysql_field_name' => 2, 'mysql_field_seek' => 2, 'mysql_field_table' => 2, 'mysql_field_type' => 2, 'mysql_fieldflags' => 2, 'mysql_fieldlen' => 2, 'mysql_fieldname' => 2, 'mysql_fieldtable' => 2, 'mysql_fieldtype' => 2, 'mysql_free_result' => 2, 'mysql_freeresult' => 2, 'mysql_get_client_info' => 2, 'mysql_get_host_info' => 2, 'mysql_get_proto_info' => 2, 'mysql_get_server_info' => 2, 'mysql_info' => 2, 'mysql_insert_id' => 2, 'mysql_list_dbs' => 2, 'mysql_list_fields' => 2,
'mysql_list_processes' => 2, 'mysql_list_tables' => 2, 'mysql_listdbs' => 2, 'mysql_listfields' => 2, 'mysql_listtables' => 2, 'mysql_num_fields' => 2, 'mysql_num_rows' => 2, 'mysql_numfields' => 2, 'mysql_numrows' => 2, 'mysql_pconnect' => 2, 'mysql_ping' => 2, 'mysql_query' => 2, 'mysql_real_escape_string' => 2, 'mysql_result' => 2, 'mysql_select_db' => 2, 'mysql_selectdb' => 2, 'mysql_set_charset' => 2, 'mysql_stat' => 2, 'mysql_table_name' => 2, 'mysql_tablename' => 2, 'mysql_thread_id' => 2, 'mysql_unbuffered_query' => 2, 'mysqli_affected_rows' => 2, 'mysqli_autocommit' => 2, 'mysqli_bind_param' => 2, 'mysqli_bind_result' => 2,
'mysqli_change_user' => 2, 'mysqli_character_set_name' => 2, 'mysqli_client_encoding' => 2, 'mysqli_close' => 2, 'mysqli_commit' => 2, 'mysqli_connect' => 2, 'mysqli_connect_errno' => 2, 'mysqli_connect_error' => 2, 'mysqli_data_seek' => 2, 'mysqli_debug' => 2, 'mysqli_disable_reads_from_master' => 2, 'mysqli_disable_rpl_parse' => 2, 'mysqli_dump_debug_info' => 2, 'mysqli_embedded_server_end' => 2, 'mysqli_embedded_server_start' => 2, 'mysqli_enable_reads_from_master' => 2, 'mysqli_enable_rpl_parse' => 2, 'mysqli_errno' => 2, 'mysqli_error' => 2, 'mysqli_escape_string' => 2, 'mysqli_execute' => 2, 'mysqli_fetch' => 2, 'mysqli_fetch_all' => 2, 'mysqli_fetch_array' => 2, 'mysqli_fetch_assoc' => 2, 'mysqli_fetch_field' => 2,
'mysqli_fetch_field_direct' => 2, 'mysqli_fetch_fields' => 2, 'mysqli_fetch_lengths' => 2, 'mysqli_fetch_object' => 2, 'mysqli_fetch_row' => 2, 'mysqli_field_count' => 2, 'mysqli_field_seek' => 2, 'mysqli_field_tell' => 2, 'mysqli_free_result' => 2, 'mysqli_get_cache_stats' => 2, 'mysqli_get_charset' => 2, 'mysqli_get_client_info' => 2, 'mysqli_get_client_stats' => 2, 'mysqli_get_client_version' => 2, 'mysqli_get_connection_stats' => 2, 'mysqli_get_host_info' => 2, 'mysqli_get_metadata' => 2, 'mysqli_get_proto_info' => 2, 'mysqli_get_server_info' => 2, 'mysqli_get_server_version' => 2, 'mysqli_get_warnings' => 2, 'mysqli_info' => 2, 'mysqli_init' => 2, 'mysqli_insert_id' => 2, 'mysqli_kill' => 2, 'mysqli_master_query' => 2,
'mysqli_more_results' => 2, 'mysqli_multi_query' => 2, 'mysqli_next_result' => 2, 'mysqli_num_fields' => 2, 'mysqli_num_rows' => 2, 'mysqli_options' => 2, 'mysqli_param_count' => 2, 'mysqli_ping' => 2, 'mysqli_poll' => 2, 'mysqli_prepare' => 2, 'mysqli_query' => 2, 'mysqli_real_connect' => 2, 'mysqli_real_escape_string' => 2, 'mysqli_real_query' => 2, 'mysqli_reap_async_query' => 2, 'mysqli_refresh' => 2, 'mysqli_report' => 2, 'mysqli_rollback' => 2, 'mysqli_rpl_parse_enabled' => 2, 'mysqli_rpl_probe' => 2, 'mysqli_rpl_query_type' => 2, 'mysqli_select_db' => 2, 'mysqli_send_long_data' => 2, 'mysqli_send_query' => 2, 'mysqli_set_charset' => 2, 'mysqli_set_local_infile_default' => 2,
'mysqli_set_local_infile_handler' => 2, 'mysqli_set_opt' => 2, 'mysqli_slave_query' => 2, 'mysqli_sqlstate' => 2, 'mysqli_ssl_set' => 2, 'mysqli_stat' => 2, 'mysqli_stmt_affected_rows' => 2, 'mysqli_stmt_attr_get' => 2, 'mysqli_stmt_attr_set' => 2, 'mysqli_stmt_bind_param' => 2, 'mysqli_stmt_bind_result' => 2, 'mysqli_stmt_close' => 2, 'mysqli_stmt_data_seek' => 2, 'mysqli_stmt_errno' => 2, 'mysqli_stmt_error' => 2, 'mysqli_stmt_execute' => 2, 'mysqli_stmt_fetch' => 2, 'mysqli_stmt_field_count' => 2, 'mysqli_stmt_free_result' => 2, 'mysqli_stmt_get_result' => 2, 'mysqli_stmt_get_warnings' => 2, 'mysqli_stmt_init' => 2, 'mysqli_stmt_insert_id' => 2, 'mysqli_stmt_more_results' => 2, 'mysqli_stmt_next_result' => 2, 'mysqli_stmt_num_rows' => 2,
'mysqli_stmt_param_count' => 2, 'mysqli_stmt_prepare' => 2, 'mysqli_stmt_reset' => 2, 'mysqli_stmt_result_metadata' => 2, 'mysqli_stmt_send_long_data' => 2, 'mysqli_stmt_sqlstate' => 2, 'mysqli_stmt_store_result' => 2, 'mysqli_store_result' => 2, 'mysqli_thread_id' => 2, 'mysqli_thread_safe' => 2, 'mysqli_use_result' => 2, 'mysqli_warning_count' => 2, 'natcasesort' => 2, 'natsort' => 2, 'new_xmldoc' => 2, 'next' => 2, 'ngettext' => 2, 'nl2br' => 2, 'nl_langinfo' => 2, 'normalizer_is_normalized' => 2, 'normalizer_normalize' => 2, 'ntuser_getdomaincontroller' => 2, 'ntuser_getusergroups' => 2, 'ntuser_getuserinfo' => 2, 'ntuser_getuserlist' => 2, 'number_format' => 2,
'numfmt_create' => 2, 'numfmt_format' => 2, 'numfmt_format_currency' => 2, 'numfmt_get_attribute' => 2, 'numfmt_get_error_code' => 2, 'numfmt_get_error_message' => 2, 'numfmt_get_locale' => 2, 'numfmt_get_pattern' => 2, 'numfmt_get_symbol' => 2, 'numfmt_get_text_attribute' => 2, 'numfmt_parse' => 2, 'numfmt_parse_currency' => 2, 'numfmt_set_attribute' => 2, 'numfmt_set_pattern' => 2, 'numfmt_set_symbol' => 2, 'numfmt_set_text_attribute' => 2, 'ob_clean' => 2, 'ob_deflatehandler' => 2, 'ob_end_clean' => 2, 'ob_end_flush' => 2, 'ob_etaghandler' => 2, 'ob_flush' => 2, 'ob_get_clean' => 2, 'ob_get_contents' => 2, 'ob_get_flush' => 2, 'ob_get_length' => 2,
'ob_get_level' => 2, 'ob_get_status' => 2, 'ob_gzhandler' => 2, 'ob_iconv_handler' => 2, 'ob_implicit_flush' => 2, 'ob_inflatehandler' => 2, 'ob_list_handlers' => 2, 'ob_start' => 2, 'ob_tidyhandler' => 2, 'ocibindbyname' => 2, 'ocicolumnisnull' => 2, 'ocicolumnname' => 2, 'ocicolumnsize' => 2, 'ocicolumntype' => 2, 'ocicommit' => 2, 'ocidefinebyname' => 2, 'ocierror' => 2, 'ociexecute' => 2, 'ocifetch' => 2, 'ocifetchinto' => 2, 'ocifetchstatement' => 2, 'ocifreecursor' => 2, 'ocifreestatement' => 2, 'ociinternaldebug' => 2, 'ocilogoff' => 2, 'ocilogon' => 2,
'ocinewcursor' => 2, 'ocinewdescriptor' => 2, 'ocinlogon' => 2, 'ocinumcols' => 2, 'ociparse' => 2, 'ociplogon' => 2, 'ociresult' => 2, 'ocirollback' => 2, 'ocirowcount' => 2, 'ociserverversion' => 2, 'ocistatementtype' => 2, 'octdec' => 2, 'odbc_autocommit' => 2, 'odbc_binmode' => 2, 'odbc_close' => 2, 'odbc_close_all' => 2, 'odbc_columnprivileges' => 2, 'odbc_columns' => 2, 'odbc_commit' => 2, 'odbc_connect' => 2, 'odbc_cursor' => 2, 'odbc_data_source' => 2, 'odbc_do' => 2, 'odbc_error' => 2, 'odbc_errormsg' => 2, 'odbc_exec' => 2,
'odbc_execute' => 2, 'odbc_fetch_array' => 2, 'odbc_fetch_into' => 2, 'odbc_fetch_object' => 2, 'odbc_fetch_row' => 2, 'odbc_field_len' => 2, 'odbc_field_name' => 2, 'odbc_field_num' => 2, 'odbc_field_precision' => 2, 'odbc_field_scale' => 2, 'odbc_field_type' => 2, 'odbc_foreignkeys' => 2, 'odbc_free_result' => 2, 'odbc_gettypeinfo' => 2, 'odbc_longreadlen' => 2, 'odbc_next_result' => 2, 'odbc_num_fields' => 2, 'odbc_num_rows' => 2, 'odbc_pconnect' => 2, 'odbc_prepare' => 2, 'odbc_primarykeys' => 2, 'odbc_procedurecolumns' => 2, 'odbc_procedures' => 2, 'odbc_result' => 2, 'odbc_result_all' => 2, 'odbc_rollback' => 2,
'odbc_setoption' => 2, 'odbc_specialcolumns' => 2, 'odbc_statistics' => 2, 'odbc_tableprivileges' => 2, 'odbc_tables' => 2, 'opendir' => 2, 'openlog' => 2, 'openssl_cipher_iv_length' => 2, 'openssl_csr_export' => 2, 'openssl_csr_export_to_file' => 2, 'openssl_csr_get_public_key' => 2, 'openssl_csr_get_subject' => 2, 'openssl_csr_new' => 2, 'openssl_csr_sign' => 2, 'openssl_decrypt' => 2, 'openssl_dh_compute_key' => 2, 'openssl_digest' => 2, 'openssl_encrypt' => 2, 'openssl_error_string' => 2, 'openssl_free_key' => 2, 'openssl_get_cipher_methods' => 2, 'openssl_get_md_methods' => 2, 'openssl_get_privatekey' => 2, 'openssl_get_publickey' => 2, 'openssl_open' => 2, 'openssl_pkcs12_export' => 2,
'openssl_pkcs12_export_to_file' => 2, 'openssl_pkcs12_read' => 2, 'openssl_pkcs7_decrypt' => 2, 'openssl_pkcs7_encrypt' => 2, 'openssl_pkcs7_sign' => 2, 'openssl_pkcs7_verify' => 2, 'openssl_pkey_export' => 2, 'openssl_pkey_export_to_file' => 2, 'openssl_pkey_free' => 2, 'openssl_pkey_get_details' => 2, 'openssl_pkey_get_private' => 2, 'openssl_pkey_get_public' => 2, 'openssl_pkey_new' => 2, 'openssl_private_decrypt' => 2, 'openssl_private_encrypt' => 2, 'openssl_public_decrypt' => 2, 'openssl_public_encrypt' => 2, 'openssl_random_pseudo_bytes' => 2, 'openssl_seal' => 2, 'openssl_sign' => 2, 'openssl_verify' => 2, 'openssl_x509_check_private_key' => 2, 'openssl_x509_checkpurpose' => 2, 'openssl_x509_export' => 2, 'openssl_x509_export_to_file' => 2, 'openssl_x509_free' => 2,
'openssl_x509_parse' => 2, 'openssl_x509_read' => 2, 'ora_bind' => 2, 'ora_close' => 2, 'ora_columnname' => 2, 'ora_columntype' => 2, 'ora_commit' => 2, 'ora_commitoff' => 2, 'ora_commiton' => 2, 'ora_error' => 2, 'ora_errorcode' => 2, 'ora_exec' => 2, 'ora_fetch' => 2, 'ora_getcolumn' => 2, 'ora_logoff' => 2, 'ora_logon' => 2, 'ora_open' => 2, 'ora_parse' => 2, 'ora_rollback' => 2, 'ord' => 2, 'output_add_rewrite_var' => 2, 'output_reset_rewrite_vars' => 2, 'outputdebugstring' => 2, 'overload' => 2, 'pack' => 2, 'parse_ini_file' => 2,
'parse_ini_string' => 2, 'parse_str' => 2, 'parse_url' => 2, 'parsekit_compile_file' => 2, 'parsekit_compile_string' => 2, 'parsekit_func_arginfo' => 2, 'parsekit_opcode_flags' => 2, 'parsekit_opcode_name' => 2, 'passthru' => 2, 'pathinfo' => 2, 'pattern' => 2, 'pclose' => 2, 'pdf_add_annotation' => 2, 'pdf_add_bookmark' => 2, 'pdf_add_launchlink' => 2, 'pdf_add_locallink' => 2, 'pdf_add_nameddest' => 2, 'pdf_add_note' => 2, 'pdf_add_outline' => 2, 'pdf_add_pdflink' => 2, 'pdf_add_thumbnail' => 2, 'pdf_add_weblink' => 2, 'pdf_arc' => 2, 'pdf_arcn' => 2, 'pdf_attach_file' => 2, 'pdf_begin_font' => 2,
'pdf_begin_glyph' => 2, 'pdf_begin_page' => 2, 'pdf_begin_pattern' => 2, 'pdf_begin_template' => 2, 'pdf_circle' => 2, 'pdf_clip' => 2, 'pdf_close' => 2, 'pdf_close_image' => 2, 'pdf_close_pdi' => 2, 'pdf_close_pdi_page' => 2, 'pdf_closepath' => 2, 'pdf_closepath_fill_stroke' => 2, 'pdf_closepath_stroke' => 2, 'pdf_concat' => 2, 'pdf_continue_text' => 2, 'pdf_create_gstate' => 2, 'pdf_create_pvf' => 2, 'pdf_curveto' => 2, 'pdf_delete' => 2, 'pdf_delete_pvf' => 2, 'pdf_encoding_set_char' => 2, 'pdf_end_font' => 2, 'pdf_end_glyph' => 2, 'pdf_end_page' => 2, 'pdf_end_pattern' => 2, 'pdf_end_template' => 2,
'pdf_endpath' => 2, 'pdf_execute_image' => 2, 'pdf_fill' => 2, 'pdf_fill_imageblock' => 2, 'pdf_fill_pdfblock' => 2, 'pdf_fill_stroke' => 2, 'pdf_fill_textblock' => 2, 'pdf_findfont' => 2, 'pdf_fit_image' => 2, 'pdf_fit_pdi_page' => 2, 'pdf_fit_textline' => 2, 'pdf_get_apiname' => 2, 'pdf_get_buffer' => 2, 'pdf_get_errmsg' => 2, 'pdf_get_errnum' => 2, 'pdf_get_info' => 2, 'pdf_get_parameter' => 2, 'pdf_get_pdi_parameter' => 2, 'pdf_get_pdi_value' => 2, 'pdf_get_value' => 2, 'pdf_initgraphics' => 2, 'pdf_lineto' => 2, 'pdf_load_font' => 2, 'pdf_load_iccprofile' => 2, 'pdf_load_image' => 2, 'pdf_makespotcolor' => 2,
'pdf_moveto' => 2, 'pdf_new' => 2, 'pdf_open' => 2, 'pdf_open_ccitt' => 2, 'pdf_open_file' => 2, 'pdf_open_gif' => 2, 'pdf_open_image' => 2, 'pdf_open_image_file' => 2, 'pdf_open_jpeg' => 2, 'pdf_open_memory_image' => 2, 'pdf_open_pdi' => 2, 'pdf_open_pdi_page' => 2, 'pdf_place_image' => 2, 'pdf_place_pdi_page' => 2, 'pdf_process_pdi' => 2, 'pdf_put_image' => 2, 'pdf_rect' => 2, 'pdf_restore' => 2, 'pdf_rotate' => 2, 'pdf_save' => 2, 'pdf_scale' => 2, 'pdf_set_border_color' => 2, 'pdf_set_border_dash' => 2, 'pdf_set_border_style' => 2, 'pdf_set_char_spacing' => 2, 'pdf_set_duration' => 2,
'pdf_set_font' => 2, 'pdf_set_gstate' => 2, 'pdf_set_horiz_scaling' => 2, 'pdf_set_info' => 2, 'pdf_set_info_author' => 2, 'pdf_set_info_creator' => 2, 'pdf_set_info_keywords' => 2, 'pdf_set_info_subject' => 2, 'pdf_set_info_title' => 2, 'pdf_set_leading' => 2, 'pdf_set_parameter' => 2, 'pdf_set_text_matrix' => 2, 'pdf_set_text_pos' => 2, 'pdf_set_text_rendering' => 2, 'pdf_set_text_rise' => 2, 'pdf_set_transition' => 2, 'pdf_set_value' => 2, 'pdf_set_word_spacing' => 2, 'pdf_setcolor' => 2, 'pdf_setdash' => 2, 'pdf_setdashpattern' => 2, 'pdf_setflat' => 2, 'pdf_setfont' => 2, 'pdf_setgray' => 2, 'pdf_setgray_fill' => 2, 'pdf_setgray_stroke' => 2,
'pdf_setlinecap' => 2, 'pdf_setlinejoin' => 2, 'pdf_setlinewidth' => 2, 'pdf_setmatrix' => 2, 'pdf_setmiterlimit' => 2, 'pdf_setpolydash' => 2, 'pdf_setrgbcolor' => 2, 'pdf_setrgbcolor_fill' => 2, 'pdf_setrgbcolor_stroke' => 2, 'pdf_shading' => 2, 'pdf_shading_pattern' => 2, 'pdf_shfill' => 2, 'pdf_show' => 2, 'pdf_show_boxed' => 2, 'pdf_show_xy' => 2, 'pdf_skew' => 2, 'pdf_stringwidth' => 2, 'pdf_stroke' => 2, 'pdf_translate' => 2, 'pdo_drivers' => 2, 'pfsockopen' => 2, 'pg_affected_rows' => 2, 'pg_cancel_query' => 2, 'pg_client_encoding' => 2, 'pg_clientencoding' => 2, 'pg_close' => 2,
'pg_cmdtuples' => 2, 'pg_connect' => 2, 'pg_connection_busy' => 2, 'pg_connection_reset' => 2, 'pg_connection_status' => 2, 'pg_convert' => 2, 'pg_copy_from' => 2, 'pg_copy_to' => 2, 'pg_dbname' => 2, 'pg_delete' => 2, 'pg_end_copy' => 2, 'pg_errormessage' => 2, 'pg_escape_bytea' => 2, 'pg_escape_string' => 2, 'pg_exec' => 2, 'pg_execute' => 2, 'pg_fetch_all' => 2, 'pg_fetch_all_columns' => 2, 'pg_fetch_array' => 2, 'pg_fetch_assoc' => 2, 'pg_fetch_object' => 2, 'pg_fetch_result' => 2, 'pg_fetch_row' => 2, 'pg_field_is_null' => 2, 'pg_field_name' => 2, 'pg_field_num' => 2,
'pg_field_prtlen' => 2, 'pg_field_size' => 2, 'pg_field_table' => 2, 'pg_field_type' => 2, 'pg_field_type_oid' => 2, 'pg_fieldisnull' => 2, 'pg_fieldname' => 2, 'pg_fieldnum' => 2, 'pg_fieldprtlen' => 2, 'pg_fieldsize' => 2, 'pg_fieldtype' => 2, 'pg_free_result' => 2, 'pg_freeresult' => 2, 'pg_get_notify' => 2, 'pg_get_pid' => 2, 'pg_get_result' => 2, 'pg_getlastoid' => 2, 'pg_host' => 2, 'pg_insert' => 2, 'pg_last_error' => 2, 'pg_last_notice' => 2, 'pg_last_oid' => 2, 'pg_lo_close' => 2, 'pg_lo_create' => 2, 'pg_lo_export' => 2, 'pg_lo_import' => 2,
'pg_lo_open' => 2, 'pg_lo_read' => 2, 'pg_lo_read_all' => 2, 'pg_lo_seek' => 2, 'pg_lo_tell' => 2, 'pg_lo_unlink' => 2, 'pg_lo_write' => 2, 'pg_loclose' => 2, 'pg_locreate' => 2, 'pg_loexport' => 2, 'pg_loimport' => 2, 'pg_loopen' => 2, 'pg_loread' => 2, 'pg_loreadall' => 2, 'pg_lounlink' => 2, 'pg_lowrite' => 2, 'pg_meta_data' => 2, 'pg_num_fields' => 2, 'pg_num_rows' => 2, 'pg_numfields' => 2, 'pg_numrows' => 2, 'pg_options' => 2, 'pg_parameter_status' => 2, 'pg_pconnect' => 2, 'pg_ping' => 2, 'pg_port' => 2,
'pg_prepare' => 2, 'pg_put_line' => 2, 'pg_query' => 2, 'pg_query_params' => 2, 'pg_result' => 2, 'pg_result_error' => 2, 'pg_result_error_field' => 2, 'pg_result_seek' => 2, 'pg_result_status' => 2, 'pg_select' => 2, 'pg_send_execute' => 2, 'pg_send_prepare' => 2, 'pg_send_query' => 2, 'pg_send_query_params' => 2, 'pg_set_client_encoding' => 2, 'pg_set_error_verbosity' => 2, 'pg_setclientencoding' => 2, 'pg_trace' => 2, 'pg_transaction_status' => 2, 'pg_tty' => 2, 'pg_unescape_bytea' => 2, 'pg_untrace' => 2, 'pg_update' => 2, 'pg_version' => 2, 'php_egg_logo_guid' => 2, 'php_ini_loaded_file' => 2,
'php_ini_scanned_files' => 2, 'php_logo_guid' => 2, 'php_real_logo_guid' => 2, 'php_sapi_name' => 2, 'php_strip_whitespace' => 2, 'php_uname' => 2, 'phpcredits' => 2, 'phpdoc_xml_from_string' => 2, 'phpinfo' => 2, 'phpversion' => 2, 'pi' => 2, 'png2wbmp' => 2, 'pop3_close' => 2, 'pop3_delete_message' => 2, 'pop3_get_account_size' => 2, 'pop3_get_message' => 2, 'pop3_get_message_count' => 2, 'pop3_get_message_header' => 2, 'pop3_get_message_ids' => 2, 'pop3_get_message_size' => 2, 'pop3_get_message_sizes' => 2, 'pop3_open' => 2, 'pop3_undelete' => 2, 'popen' => 2, 'pos' => 2, 'posix_ctermid' => 2,
'posix_errno' => 2, 'posix_get_last_error' => 2, 'posix_getcwd' => 2, 'posix_getegid' => 2, 'posix_geteuid' => 2, 'posix_getgid' => 2, 'posix_getgrgid' => 2, 'posix_getgrnam' => 2, 'posix_getgroups' => 2, 'posix_getlogin' => 2, 'posix_getpgid' => 2, 'posix_getpgrp' => 2, 'posix_getpid' => 2, 'posix_getppid' => 2, 'posix_getpwnam' => 2, 'posix_getpwuid' => 2, 'posix_getrlimit' => 2, 'posix_getsid' => 2, 'posix_getuid' => 2, 'posix_isatty' => 2, 'posix_kill' => 2, 'posix_mkfifo' => 2, 'posix_setegid' => 2, 'posix_seteuid' => 2, 'posix_setgid' => 2, 'posix_setpgid' => 2,
'posix_setsid' => 2, 'posix_setuid' => 2, 'posix_strerror' => 2, 'posix_times' => 2, 'posix_ttyname' => 2, 'posix_uname' => 2, 'pow' => 2, 'preg_filter' => 2, 'preg_grep' => 2, 'preg_last_error' => 2, 'preg_match' => 2, 'preg_match_all' => 2, 'preg_quote' => 2, 'preg_replace' => 2, 'preg_replace_callback' => 2, 'preg_split' => 2, 'prev' => 2, 'print_r' => 2, 'printf' => 2, 'proc_close' => 2, 'proc_get_status' => 2, 'proc_open' => 2, 'proc_terminate' => 2, 'property_exists' => 2, 'putenv' => 2, 'quoted_printable_decode' => 2,
'quoted_printable_encode' => 2, 'quotemeta' => 2, 'rad2deg' => 2, 'radius_acct_open' => 2, 'radius_add_server' => 2, 'radius_auth_open' => 2, 'radius_close' => 2, 'radius_config' => 2, 'radius_create_request' => 2, 'radius_cvt_addr' => 2, 'radius_cvt_int' => 2, 'radius_cvt_string' => 2, 'radius_demangle' => 2, 'radius_demangle_mppe_key' => 2, 'radius_get_attr' => 2, 'radius_get_vendor_attr' => 2, 'radius_put_addr' => 2, 'radius_put_attr' => 2, 'radius_put_int' => 2, 'radius_put_string' => 2, 'radius_put_vendor_addr' => 2, 'radius_put_vendor_attr' => 2, 'radius_put_vendor_int' => 2, 'radius_put_vendor_string' => 2, 'radius_request_authenticator' => 2, 'radius_send_request' => 2,
'radius_server_secret' => 2, 'radius_strerror' => 2, 'rand' => 2, 'range' => 2, 'rawurldecode' => 2, 'rawurlencode' => 2, 'read_exif_data' => 2, 'readdir' => 2, 'readfile' => 2, 'readgzfile' => 2, 'readlink' => 2, 'realpath' => 2, 'realpath_cache_get' => 2, 'realpath_cache_size' => 2, 'recode_file' => 2, 'recode_string' => 2, 'reg_close_key' => 2, 'reg_create_key' => 2, 'reg_enum_key' => 2, 'reg_enum_value' => 2, 'reg_get_value' => 2, 'reg_open_key' => 2, 'reg_set_value' => 2, 'register_shutdown_function' => 2, 'register_tick_function' => 2, 'rename' => 2,
'res_close' => 2, 'res_get' => 2, 'res_list' => 2, 'res_list_type' => 2, 'res_open' => 2, 'res_set' => 2, 'reset' => 2, 'resourcebundle_count' => 2, 'resourcebundle_create' => 2, 'resourcebundle_get' => 2, 'resourcebundle_get_error_code' => 2, 'resourcebundle_get_error_message' => 2, 'resourcebundle_locales' => 2, 'restore_error_handler' => 2, 'restore_exception_handler' => 2, 'restore_include_path' => 2, 'rewind' => 2, 'rewinddir' => 2, 'rmdir' => 2, 'round' => 2, 'rsort' => 2, 'rtrim' => 2, 'runkit_class_adopt' => 2, 'runkit_class_emancipate' => 2, 'runkit_constant_add' => 2, 'runkit_constant_redefine' => 2,
'runkit_constant_remove' => 2, 'runkit_default_property_add' => 2, 'runkit_function_add' => 2, 'runkit_function_copy' => 2, 'runkit_function_redefine' => 2, 'runkit_function_remove' => 2, 'runkit_function_rename' => 2, 'runkit_import' => 2, 'runkit_lint' => 2, 'runkit_lint_file' => 2, 'runkit_method_add' => 2, 'runkit_method_copy' => 2, 'runkit_method_redefine' => 2, 'runkit_method_remove' => 2, 'runkit_method_rename' => 2, 'runkit_object_id' => 2, 'runkit_return_value_used' => 2, 'runkit_sandbox_output_handler' => 2, 'runkit_superglobals' => 2, 'runkit_zval_inspect' => 2, 'scandir' => 2, 'sem_acquire' => 2, 'sem_get' => 2, 'sem_release' => 2, 'sem_remove' => 2, 'serialize' => 2,
'session_cache_expire' => 2, 'session_cache_limiter' => 2, 'session_commit' => 2, 'session_decode' => 2, 'session_destroy' => 2, 'session_encode' => 2, 'session_get_cookie_params' => 2, 'session_id' => 2, 'session_is_registered' => 2, 'session_module_name' => 2, 'session_name' => 2, 'session_regenerate_id' => 2, 'session_register' => 2, 'session_save_path' => 2, 'session_set_cookie_params' => 2, 'session_set_save_handler' => 2, 'session_start' => 2, 'session_unregister' => 2, 'session_unset' => 2, 'session_write_close' => 2, 'set_content' => 2, 'set_error_handler' => 2, 'set_exception_handler' => 2, 'set_file_buffer' => 2, 'set_include_path' => 2, 'set_magic_quotes_runtime' => 2,
'set_socket_blocking' => 2, 'set_time_limit' => 2, 'setcookie' => 2, 'setlocale' => 2, 'setrawcookie' => 2, 'settype' => 2, 'sha1' => 2, 'sha1_file' => 2, 'shell_exec' => 2, 'shm_attach' => 2, 'shm_detach' => 2, 'shm_get_var' => 2, 'shm_put_var' => 2, 'shm_remove' => 2, 'shm_remove_var' => 2, 'shmop_close' => 2, 'shmop_delete' => 2, 'shmop_open' => 2, 'shmop_read' => 2, 'shmop_size' => 2, 'shmop_write' => 2, 'show_source' => 2, 'shuffle' => 2, 'similar_text' => 2, 'simplexml_import_dom' => 2, 'simplexml_load_file' => 2,
'simplexml_load_string' => 2, 'sin' => 2, 'sinh' => 2, 'sizeof' => 2, 'sleep' => 2, 'smtp_close' => 2, 'smtp_cmd_data' => 2, 'smtp_cmd_mail' => 2, 'smtp_cmd_rcpt' => 2, 'smtp_connect' => 2, 'snmp2_get' => 2, 'snmp2_getnext' => 2, 'snmp2_real_walk' => 2, 'snmp2_set' => 2, 'snmp2_walk' => 2, 'snmp3_get' => 2, 'snmp3_getnext' => 2, 'snmp3_real_walk' => 2, 'snmp3_set' => 2, 'snmp3_walk' => 2, 'snmp_get_quick_print' => 2, 'snmp_get_valueretrieval' => 2, 'snmp_read_mib' => 2, 'snmp_set_quick_print' => 2, 'snmp_set_valueretrieval' => 2, 'snmpget' => 2,
'snmpgetnext' => 2, 'snmprealwalk' => 2, 'snmpset' => 2, 'snmpwalk' => 2, 'snmpwalkoid' => 2, 'socket_accept' => 2, 'socket_bind' => 2, 'socket_clear_error' => 2, 'socket_close' => 2, 'socket_connect' => 2, 'socket_create' => 2, 'socket_create_listen' => 2, 'socket_create_pair' => 2, 'socket_get_option' => 2, 'socket_get_status' => 2, 'socket_getopt' => 2, 'socket_getpeername' => 2, 'socket_getsockname' => 2, 'socket_iovec_add' => 2, 'socket_iovec_alloc' => 2, 'socket_iovec_delete' => 2, 'socket_iovec_fetch' => 2, 'socket_iovec_free' => 2, 'socket_iovec_set' => 2, 'socket_last_error' => 2, 'socket_listen' => 2,
'socket_read' => 2, 'socket_readv' => 2, 'socket_recv' => 2, 'socket_recvfrom' => 2, 'socket_recvmsg' => 2, 'socket_select' => 2, 'socket_send' => 2, 'socket_sendmsg' => 2, 'socket_sendto' => 2, 'socket_set_block' => 2, 'socket_set_blocking' => 2, 'socket_set_nonblock' => 2, 'socket_set_option' => 2, 'socket_set_timeout' => 2, 'socket_setopt' => 2, 'socket_shutdown' => 2, 'socket_strerror' => 2, 'socket_write' => 2, 'socket_writev' => 2, 'solid_close' => 2, 'solid_connect' => 2, 'solid_exec' => 2, 'solid_fetchrow' => 2, 'solid_fieldname' => 2, 'solid_fieldnum' => 2, 'solid_freeresult' => 2,
'solid_numfields' => 2, 'solid_numrows' => 2, 'solid_result' => 2, 'sort' => 2, 'soundex' => 2, 'spl_autoload' => 2, 'spl_autoload_call' => 2, 'spl_autoload_extensions' => 2, 'spl_autoload_functions' => 2, 'spl_autoload_register' => 2, 'spl_autoload_unregister' => 2, 'spl_classes' => 2, 'spl_object_hash' => 2, 'split' => 2, 'spliti' => 2, 'sprintf' => 2, 'sql_regcase' => 2, 'sqlite_array_query' => 2, 'sqlite_busy_timeout' => 2, 'sqlite_changes' => 2, 'sqlite_close' => 2, 'sqlite_column' => 2, 'sqlite_create_aggregate' => 2, 'sqlite_create_function' => 2, 'sqlite_current' => 2, 'sqlite_error_string' => 2,
'sqlite_escape_string' => 2, 'sqlite_exec' => 2, 'sqlite_factory' => 2, 'sqlite_fetch_all' => 2, 'sqlite_fetch_array' => 2, 'sqlite_fetch_column_types' => 2, 'sqlite_fetch_object' => 2, 'sqlite_fetch_single' => 2, 'sqlite_fetch_string' => 2, 'sqlite_field_name' => 2, 'sqlite_has_more' => 2, 'sqlite_has_prev' => 2, 'sqlite_last_error' => 2, 'sqlite_last_insert_rowid' => 2, 'sqlite_libencoding' => 2, 'sqlite_libversion' => 2, 'sqlite_next' => 2, 'sqlite_num_fields' => 2, 'sqlite_num_rows' => 2, 'sqlite_open' => 2, 'sqlite_popen' => 2, 'sqlite_prev' => 2, 'sqlite_query' => 2, 'sqlite_rewind' => 2, 'sqlite_seek' => 2, 'sqlite_single_query' => 2,
'sqlite_udf_decode_binary' => 2, 'sqlite_udf_encode_binary' => 2, 'sqlite_unbuffered_query' => 2, 'sqlite_valid' => 2, 'sqrt' => 2, 'srand' => 2, 'sscanf' => 2, 'ssh2_auth_hostbased_file' => 2, 'ssh2_auth_none' => 2, 'ssh2_auth_password' => 2, 'ssh2_auth_pubkey_file' => 2, 'ssh2_connect' => 2, 'ssh2_exec' => 2, 'ssh2_fetch_stream' => 2, 'ssh2_fingerprint' => 2, 'ssh2_forward_accept' => 2, 'ssh2_forward_listen' => 2, 'ssh2_methods_negotiated' => 2, 'ssh2_poll' => 2, 'ssh2_publickey_add' => 2, 'ssh2_publickey_init' => 2, 'ssh2_publickey_list' => 2, 'ssh2_publickey_remove' => 2, 'ssh2_scp_recv' => 2, 'ssh2_scp_send' => 2, 'ssh2_sftp' => 2,
'ssh2_sftp_lstat' => 2, 'ssh2_sftp_mkdir' => 2, 'ssh2_sftp_readlink' => 2, 'ssh2_sftp_realpath' => 2, 'ssh2_sftp_rename' => 2, 'ssh2_sftp_rmdir' => 2, 'ssh2_sftp_stat' => 2, 'ssh2_sftp_symlink' => 2, 'ssh2_sftp_unlink' => 2, 'ssh2_shell' => 2, 'ssh2_tunnel' => 2, 'stat' => 2, 'stats_absolute_deviation' => 2, 'stats_cdf_beta' => 2, 'stats_cdf_binomial' => 2, 'stats_cdf_cauchy' => 2, 'stats_cdf_chisquare' => 2, 'stats_cdf_exponential' => 2, 'stats_cdf_f' => 2, 'stats_cdf_gamma' => 2, 'stats_cdf_laplace' => 2, 'stats_cdf_logistic' => 2, 'stats_cdf_negative_binomial' => 2, 'stats_cdf_noncentral_chisquare' => 2, 'stats_cdf_noncentral_f' => 2, 'stats_cdf_noncentral_t' => 2,
'stats_cdf_normal' => 2, 'stats_cdf_poisson' => 2, 'stats_cdf_t' => 2, 'stats_cdf_uniform' => 2, 'stats_cdf_weibull' => 2, 'stats_covariance' => 2, 'stats_dens_beta' => 2, 'stats_dens_cauchy' => 2, 'stats_dens_chisquare' => 2, 'stats_dens_exponential' => 2, 'stats_dens_f' => 2, 'stats_dens_gamma' => 2, 'stats_dens_laplace' => 2, 'stats_dens_logistic' => 2, 'stats_dens_normal' => 2, 'stats_dens_pmf_binomial' => 2, 'stats_dens_pmf_hypergeometric' => 2, 'stats_dens_pmf_negative_binomial' => 2, 'stats_dens_pmf_poisson' => 2, 'stats_dens_t' => 2, 'stats_dens_uniform' => 2, 'stats_dens_weibull' => 2, 'stats_harmonic_mean' => 2, 'stats_kurtosis' => 2, 'stats_rand_gen_beta' => 2, 'stats_rand_gen_chisquare' => 2,
'stats_rand_gen_exponential' => 2, 'stats_rand_gen_f' => 2, 'stats_rand_gen_funiform' => 2, 'stats_rand_gen_gamma' => 2, 'stats_rand_gen_ipoisson' => 2, 'stats_rand_gen_iuniform' => 2, 'stats_rand_gen_noncenral_f' => 2, 'stats_rand_gen_noncentral_chisquare' => 2, 'stats_rand_gen_noncentral_t' => 2, 'stats_rand_gen_normal' => 2, 'stats_rand_gen_t' => 2, 'stats_rand_getsd' => 2, 'stats_rand_ibinomial' => 2, 'stats_rand_ibinomial_negative' => 2, 'stats_rand_ignlgi' => 2, 'stats_rand_phrase_to_seeds' => 2, 'stats_rand_ranf' => 2, 'stats_rand_setall' => 2, 'stats_skew' => 2, 'stats_standard_deviation' => 2, 'stats_stat_binomial_coef' => 2, 'stats_stat_correlation' => 2, 'stats_stat_factorial' => 2, 'stats_stat_independent_t' => 2, 'stats_stat_innerproduct' => 2, 'stats_stat_paired_t' => 2,
'stats_stat_percentile' => 2, 'stats_stat_powersum' => 2, 'stats_variance' => 2, 'str_getcsv' => 2, 'str_ireplace' => 2, 'str_pad' => 2, 'str_repeat' => 2, 'str_replace' => 2, 'str_rot13' => 2, 'str_shuffle' => 2, 'str_split' => 2, 'str_word_count' => 2, 'strcasecmp' => 2, 'strchr' => 2, 'strcmp' => 2, 'strcoll' => 2, 'strcspn' => 2, 'stream_bucket_append' => 2, 'stream_bucket_make_writeable' => 2, 'stream_bucket_new' => 2, 'stream_bucket_prepend' => 2, 'stream_context_create' => 2, 'stream_context_get_default' => 2, 'stream_context_get_options' => 2, 'stream_context_get_params' => 2, 'stream_context_set_default' => 2,
'stream_context_set_option' => 2, 'stream_context_set_params' => 2, 'stream_copy_to_stream' => 2, 'stream_encoding' => 2, 'stream_filter_append' => 2, 'stream_filter_prepend' => 2, 'stream_filter_register' => 2, 'stream_filter_remove' => 2, 'stream_get_contents' => 2, 'stream_get_filters' => 2, 'stream_get_line' => 2, 'stream_get_meta_data' => 2, 'stream_get_transports' => 2, 'stream_get_wrappers' => 2, 'stream_is_local' => 2, 'stream_notification_callback' => 2, 'stream_register_wrapper' => 2, 'stream_resolve_include_path' => 2, 'stream_select' => 2, 'stream_set_blocking' => 2, 'stream_set_chunk_size' => 2, 'stream_set_read_buffer' => 2, 'stream_set_timeout' => 2, 'stream_set_write_buffer' => 2, 'stream_socket_accept' => 2, 'stream_socket_client' => 2,
'stream_socket_enable_crypto' => 2, 'stream_socket_get_name' => 2, 'stream_socket_pair' => 2, 'stream_socket_recvfrom' => 2, 'stream_socket_sendto' => 2, 'stream_socket_server' => 2, 'stream_socket_shutdown' => 2, 'stream_supports_lock' => 2, 'stream_wrapper_register' => 2, 'stream_wrapper_restore' => 2, 'stream_wrapper_unregister' => 2, 'strftime' => 2, 'strip_tags' => 2, 'stripcslashes' => 2, 'stripos' => 2, 'stripslashes' => 2, 'stristr' => 2, 'strlen' => 2, 'strnatcasecmp' => 2, 'strnatcmp' => 2, 'strncasecmp' => 2, 'strncmp' => 2, 'strpbrk' => 2, 'strpos' => 2, 'strrchr' => 2, 'strrev' => 2,
'strripos' => 2, 'strrpos' => 2, 'strspn' => 2, 'strstr' => 2, 'strtok' => 2, 'strtolower' => 2, 'strtotime' => 2, 'strtoupper' => 2, 'strtr' => 2, 'strval' => 2, 'substr' => 2, 'substr_compare' => 2, 'substr_count' => 2, 'substr_replac' => 2, 'substr_replace' => 2, 'svn_add' => 2, 'svn_auth_get_parameter' => 2, 'svn_auth_set_parameter' => 2, 'svn_cat' => 2, 'svn_checkout' => 2, 'svn_cleanup' => 2, 'svn_client_version' => 2, 'svn_commit' => 2, 'svn_diff' => 2, 'svn_export' => 2, 'svn_fs_abort_txn' => 2,
'svn_fs_apply_text' => 2, 'svn_fs_begin_txn2' => 2, 'svn_fs_change_node_prop' => 2, 'svn_fs_check_path' => 2, 'svn_fs_contents_changed' => 2, 'svn_fs_copy' => 2, 'svn_fs_delete' => 2, 'svn_fs_dir_entries' => 2, 'svn_fs_file_contents' => 2, 'svn_fs_file_length' => 2, 'svn_fs_is_dir' => 2, 'svn_fs_is_file' => 2, 'svn_fs_make_dir' => 2, 'svn_fs_make_file' => 2, 'svn_fs_node_created_rev' => 2, 'svn_fs_node_prop' => 2, 'svn_fs_props_changed' => 2, 'svn_fs_revision_prop' => 2, 'svn_fs_revision_root' => 2, 'svn_fs_txn_root' => 2, 'svn_fs_youngest_rev' => 2, 'svn_import' => 2, 'svn_info' => 2, 'svn_log' => 2, 'svn_ls' => 2, 'svn_repos_create' => 2,
'svn_repos_fs' => 2, 'svn_repos_fs_begin_txn_for_commit' => 2, 'svn_repos_fs_commit_txn' => 2, 'svn_repos_hotcopy' => 2, 'svn_repos_open' => 2, 'svn_repos_recover' => 2, 'svn_status' => 2, 'svn_update' => 2, 'sybase_affected_rows' => 2, 'sybase_close' => 2, 'sybase_connect' => 2, 'sybase_data_seek' => 2, 'sybase_fetch_array' => 2, 'sybase_fetch_field' => 2, 'sybase_fetch_object' => 2, 'sybase_fetch_row' => 2, 'sybase_field_seek' => 2, 'sybase_free_result' => 2, 'sybase_num_fields' => 2, 'sybase_num_rows' => 2, 'sybase_pconnect' => 2, 'sybase_query' => 2, 'sybase_result' => 2, 'sybase_select_db' => 2, 'symlink' => 2, 'syntax' => 2,
'sys_get_temp_dir' => 2, 'syslog' => 2, 'system' => 2, 'tan' => 2, 'tanh' => 2, 'tempnam' => 2, 'textdomain' => 2, 'thread_get' => 2, 'thread_include' => 2, 'thread_lock' => 2, 'thread_lock_try' => 2, 'thread_mutex_destroy' => 2, 'thread_mutex_init' => 2, 'thread_set' => 2, 'thread_start' => 2, 'thread_unlock' => 2, 'tidy_access_count' => 2, 'tidy_clean_repair' => 2, 'tidy_config_count' => 2, 'tidy_diagnose' => 2, 'tidy_error_count' => 2, 'tidy_get_body' => 2, 'tidy_get_config' => 2, 'tidy_get_error_buffer' => 2, 'tidy_get_head' => 2, 'tidy_get_html' => 2,
'tidy_get_html_ver' => 2, 'tidy_get_output' => 2, 'tidy_get_release' => 2, 'tidy_get_root' => 2, 'tidy_get_status' => 2, 'tidy_getopt' => 2, 'tidy_is_xhtml' => 2, 'tidy_is_xml' => 2, 'tidy_parse_file' => 2, 'tidy_parse_string' => 2, 'tidy_repair_file' => 2, 'tidy_repair_string' => 2, 'tidy_warning_count' => 2, 'time' => 2, 'time_nanosleep' => 2, 'time_sleep_until' => 2, 'timezone_abbreviations_list' => 2, 'timezone_identifiers_list' => 2, 'timezone_location_get' => 2, 'timezone_name_from_abbr' => 2, 'timezone_name_get' => 2, 'timezone_offset_get' => 2, 'timezone_open' => 2, 'timezone_transitions_get' => 2, 'timezone_version_get' => 2, 'tmpfile' => 2,
'token_get_all' => 2, 'token_name' => 2, 'touch' => 2, 'trait_exists' => 2, 'transliterate' => 2, 'transliterate_filters_get' => 2, 'trigger_error' => 2, 'trim' => 2, 'uasort' => 2, 'ucfirst' => 2, 'ucwords' => 2, 'uksort' => 2, 'umask' => 2, 'uniqid' => 2, 'unixtojd' => 2, 'unlink' => 2, 'unpack' => 2, 'unregister_tick_function' => 2, 'unserialize' => 2, 'urldecode' => 2, 'urlencode' => 2, 'use_soap_error_handler' => 2, 'user_error' => 2, 'usleep' => 2, 'usort' => 2, 'utf8_decode' => 2,
'utf8_encode' => 2, 'var_dump' => 2, 'var_export' => 2, 'variant_abs' => 2, 'variant_add' => 2, 'variant_and' => 2, 'variant_cast' => 2, 'variant_cat' => 2, 'variant_cmp' => 2, 'variant_date_from_timestamp' => 2, 'variant_date_to_timestamp' => 2, 'variant_div' => 2, 'variant_eqv' => 2, 'variant_fix' => 2, 'variant_get_type' => 2, 'variant_idiv' => 2, 'variant_imp' => 2, 'variant_int' => 2, 'variant_mod' => 2, 'variant_mul' => 2, 'variant_neg' => 2, 'variant_not' => 2, 'variant_or' => 2, 'variant_pow' => 2, 'variant_round' => 2, 'variant_set' => 2,
'variant_set_type' => 2, 'variant_sub' => 2, 'variant_xor' => 2, 'version_compare' => 2, 'vfprintf' => 2, 'virtual' => 2, 'vm_addalias' => 2, 'vm_adduser' => 2, 'vm_delalias' => 2, 'vm_deluser' => 2, 'vm_passwd' => 2, 'vprintf' => 2, 'vsprintf' => 2, 'wddx_add_vars' => 2, 'wddx_deserialize' => 2, 'wddx_packet_end' => 2, 'wddx_packet_start' => 2, 'wddx_serialize_value' => 2, 'wddx_serialize_vars' => 2, 'win32_create_service' => 2, 'win32_delete_service' => 2, 'win32_get_last_control_message' => 2, 'win32_ps_list_procs' => 2, 'win32_ps_stat_mem' => 2, 'win32_ps_stat_proc' => 2, 'win32_query_service_status' => 2,
'win32_scheduler_delete_task' => 2, 'win32_scheduler_enum_tasks' => 2, 'win32_scheduler_get_task_info' => 2, 'win32_scheduler_run' => 2, 'win32_scheduler_set_task_info' => 2, 'win32_set_service_status' => 2, 'win32_start_service' => 2, 'win32_start_service_ctrl_dispatcher' => 2, 'win32_stop_service' => 2, 'win_beep' => 2, 'win_browse_file' => 2, 'win_browse_folder' => 2, 'win_create_link' => 2, 'win_message_box' => 2, 'win_play_wav' => 2, 'win_shell_execute' => 2, 'wordwrap' => 2, 'xml_error_string' => 2, 'xml_get_current_byte_index' => 2, 'xml_get_current_column_number' => 2, 'xml_get_current_line_number' => 2, 'xml_get_error_code' => 2, 'xml_parse' => 2, 'xml_parse_into_struct' => 2, 'xml_parser_create' => 2, 'xml_parser_create_ns' => 2,
'xml_parser_free' => 2, 'xml_parser_get_option' => 2, 'xml_parser_set_option' => 2, 'xml_set_character_data_handler' => 2, 'xml_set_default_handler' => 2, 'xml_set_element_handler' => 2, 'xml_set_end_namespace_decl_handler' => 2, 'xml_set_external_entity_ref_handler' => 2, 'xml_set_notation_decl_handler' => 2, 'xml_set_object' => 2, 'xml_set_processing_instruction_handler' => 2, 'xml_set_start_namespace_decl_handler' => 2, 'xml_set_unparsed_entity_decl_handler' => 2, 'xmldoc' => 2, 'xmldocfile' => 2, 'xmlrpc_decode' => 2, 'xmlrpc_decode_request' => 2, 'xmlrpc_encode' => 2, 'xmlrpc_encode_request' => 2, 'xmlrpc_get_type' => 2, 'xmlrpc_is_fault' => 2, 'xmlrpc_parse_method_descriptions' => 2, 'xmlrpc_server_add_introspection_data' => 2, 'xmlrpc_server_call_method' => 2, 'xmlrpc_server_create' => 2, 'xmlrpc_server_destroy' => 2,
'xmlrpc_server_register_introspection_callback' => 2, 'xmlrpc_server_register_method' => 2, 'xmlrpc_set_type' => 2, 'xmltree' => 2, 'xmlwriter_end_attribute' => 2, 'xmlwriter_end_cdata' => 2, 'xmlwriter_end_comment' => 2, 'xmlwriter_end_document' => 2, 'xmlwriter_end_dtd' => 2, 'xmlwriter_end_dtd_attlist' => 2, 'xmlwriter_end_dtd_element' => 2, 'xmlwriter_end_dtd_entity' => 2, 'xmlwriter_end_element' => 2, 'xmlwriter_end_pi' => 2, 'xmlwriter_flush' => 2, 'xmlwriter_full_end_element' => 2, 'xmlwriter_open_memory' => 2, 'xmlwriter_open_uri' => 2, 'xmlwriter_output_memory' => 2, 'xmlwriter_set_indent' => 2, 'xmlwriter_set_indent_string' => 2, 'xmlwriter_start_attribute' => 2, 'xmlwriter_start_attribute_ns' => 2, 'xmlwriter_start_cdata' => 2, 'xmlwriter_start_comment' => 2, 'xmlwriter_start_document' => 2,
'xmlwriter_start_dtd' => 2, 'xmlwriter_start_dtd_attlist' => 2, 'xmlwriter_start_dtd_element' => 2, 'xmlwriter_start_dtd_entity' => 2, 'xmlwriter_start_element' => 2, 'xmlwriter_start_element_ns' => 2, 'xmlwriter_start_pi' => 2, 'xmlwriter_text' => 2, 'xmlwriter_write_attribute' => 2, 'xmlwriter_write_attribute_ns' => 2, 'xmlwriter_write_cdata' => 2, 'xmlwriter_write_comment' => 2, 'xmlwriter_write_dtd' => 2, 'xmlwriter_write_dtd_attlist' => 2, 'xmlwriter_write_dtd_element' => 2, 'xmlwriter_write_dtd_entity' => 2, 'xmlwriter_write_element' => 2, 'xmlwriter_write_element_ns' => 2, 'xmlwriter_write_pi' => 2, 'xmlwriter_write_raw' => 2, 'xpath_eval' => 2, 'xpath_eval_expression' => 2, 'xpath_new_context' => 2, 'xpath_register_ns' => 2, 'xpath_register_ns_auto' => 2, 'xptr_eval' => 2,
'xptr_new_context' => 2, 'yp_all' => 2, 'yp_cat' => 2, 'yp_err_string' => 2, 'yp_errno' => 2, 'yp_first' => 2, 'yp_get_default_domain' => 2, 'yp_master' => 2, 'yp_match' => 2, 'yp_next' => 2, 'yp_order' => 2, 'zend_current_obfuscation_level' => 2, 'zend_get_cfg_var' => 2, 'zend_get_id' => 2, 'zend_loader_current_file' => 2, 'zend_loader_enabled' => 2, 'zend_loader_file_encoded' => 2, 'zend_loader_file_licensed' => 2, 'zend_loader_install_license' => 2, 'zend_loader_version' => 2, 'zend_logo_guid' => 2, 'zend_match_hostmasks' => 2, 'zend_obfuscate_class_name' => 2, 'zend_obfuscate_function_name' => 2, 'zend_optimizer_version' => 2, 'zend_runtime_obfuscate' => 2,
'zend_version' => 2, 'zip_close' => 2, 'zip_entry_close' => 2, 'zip_entry_compressedsize' => 2, 'zip_entry_compressionmethod' => 2, 'zip_entry_filesize' => 2, 'zip_entry_name' => 2, 'zip_entry_open' => 2, 'zip_entry_read' => 2, 'zip_open' => 2, 'zip_read' => 2, 'zlib_decode' => 2, 'zlib_encode' => 2, 'zlib_get_coding_type' => 2
), 2 => false
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '$', 1 => '\'', 2 => '"', 4 => '_', 7 => "\n", 8 => "\t", 9 => '//', 10 => '/*', 11 => '#', 12 => '?>', 13 => '<?'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if (preg_match('~^[a-z]+~i', $part, $matches)) {
return array(3, $matches[0], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if (preg_match('~^\\d+~', $part, $matches)) {
return array(5, $matches[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(6, $matches[0], $buffer);
}
if ($delimiters[7] === $letter) {
return array(7, $delimiters[7], $buffer);
}
if ($delimiters[8] === $letter) {
return array(8, $delimiters[8], $buffer);
}
if (0 === strpos($part, $delimiters[9])) {
return array(9, $delimiters[9], $buffer);
}
if (0 === strpos($part, $delimiters[10])) {
return array(10, $delimiters[10], $buffer);
}
if ($delimiters[11] === $letter) {
return array(11, $delimiters[11], $buffer);
}
if (0 === strpos($part, $delimiters[12])) {
return array(12, $delimiters[12], $buffer);
}
if (0 === strpos($part, $delimiters[13])) {
return array(13, $delimiters[13], $buffer);
}
if (preg_match('~<<<\'\\w+\'\\n~A', $text, $matches, 0, $textPos)) {
return array(14, $matches[0], $buffer);
}
if (preg_match('~<<<(?:\\w+|"\\w+")\\n~A', $text, $matches, 0, $textPos)) {
return array(15, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state DUMMY_PHP.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '<?php', 1 => '<?=', 2 => '<?'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state FUNCTION.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^\\W+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_BLOCK.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '*/'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '?>'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state VAR.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
1 => '$', 2 => '{', 3 => '}'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~^\\W+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state VAR_STR.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '}'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^\s+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\\\\', 2 => '\\"', 3 => '$', 4 => '{$', 5 => "\n", 6 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if ($delimiters[6] === $letter) {
return array(6, $delimiters[6], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEREDOC.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '\\$', 3 => '$', 4 => '{$'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEREDOC_END.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter9($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if (preg_match('~\\w+;\\n~A', $text, $matches, 0, $textPos)) {
return array(0, $matches[0], $buffer);
}
return array(1, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter10($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\'', 1 => '\\\\', 2 => '\\\'', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NOWDOC.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter11($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NOWDOC_END.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter12($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if (preg_match('~\\w+;\\n~A', $text, $matches, 0, $textPos)) {
return array(0, $matches[0], $buffer);
}
return array(1, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NUMBER.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter13($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'e', 1 => 'E', 2 => 'x', 3 => 'b'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(4, $matches[0], $buffer);
}
return array(5, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state EXPONENT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter14($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '+', 1 => '-'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^\\D+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEXA.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter15($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^[^a-f\\d]+~i', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,711 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Python lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Python
*/
class Python
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Python';
$this->trans = array(
0 => array(
0 => array(
0 => 1, 1 => -1
), 1 => array(
0 => 1, 1 => -1
), 2 => array(
0 => 2, 1 => 1
), 3 => array(
0 => 3, 1 => 1
), 4 => array(
0 => 4, 1 => 1
), 5 => array(
0 => 5, 1 => 1
), 6 => array(
0 => 6, 1 => 1
), 7 => array(
0 => 7, 1 => 1
), 8 => array(
0 => 7, 1 => 1
), 9 => array(
0 => 0, 1 => 1
), 10 => array(
0 => 0, 1 => 1
)
), 1 => array(
0 => array(
0 => 11, 1 => -1
)
), 2 => array(
0 => array(
0 => 11, 1 => 0
), 1 => array(
0 => 2, 1 => 1
), 2 => array(
0 => 2, 1 => 1
), 3 => array(
0 => 2, 1 => 1
), 4 => array(
0 => 2, 1 => 1
)
), 3 => array(
0 => array(
0 => 11, 1 => 0
), 1 => array(
0 => 3, 1 => 1
), 2 => array(
0 => 3, 1 => 1
), 3 => array(
0 => 3, 1 => 1
), 4 => array(
0 => 3, 1 => 1
)
), 4 => array(
0 => array(
0 => 11, 1 => 0
), 1 => array(
0 => 4, 1 => 1
), 2 => array(
0 => 4, 1 => 1
), 3 => array(
0 => 4, 1 => 1
), 4 => array(
0 => 4, 1 => 1
)
), 5 => array(
0 => array(
0 => 11, 1 => 0
), 1 => array(
0 => 5, 1 => 1
), 2 => array(
0 => 5, 1 => 1
), 3 => array(
0 => 5, 1 => 1
), 4 => array(
0 => 5, 1 => 1
)
), 6 => array(
0 => array(
0 => 11, 1 => -1
), 1 => array(
0 => 6, 1 => 1
)
), 7 => array(
0 => array(
0 => 8, 1 => 1
), 1 => array(
0 => 11, 1 => 0
), 2 => array(
0 => 11, 1 => 0
), 3 => array(
0 => 11, 1 => 0
), 4 => array(
0 => 11, 1 => 0
), 5 => array(
0 => 9, 1 => 1
), 6 => array(
0 => 9, 1 => 1
), 7 => array(
0 => 9, 1 => 1
), 8 => array(
0 => 10, 1 => 1
), 9 => array(
0 => 10, 1 => 1
), 10 => array(
0 => 11, 1 => -1
)
), 8 => array(
0 => array(
0 => 11, 1 => 0
), 1 => array(
0 => 11, 1 => 0
), 2 => array(
0 => 9, 1 => 1
), 3 => array(
0 => 9, 1 => 1
), 4 => array(
0 => 9, 1 => 1
), 5 => array(
0 => 11, 1 => -1
)
), 9 => array(
0 => array(
0 => 11, 1 => 0
), 1 => array(
0 => 11, 1 => 0
), 2 => array(
0 => 11, 1 => -1
)
), 10 => array(
0 => array(
0 => 11, 1 => 0
), 1 => array(
0 => 11, 1 => 0
), 2 => array(
0 => 11, 1 => -1
)
)
);
$this->initialState = 0;
$this->returnState = 11;
$this->quitState = 12;
$this->flags = array(
0 => 0, 1 => 5, 2 => 4, 3 => 4, 4 => 4, 5 => 4, 6 => 4, 7 => 4, 8 => 0, 9 => 0, 10 => 4
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL, 9 => NULL, 10 => NULL
);
$this->classes = array(
0 => NULL, 1 => NULL, 2 => 'py-docstring', 3 => 'py-docstring', 4 => 'py-quote', 5 => 'py-quote', 6 => 'py-comment', 7 => 'py-num', 8 => 'py-num', 9 => 'py-num', 10 => 'py-num'
);
$this->keywords = array(
0 => 'py-keyword', 1 => array(
'and' => 1, 'as' => 1, 'assert' => 1, 'break' => 1, 'class' => 1, 'continue' => 1, 'def' => 1, 'del' => 1, 'elif' => 1, 'else' => 1, 'except' => 1, 'exec' => 1, 'finally' => 1, 'for' => 1, 'from' => 1, 'global' => 1, 'if' => 1, 'import' => 1, 'in' => 1, 'is' => 1, 'lambda' => 1, 'not' => 1, 'or' => 1, 'pass' => 1, 'print' => 1, 'raise' => 1,
'return' => 1, 'try' => 1, 'while' => 1, 'with' => 1, 'yield' => 1, 'abs' => 2, 'all' => 2, 'any' => 2, 'apply' => 2, 'basestring' => 2, 'bool' => 2, 'buffer' => 2, 'callable' => 2, 'chr' => 2, 'classmethod' => 2, 'cmp' => 2, 'coerce' => 2, 'compile' => 2, 'complex' => 2, 'delattr' => 2, 'dict' => 2, 'dir' => 2, 'divmod' => 2, 'enumerate' => 2, 'eval' => 2, 'execfile' => 2,
'file' => 2, 'filter' => 2, 'float' => 2, 'frozenset' => 2, 'getattr' => 2, 'globals' => 2, 'hasattr' => 2, 'hash' => 2, 'hex' => 2, 'id' => 2, 'input' => 2, 'int' => 2, 'intern' => 2, 'isinstance' => 2, 'issubclass' => 2, 'iter' => 2, 'len' => 2, 'list' => 2, 'locals' => 2, 'long' => 2, 'map' => 2, 'max' => 2, 'min' => 2, 'object' => 2, 'oct' => 2, 'open' => 2,
'ord' => 2, 'pow' => 2, 'property' => 2, 'range' => 2, 'raw_input' => 2, 'reduce' => 2, 'reload' => 2, 'repr' => 2, 'reversed' => 2, 'round' => 2, 'set' => 2, 'setattr' => 2, 'slice' => 2, 'sorted' => 2, 'staticmethod' => 2, 'str' => 2, 'sum' => 2, 'super' => 2, 'tuple' => 2, 'type' => 2, 'unichr' => 2, 'unicode' => 2, 'vars' => 2, 'xrange' => 2, 'zip' => 2, 'ArithmeticError' => 3,
'AssertionError' => 3, 'AttributeError' => 3, 'BaseException' => 3, 'DeprecationWarning' => 3, 'EOFError' => 3, 'Ellipsis' => 3, 'EnvironmentError' => 3, 'Exception' => 3, 'FloatingPointError' => 3, 'FutureWarning' => 3, 'GeneratorExit' => 3, 'IOError' => 3, 'ImportError' => 3, 'ImportWarning' => 3, 'IndentationError' => 3, 'IndexError' => 3, 'KeyError' => 3, 'KeyboardInterrupt' => 3, 'LookupError' => 3, 'MemoryError' => 3, 'NameError' => 3, 'NotImplemented' => 3, 'NotImplementedError' => 3, 'OSError' => 3, 'OverflowError' => 3, 'OverflowWarning' => 3,
'PendingDeprecationWarning' => 3, 'ReferenceError' => 3, 'RuntimeError' => 3, 'RuntimeWarning' => 3, 'StandardError' => 3, 'StopIteration' => 3, 'SyntaxError' => 3, 'SyntaxWarning' => 3, 'SystemError' => 3, 'SystemExit' => 3, 'TabError' => 3, 'TypeError' => 3, 'UnboundLocalError' => 3, 'UnicodeDecodeError' => 3, 'UnicodeEncodeError' => 3, 'UnicodeError' => 3, 'UnicodeTranslateError' => 3, 'UnicodeWarning' => 3, 'UserWarning' => 3, 'ValueError' => 3, 'Warning' => 3, 'WindowsError' => 3, 'ZeroDivisionError' => 3, 'BufferType' => 3, 'BuiltinFunctionType' => 3, 'BuiltinMethodType' => 3,
'ClassType' => 3, 'CodeType' => 3, 'ComplexType' => 3, 'DictProxyType' => 3, 'DictType' => 3, 'DictionaryType' => 3, 'EllipsisType' => 3, 'FileType' => 3, 'FloatType' => 3, 'FrameType' => 3, 'FunctionType' => 3, 'GeneratorType' => 3, 'InstanceType' => 3, 'IntType' => 3, 'LambdaType' => 3, 'ListType' => 3, 'LongType' => 3, 'MethodType' => 3, 'ModuleType' => 3, 'NoneType' => 3, 'ObjectType' => 3, 'SliceType' => 3, 'StringType' => 3, 'StringTypes' => 3, 'TracebackType' => 3, 'TupleType' => 3,
'TypeType' => 3, 'UnboundMethodType' => 3, 'UnicodeType' => 3, 'XRangeType' => 3, 'False' => 3, 'None' => 3, 'True' => 3, '__abs__' => 3, '__add__' => 3, '__all__' => 3, '__author__' => 3, '__bases__' => 3, '__builtins__' => 3, '__call__' => 3, '__class__' => 3, '__cmp__' => 3, '__coerce__' => 3, '__contains__' => 3, '__debug__' => 3, '__del__' => 3, '__delattr__' => 3, '__delitem__' => 3, '__delslice__' => 3, '__dict__' => 3, '__div__' => 3, '__divmod__' => 3,
'__doc__' => 3, '__eq__' => 3, '__file__' => 3, '__float__' => 3, '__floordiv__' => 3, '__future__' => 3, '__ge__' => 3, '__getattr__' => 3, '__getattribute__' => 3, '__getitem__' => 3, '__getslice__' => 3, '__gt__' => 3, '__hash__' => 3, '__hex__' => 3, '__iadd__' => 3, '__import__' => 3, '__imul__' => 3, '__init__' => 3, '__int__' => 3, '__invert__' => 3, '__iter__' => 3, '__le__' => 3, '__len__' => 3, '__long__' => 3, '__lshift__' => 3, '__lt__' => 3,
'__members__' => 3, '__metaclass__' => 3, '__mod__' => 3, '__mro__' => 3, '__mul__' => 3, '__name__' => 3, '__ne__' => 3, '__neg__' => 3, '__new__' => 3, '__nonzero__' => 3, '__oct__' => 3, '__or__' => 3, '__path__' => 3, '__pos__' => 3, '__pow__' => 3, '__radd__' => 3, '__rdiv__' => 3, '__rdivmod__' => 3, '__reduce__' => 3, '__repr__' => 3, '__rfloordiv__' => 3, '__rlshift__' => 3, '__rmod__' => 3, '__rmul__' => 3, '__ror__' => 3, '__rpow__' => 3,
'__rrshift__' => 3, '__rsub__' => 3, '__rtruediv__' => 3, '__rxor__' => 3, '__setattr__' => 3, '__setitem__' => 3, '__setslice__' => 3, '__self__' => 3, '__slots__' => 3, '__str__' => 3, '__sub__' => 3, '__truediv__' => 3, '__version__' => 3, '__xor__' => 3
), 2 => true
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
1 => '_', 2 => '\'\'\'', 3 => '"""', 4 => '\'', 5 => '"', 6 => '#', 9 => "\n", 10 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~^[a-z]+~i', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if ($delimiters[6] === $letter) {
return array(6, $delimiters[6], $buffer);
}
if (preg_match('~^\\d+~', $part, $matches)) {
return array(7, $matches[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(8, $matches[0], $buffer);
}
if ($delimiters[9] === $letter) {
return array(9, $delimiters[9], $buffer);
}
if ($delimiters[10] === $letter) {
return array(10, $delimiters[10], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state KEYWORD.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^\\W+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state DOCSTRING1.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\'\'\'', 1 => '\\\\', 2 => '\\\'\'\'', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state DOCSTRING2.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"""', 1 => '\\\\', 2 => '\\"""', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\'', 1 => '\\\\', 2 => '\\\'', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\\\\', 2 => '\\"', 3 => "\n", 4 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NUMBER.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
1 => 'l', 2 => 'L', 3 => 'j', 4 => 'J', 5 => 'e-', 6 => 'e+', 7 => 'e', 8 => 'x', 9 => 'X'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
if (0 === strpos($part, $delimiters[5])) {
return array(5, $delimiters[5], $buffer);
}
if (0 === strpos($part, $delimiters[6])) {
return array(6, $delimiters[6], $buffer);
}
if ($delimiters[7] === $letter) {
return array(7, $delimiters[7], $buffer);
}
if ($delimiters[8] === $letter) {
return array(8, $delimiters[8], $buffer);
}
if ($delimiters[9] === $letter) {
return array(9, $delimiters[9], $buffer);
}
return array(10, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state FRACTION.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'j', 1 => 'J', 2 => 'e-', 3 => 'e+', 4 => 'e'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
return array(5, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state EXPONENT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter9($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'j', 1 => 'J'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^\\D+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEXA.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter10($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'L', 1 => 'l'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (preg_match('~^[^a-f\\d]+~i', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,594 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Sql lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Sql
*/
class Sql
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Sql';
$this->trans = array(
0 => array(
0 => array(
0 => 1, 1 => -1
), 1 => array(
0 => 7, 1 => 1
), 2 => array(
0 => 7, 1 => 1
), 3 => array(
0 => 2, 1 => 1
), 4 => array(
0 => 3, 1 => 1
), 5 => array(
0 => 3, 1 => 1
), 6 => array(
0 => 3, 1 => 1
), 7 => array(
0 => 4, 1 => 1
), 8 => array(
0 => 5, 1 => 1
), 9 => array(
0 => 6, 1 => 1
), 10 => array(
0 => 0, 1 => 1
), 11 => array(
0 => 0, 1 => 1
)
), 1 => array(
0 => array(
0 => 10, 1 => -1
)
), 2 => array(
0 => array(
0 => 2, 1 => 1
), 1 => array(
0 => 2, 1 => 1
), 2 => array(
0 => 10, 1 => 0
)
), 3 => array(
0 => array(
0 => 10, 1 => -1
), 1 => array(
0 => 3, 1 => 1
)
), 4 => array(
0 => array(
0 => 10, 1 => 0
), 1 => array(
0 => 4, 1 => 1
), 2 => array(
0 => 4, 1 => 1
), 3 => array(
0 => 4, 1 => 1
)
), 5 => array(
0 => array(
0 => 10, 1 => 0
), 1 => array(
0 => 5, 1 => 1
), 2 => array(
0 => 5, 1 => 1
), 3 => array(
0 => 5, 1 => 1
)
), 6 => array(
0 => array(
0 => 10, 1 => 0
), 1 => array(
0 => 6, 1 => 1
), 2 => array(
0 => 6, 1 => 1
), 3 => array(
0 => 6, 1 => 1
)
), 7 => array(
0 => array(
0 => 8, 1 => 1
), 1 => array(
0 => 7, 1 => 1
), 2 => array(
0 => 10, 1 => -1
)
), 8 => array(
0 => array(
0 => 10, 1 => -1
)
), 9 => array(
0 => array(
0 => 9, 1 => 1
), 1 => array(
0 => 9, 1 => 1
), 2 => array(
0 => 9, 1 => 1
), 3 => array(
0 => 9, 1 => 1
), 4 => array(
0 => 9, 1 => 1
)
)
);
$this->initialState = 0;
$this->returnState = 10;
$this->quitState = 11;
$this->flags = array(
0 => 1, 1 => 5, 2 => 4, 3 => 4, 4 => 4, 5 => 4, 6 => 4, 7 => 4, 8 => 0, 9 => 4
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL, 9 => NULL
);
$this->classes = array(
0 => NULL, 1 => NULL, 2 => 'sql-comment', 3 => 'sql-comment', 4 => 'sql-value', 5 => 'sql-value', 6 => 'sql-value', 7 => 'sql-num', 8 => 'sql-num', 9 => 'sql-option'
);
$this->keywords = array(
0 => 'sql-keyword', 1 => array(
'a' => 1, 'abs' => 2, 'acos' => 2, 'add' => 1, 'add_months' => 1, 'after' => 1, 'all' => 1, 'alter' => 1, 'an' => 1, 'and' => 1, 'any' => 1, 'array' => 1, 'as' => 1, 'asc' => 1, 'ascii' => 2, 'asin' => 2, 'atan' => 2, 'atan2' => 2, 'avg' => 2, 'before' => 1, 'begin' => 1, 'between' => 1, 'bigint' => 3, 'binary' => 1, 'bind' => 1, 'binding' => 1,
'bit' => 1, 'blob' => 3, 'boolean' => 3, 'by' => 1, 'call' => 1, 'cascade' => 1, 'case' => 1, 'cast' => 1, 'ceiling' => 2, 'char' => 3, 'char_length' => 2, 'character' => 2, 'character_length' => 2, 'chartorowid' => 1, 'check' => 1, 'chr' => 1, 'cleanup' => 1, 'close' => 1, 'clustered' => 1, 'coalesce' => 1, 'colgroup' => 1, 'collate' => 1, 'commit' => 1, 'complex' => 1, 'compress' => 1, 'concat' => 2,
'connect' => 1, 'constraint' => 1, 'contains' => 1, 'continue' => 1, 'convert' => 1, 'cos' => 2, 'count' => 2, 'create' => 1, 'cross' => 1, 'curdate' => 2, 'current' => 1, 'cursor' => 1, 'curtime' => 2, 'cvar' => 1, 'database' => 1, 'datapages' => 1, 'date' => 2, 'dayname' => 2, 'dayofmonth' => 2, 'dayofweek' => 2, 'dayofyear' => 2, 'db_name' => 1, 'dba' => 1, 'dec' => 3, 'decimal' => 3, 'declaration' => 1,
'declare' => 1, 'decode' => 2, 'default' => 1, 'definition' => 1, 'degrees' => 1, 'delete' => 1, 'desc' => 1, 'describe' => 1, 'descriptor' => 1, 'dhtype' => 1, 'difference' => 1, 'distinct' => 1, 'double' => 3, 'drop' => 1, 'each' => 1, 'else' => 1, 'end' => 1, 'escape' => 1, 'exclusive' => 1, 'exec' => 1, 'execute' => 1, 'exists' => 1, 'exit' => 1, 'exp' => 2, 'explicit' => 1, 'extent' => 1,
'fetch' => 1, 'field file' => 1, 'float' => 3, 'floor' => 2, 'for' => 1, 'foreign' => 1, 'found' => 1, 'from' => 1, 'full' => 1, 'go' => 1, 'goto' => 1, 'grant' => 1, 'greatest' => 2, 'group' => 1, 'hash' => 1, 'having' => 1, 'hour' => 1, 'identified' => 1, 'ifnull' => 2, 'immediate' => 1, 'in' => 1, 'index' => 1, 'indexpages' => 1, 'indicator' => 1, 'initcap' => 1, 'inner' => 1,
'inout' => 1, 'input' => 1, 'insert' => 1, 'instr' => 1, 'int' => 3, 'integer' => 3, 'interface' => 1, 'intersect' => 1, 'into' => 1, 'is' => 1, 'isnull' => 2, 'java_object' => 3, 'join' => 1, 'key' => 1, 'last_day' => 2, 'lcase' => 2, 'least' => 2, 'left' => 2, 'length' => 2, 'like' => 1, 'link' => 1, 'list' => 1, 'locate' => 1, 'lock' => 1, 'log' => 2, 'log10' => 2,
'long' => 1, 'longblob' => 3, 'longtext' => 3, 'longvarbinary' => 3, 'longvarchar' => 3, 'lower' => 1, 'lpad' => 1, 'ltrim' => 2, 'lvarbinary' => 1, 'lvarchar' => 1, 'main' => 1, 'max' => 2, 'mediumint' => 3, 'metadata_only' => 1, 'min' => 2, 'minus' => 2, 'minute' => 2, 'mod' => 2, 'mode' => 1, 'modify' => 1, 'money' => 1, 'month' => 2, 'monthname' => 2, 'months_between' => 2, 'name' => 1, 'national' => 1,
'natural' => 1, 'nchar' => 1, 'newrow' => 1, 'next_day' => 1, 'nocompress' => 1, 'not' => 1, 'now' => 1, 'nowait' => 1, 'null' => 1, 'nullif' => 1, 'nullvalue' => 1, 'number' => 1, 'numeric' => 1, 'nvl' => 1, 'object_id' => 1, 'odbc_convert' => 1, 'odbcinfo' => 1, 'of' => 1, 'oldrow' => 1, 'on' => 1, 'open' => 1, 'option' => 1, 'or' => 1, 'order' => 1, 'out' => 1, 'outer' => 1,
'output' => 1, 'pctfree' => 1, 'pi' => 1, 'power' => 1, 'precision' => 1, 'prefix' => 1, 'prepare' => 1, 'primary' => 1, 'privileges' => 1, 'procedure' => 1, 'public' => 1, 'quarter' => 2, 'radians' => 2, 'rand' => 2, 'range' => 2, 'raw' => 1, 'real' => 3, 'record' => 1, 'references' => 1, 'referencing' => 1, 'rename' => 1, 'repeat' => 2, 'replace' => 1, 'resource' => 1, 'restrict' => 1, 'result' => 1,
'return' => 2, 'revoke' => 2, 'right' => 2, 'rollback' => 1, 'row' => 2, 'rowid' => 2, 'rowidtochar' => 2, 'rownum' => 2, 'rpad' => 2, 'rtrim' => 2, 'searched_case' => 1, 'second' => 1, 'section' => 1, 'select' => 1, 'service' => 1, 'set' => 1, 'share' => 1, 'short' => 1, 'sign' => 1, 'simple_case' => 1, 'sin' => 2, 'size' => 2, 'smallint' => 3, 'some' => 1, 'soundex' => 1, 'space' => 1,
'sql' => 1, 'sql_bigint' => 3, 'sql_binary' => 3, 'sql_bit' => 3, 'sql_char' => 3, 'sql_date' => 3, 'sql_decimal' => 3, 'sql_double' => 3, 'sql_float' => 1, 'sql_integer' => 3, 'sql_longvarbinary' => 3, 'sql_longvarchar' => 3, 'sql_numeric' => 3, 'sql_real' => 3, 'sql_smallint' => 3, 'sql_time' => 3, 'sql_timestamp' => 1, 'sql_tinyint' => 3, 'sql_tsi_day' => 3, 'sql_tsi_frac_second' => 3, 'sql_tsi_hour' => 3, 'sql_tsi_minute' => 3, 'sql_tsi_month' => 3, 'sql_tsi_quarter' => 3, 'sql_tsi_second' => 3, 'sql_tsi_week' => 3,
'sql_tsi_year' => 3, 'sql_varbinary' => 3, 'sql_varchar' => 3, 'sqlerror' => 1, 'sqlwarning' => 1, 'sqrt' => 1, 'start' => 1, 'statement' => 1, 'statistics' => 1, 'stop' => 1, 'storage_attributes' => 1, 'storage_manager' => 1, 'store_in_progress' => 1, 'string' => 3, 'substr' => 2, 'substring' => 2, 'suffix' => 2, 'sum' => 2, 'suser_name' => 2, 'synonym' => 2, 'sysdate' => 2, 'systime' => 2, 'systimestamp' => 2, 'table' => 1, 'tan' => 2, 'text' => 3,
'then' => 1, 'time' => 2, 'timeout' => 2, 'timestamp' => 3, 'timestampadd' => 2, 'timestampdiff' => 2, 'tinyint' => 3, 'to' => 2, 'to_char' => 2, 'to_date' => 2, 'to_number' => 2, 'to_time' => 2, 'to_timestamp' => 2, 'top' => 1, 'tpe' => 1, 'tran' => 1, 'transaction' => 1, 'translate' => 1, 'trigger' => 1, 'type' => 1, 'ucase' => 1, 'uid' => 1, 'union' => 1, 'unique' => 1, 'unsigned' => 1, 'update' => 1,
'upper' => 1, 'user' => 1, 'user_id' => 1, 'user_name' => 1, 'using' => 1, 'uuid' => 1, 'values' => 1, 'varbinary' => 1, 'varchar' => 3, 'variables' => 1, 'varying' => 1, 'version' => 1, 'view' => 1, 'week' => 2, 'when' => 1, 'whenever' => 1, 'where' => 1, 'with' => 1, 'work' => 1, 'year' => 1
), 2 => false
);
}
/**
* Finds a delimiter for state OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
3 => '/*', 4 => '//', 5 => '#', 6 => '--', 7 => '"', 8 => '\'', 9 => '`', 10 => "\n", 11 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (preg_match('~^[a-z]+~i', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
if (preg_match('~^\\d+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(2, $matches[0], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
if ($delimiters[5] === $letter) {
return array(5, $delimiters[5], $buffer);
}
if (0 === strpos($part, $delimiters[6])) {
return array(6, $delimiters[6], $buffer);
}
if ($delimiters[7] === $letter) {
return array(7, $delimiters[7], $buffer);
}
if ($delimiters[8] === $letter) {
return array(8, $delimiters[8], $buffer);
}
if ($delimiters[9] === $letter) {
return array(9, $delimiters[9], $buffer);
}
if ($delimiters[10] === $letter) {
return array(10, $delimiters[10], $buffer);
}
if ($delimiters[11] === $letter) {
return array(11, $delimiters[11], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state FUNCTION.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^\\W+~', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_BLOCK.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t", 2 => '*/'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state COMMENT_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '"', 1 => '\\"', 2 => "\n", 3 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\'', 1 => '\\\'', 2 => "\n", 3 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state QUOTE_BACK_APOSTROPHE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '`', 1 => '\\`', 2 => "\n", 3 => "\t"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state NUMBER.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'x'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^\.\\d+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
return array(2, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEXA.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (preg_match('~^[^a-f\\d]+~i', $part, $matches)) {
return array(0, $matches[0], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state OPTION.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter9($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'BLOB', 1 => 'TEXT', 2 => 'INTEGER', 3 => 'CHAR', 4 => 'DATE'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $text[$textPos];
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,972 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer\Cache;
/**
* Optimized and cached Texy lexer.
*
* This file is generated. All changes made in this file will be lost.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
* @see \FSHL\Generator
* @see \FSHL\Lexer\Texy
*/
class Texy
{
/**
* Language name.
*
* @var array
*/
public $language;
/**
* Transitions table.
*
* @var array
*/
public $trans;
/**
* Id of the initial state.
*
* @var integer
*/
public $initialState;
/**
* Id of the return state.
*
* @var integer
*/
public $returnState;
/**
* Id of the quit state.
*
* @var integer
*/
public $quitState;
/**
* List of flags for all states.
*
* @var array
*/
public $flags;
/**
* Data for all states.
*
* @var array
*/
public $data;
/**
* List of CSS classes.
*
* @var array
*/
public $classes;
/**
* List of keywords.
*
* @var array
*/
public $keywords;
/**
* Initializes the lexer.
*/
public function __construct()
{
$this->language = 'Texy';
$this->trans = array(
0 => array(
0 => array(
0 => 8, 1 => 1
), 1 => array(
0 => 9, 1 => 1
), 2 => array(
0 => 1, 1 => 1
)
), 1 => array(
0 => array(
0 => 3, 1 => 1
), 1 => array(
0 => 2, 1 => -1
)
), 2 => array(
0 => array(
0 => 4, 1 => 1
), 1 => array(
0 => 4, 1 => 1
), 2 => array(
0 => 4, 1 => 1
), 3 => array(
0 => 4, 1 => 1
), 4 => array(
0 => 0, 1 => -1
)
), 3 => array(
0 => array(
0 => 3, 1 => 1
), 1 => array(
0 => 4, 1 => 1
), 2 => array(
0 => 4, 1 => 1
), 3 => array(
0 => 7, 1 => 1
), 4 => array(
0 => 7, 1 => 1
), 5 => array(
0 => 7, 1 => 1
), 6 => array(
0 => 7, 1 => 1
), 7 => array(
0 => 0, 1 => -1
)
), 4 => array(
0 => array(
0 => 4, 1 => 1
), 1 => array(
0 => 4, 1 => 1
), 2 => array(
0 => 4, 1 => 1
), 3 => array(
0 => 4, 1 => 1
), 4 => array(
0 => 3, 1 => 1
), 5 => array(
0 => 5, 1 => -1
)
), 5 => array(
0 => array(
0 => 6, 1 => 1
), 1 => array(
0 => 6, 1 => 1
), 2 => array(
0 => 6, 1 => 1
), 3 => array(
0 => 6, 1 => 1
), 4 => array(
0 => 3, 1 => 1
)
), 6 => array(
0 => array(
0 => 3, 1 => 1
)
), 7 => array(
0 => array(
0 => 0, 1 => -1
)
), 8 => array(
0 => array(
0 => 15, 1 => 1
), 1 => array(
0 => 19, 1 => 1
), 2 => array(
0 => 10, 1 => 1
), 3 => array(
0 => 11, 1 => 1
), 4 => array(
0 => 0, 1 => -1
)
), 9 => array(
0 => array(
0 => 0, 1 => -1
)
), 10 => array(
0 => array(
0 => 0, 1 => -1
)
), 11 => array(
0 => array(
0 => 12, 1 => -1
)
), 12 => array(
0 => array(
0 => 13, 1 => 1
)
), 13 => array(
0 => array(
0 => 14, 1 => 1
), 1 => array(
0 => 12, 1 => -1
)
), 14 => array(
0 => array(
0 => 0, 1 => -1
)
), 15 => array(
0 => array(
0 => 16, 1 => -1
)
), 16 => array(
0 => array(
0 => 17, 1 => 1
)
), 17 => array(
0 => array(
0 => 18, 1 => 1
), 1 => array(
0 => 16, 1 => -1
)
), 18 => array(
0 => array(
0 => 0, 1 => -1
)
), 19 => array(
0 => array(
0 => 20, 1 => -1
)
), 20 => array(
0 => array(
0 => 21, 1 => 1
)
), 21 => array(
0 => array(
0 => 22, 1 => 1
), 1 => array(
0 => 20, 1 => -1
)
), 22 => array(
0 => array(
0 => 0, 1 => -1
)
)
);
$this->initialState = 2;
$this->returnState = 23;
$this->quitState = 24;
$this->flags = array(
0 => 0, 1 => 0, 2 => 0, 3 => 'texy-err', 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0, 13 => 0, 14 => 0, 15 => 0, 16 => 0, 17 => 0, 18 => 0, 19 => 0, 20 => 0, 21 => 0, 22 => 0
);
$this->data = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => NULL, 6 => NULL, 7 => NULL, 8 => NULL, 9 => NULL, 10 => NULL, 11 => NULL, 12 => NULL, 13 => NULL, 14 => NULL, 15 => NULL, 16 => NULL, 17 => NULL, 18 => NULL, 19 => NULL, 20 => NULL, 21 => NULL, 22 => NULL
);
$this->classes = array(
0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => 'texy-hlead', 5 => 'texy-hbody', 6 => 'texy-hlead', 7 => 'texy-hr', 8 => 'texy-hr', 9 => 'texy-hr', 10 => 'texy-hr', 11 => 'texy-hr', 12 => 'texy-text', 13 => 'texy-text', 14 => 'texy-hr', 15 => 'texy-hr', 16 => 'texy-html', 17 => 'texy-html', 18 => 'texy-hr', 19 => 'texy-hr', 20 => 'texy-code', 21 => 'texy-code', 22 => 'texy-hr'
);
$this->keywords = array(
);
}
/**
* Finds a delimiter for state LINE_BODY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter0($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '/---', 1 => '\\---', 2 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter1($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (preg_match('~^\\S+~', $part, $matches)) {
return array(1, $matches[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state LINE_SINGLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter2($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '##', 1 => '**', 2 => '==', 3 => '--'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
return array(4, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state LINE_DOUBLE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter3($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n", 1 => '##', 2 => '==', 3 => '--', 4 => '- -', 5 => '**', 6 => '* *'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
if (0 === strpos($part, $delimiters[4])) {
return array(4, $delimiters[4], $buffer);
}
if (0 === strpos($part, $delimiters[5])) {
return array(5, $delimiters[5], $buffer);
}
if (0 === strpos($part, $delimiters[6])) {
return array(6, $delimiters[6], $buffer);
}
return array(7, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEADER_IN.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter4($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '=', 1 => '#', 2 => '-', 3 => '*', 4 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
return array(5, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEADER_BODY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter5($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '=', 1 => '#', 2 => '-', 3 => '*', 4 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
if ($delimiters[1] === $letter) {
return array(1, $delimiters[1], $buffer);
}
if ($delimiters[2] === $letter) {
return array(2, $delimiters[2], $buffer);
}
if ($delimiters[3] === $letter) {
return array(3, $delimiters[3], $buffer);
}
if ($delimiters[4] === $letter) {
return array(4, $delimiters[4], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HEADER_OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter6($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state HORIZONTAL_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter7($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_IN.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter8($text, $textLength, $textPos)
{
static $delimiters = array(
0 => 'html', 1 => 'code', 2 => 'div', 3 => 'text'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
if (0 === strpos($part, $delimiters[1])) {
return array(1, $delimiters[1], $buffer);
}
if (0 === strpos($part, $delimiters[2])) {
return array(2, $delimiters[2], $buffer);
}
if (0 === strpos($part, $delimiters[3])) {
return array(3, $delimiters[3], $buffer);
}
return array(4, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter9($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
return array(0, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_DUMMY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter10($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
return array(0, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_TEXT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter11($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_TEXT_BODY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter12($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_TEXT_BODY_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter13($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\\---'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
return array(1, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_TEXT_BODY_OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter14($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
return array(0, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_HTML.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter15($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_HTML_BODY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter16($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_HTML_BODY_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter17($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\\---'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
return array(1, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_HTML_BODY_OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter18($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
return array(0, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_CODE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter19($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_CODE_BODY.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter20($text, $textLength, $textPos)
{
static $delimiters = array(
0 => "\n"
);
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
if ($delimiters[0] === $letter) {
return array(0, $delimiters[0], $buffer);
}
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_CODE_BODY_LINE.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter21($text, $textLength, $textPos)
{
static $delimiters = array(
0 => '\\---'
);
$buffer = false;
while ($textPos < $textLength) {
$part = substr($text, $textPos, 10);
$letter = $text[$textPos];
if (0 === strpos($part, $delimiters[0])) {
return array(0, $delimiters[0], $buffer);
}
return array(1, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
/**
* Finds a delimiter for state BLOCK_CODE_BODY_OUT.
*
* @param string $text
* @param string $textLength
* @param string $textPos
* @return array
*/
public function findDelimiter22($text, $textLength, $textPos)
{
$buffer = false;
while ($textPos < $textLength) {
$letter = $text[$textPos];
return array(0, $letter, $buffer);
$buffer .= $letter;
$textPos++;
}
return array(-1, -1, $buffer);
}
}

View File

@ -0,0 +1,308 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* CPP lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Cpp implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Cpp';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'ALPHA' => array('KEYWORD', Generator::BACK),
'//' => array('COMMENT_LINE', Generator::NEXT),
'#' => array('PREPROC', Generator::NEXT),
'NUM' => array('NUMBER', Generator::NEXT),
'DOTNUM' => array('NUMBER', Generator::NEXT),
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'/*' => array('COMMENT_BLOCK', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'KEYWORD' => array(
array(
'!ALNUM_' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_KEYWORD | Generator::STATE_FLAG_RECURSION,
null,
null
),
'NUMBER' => array(
array(
'x' => array('HEXA', Generator::NEXT),
'f' => array(Generator::STATE_SELF, Generator::NEXT),
'DOTNUM' => array(Generator::STATE_SELF, Generator::NEXT),
'ALL' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'cpp-num',
null
),
'HEXA' => array(
array(
'L' => array(Generator::STATE_SELF, Generator::NEXT),
'!HEXNUM' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'cpp-num',
null
),
'PREPROC' => array(
array(
"\\\n" => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
"\\\xd\xa" => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'cpp-preproc',
null
),
'QUOTE_DOUBLE' => array(
array(
'"' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\\' => array(Generator::STATE_SELF, Generator::NEXT),
'\\"' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'cpp-quote',
null
),
'QUOTE_SINGLE' => array(
array(
'\'' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\'' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'cpp-quote',
null
),
'COMMENT_BLOCK' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'*/' => array(Generator::STATE_RETURN, Generator::CURRENT)
),
Generator::STATE_FLAG_RECURSION,
'cpp-comment',
null
),
'COMMENT_LINE' => array(
array(
'LINE' => array(Generator::STATE_RETURN, Generator::BACK),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'cpp-comment',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array();
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array(
'cpp-keywords',
array(
'bool' => 1,
'break' => 1,
'case' => 1,
'catch' => 1,
'char' => 1,
'class' => 1,
'const' => 1,
'const_cast' => 1,
'continue' => 1,
'default' => 1,
'delete' => 1,
'deprecated' => 1,
'dllexport' => 1,
'dllimport' => 1,
'do' => 1,
'double' => 1,
'dynamic_cast' => 1,
'else' => 1,
'enum' => 1,
'explicit' => 1,
'extern' => 1,
'false' => 1,
'float' => 1,
'for' => 1,
'friend' => 1,
'goto' => 1,
'if' => 1,
'inline' => 1,
'int' => 1,
'long' => 1,
'mutable' => 1,
'naked' => 1,
'namespace' => 1,
'new' => 1,
'noinline' => 1,
'noreturn' => 1,
'nothrow' => 1,
'novtable' => 1,
'operator' => 1,
'private' => 1,
'property' => 1,
'protected' => 1,
'public' => 1,
'register' => 1,
'reinterpret_cast' => 1,
'return' => 1,
'selectany' => 1,
'short' => 1,
'signed' => 1,
'sizeof' => 1,
'static' => 1,
'static_cast' => 1,
'struct' => 1,
'switch' => 1,
'template' => 1,
'this' => 1,
'thread' => 1,
'throw' => 1,
'true' => 1,
'try' => 1,
'typedef' => 1,
'typeid' => 1,
'typename' => 1,
'union' => 1,
'unsigned' => 1,
'using' => 1,
'uuid' => 1,
'virtual' => 1,
'void' => 1,
'volatile' => 1,
'__wchar_t' => 1,
'wchar_t' => 1,
'while' => 1,
'__abstract' => 1,
'__alignof' => 1,
'__asm' => 1,
'__assume' => 1,
'__based' => 1,
'__box' => 1,
'__cdecl' => 1,
'__declspec' => 1,
'__delegate' => 1,
'__event' => 1,
'__except' => 1,
'__fastcall' => 1,
'__finally' => 1,
'__forceinline' => 1,
'__gc' => 1,
'__hook' => 1,
'__identifier' => 1,
'__if_exists' => 1,
'__if_not_exists' => 1,
'__inline' => 1,
'__int8' => 1,
'__int16' => 1,
'__int32' => 1,
'__int64' => 1,
'__interface' => 1,
'__leave' => 1,
'__m64' => 1,
'__m128' => 1,
'__m128d' => 1,
'__m128i' => 1,
'__multiple_inheritance' => 1,
'__nogc' => 1,
'__noop' => 1,
'__pin' => 1,
'__property' => 1,
'__raise' => 1,
'__sealed' => 1,
'__single_inheritance' => 1,
'__stdcall' => 1,
'__super' => 1,
'__try_cast' => 1,
'__try' => 1,
'__except' => 1,
'__finally' => 1,
'__unhook' => 1,
'__uuidof' => 1,
'__value' => 1,
'__virtual_inheritance' => 1,
'__w64' => 1
),
Generator::CASE_SENSITIVE
);
}
}

View File

@ -0,0 +1,255 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* CSS lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Css implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Css';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'FUNC' => array('FUNC', Generator::NEXT),
'ALNUM' => array('TAG', Generator::NEXT),
'*' => array('TAG', Generator::NEXT),
'#' => array('ID', Generator::NEXT),
'.' => array('CLASS', Generator::NEXT),
'{' => array('DEF', Generator::NEXT),
'/*' => array('COMMENT', Generator::NEXT),
'@media' => array('MEDIA', Generator::NEXT),
'@' => array('AT_RULE', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'</' => array(Generator::STATE_QUIT, Generator::NEXT),
'PHP' => array('PHP', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'MEDIA' => array(
array(
'PROPERTY' => array('PROPERTY', Generator::NEXT),
':' => array('VALUE', Generator::CURRENT),
';' => array(Generator::STATE_SELF, Generator::CURRENT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
')' => array(Generator::STATE_RETURN, Generator::CURRENT),
'/*' => array('COMMENT', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'css-at-rule',
null
),
'AT_RULE' => array(
array(
'SPACE' => array(Generator::STATE_RETURN, Generator::BACK),
'/*' => array('COMMENT', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'css-at-rule',
null
),
'TAG' => array(
array(
'{' => array(Generator::STATE_RETURN, Generator::NEXT),
',' => array(Generator::STATE_RETURN, Generator::BACK),
'SPACE' => array(Generator::STATE_RETURN, Generator::BACK),
':' => array('PSEUDO', Generator::NEXT),
'/*' => array('COMMENT', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'css-tag',
null
),
'ID' => array(
array(
'{' => array(Generator::STATE_RETURN, Generator::BACK),
',' => array(Generator::STATE_RETURN, Generator::BACK),
'SPACE' => array(Generator::STATE_RETURN, Generator::BACK),
':' => array('PSEUDO', Generator::NEXT),
'/*' => array('COMMENT', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'css-id',
null
),
'CLASS' => array(
array(
'{' => array(Generator::STATE_RETURN, Generator::BACK),
'SPACE' => array(Generator::STATE_RETURN, Generator::BACK),
',' => array(Generator::STATE_RETURN, Generator::BACK),
':' => array('PSEUDO', Generator::NEXT),
'/*' => array('COMMENT', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'css-class',
null
),
'PSEUDO' => array(
array(
'SPACE' => array(Generator::STATE_RETURN, Generator::BACK),
',' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'css-pseudo',
null
),
'DEF' => array(
array(
'PROPERTY' => array('PROPERTY', Generator::NEXT),
':' => array('VALUE', Generator::CURRENT),
';' => array(Generator::STATE_SELF, Generator::CURRENT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'}' => array(Generator::STATE_RETURN, Generator::CURRENT),
'/*' => array('COMMENT', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
null,
null
),
'PROPERTY' => array(
array(
':' => array(Generator::STATE_RETURN, Generator::BACK),
'}' => array(Generator::STATE_RETURN, Generator::BACK),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'/*' => array('COMMENT', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'css-property',
null
),
'VALUE' => array(
array(
'#' => array('COLOR', Generator::NEXT),
';' => array(Generator::STATE_RETURN, Generator::BACK),
'FUNC' => array('FUNC', Generator::NEXT),
')' => array(Generator::STATE_RETURN, Generator::BACK),
'}' => array(Generator::STATE_RETURN, Generator::BACK),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'/*' => array('COMMENT', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'css-value',
null
),
'FUNC' => array(
array(
')' => array(Generator::STATE_RETURN, Generator::CURRENT),
'ALL' => array('VALUE', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'css-func',
null
),
'COLOR' => array(
array(
'!HEXNUM' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'css-color',
null
),
'COMMENT' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'*/' => array(Generator::STATE_RETURN, Generator::CURRENT)
),
Generator::STATE_FLAG_RECURSION,
'css-comment',
null
),
'PHP' => array(
null,
Generator::STATE_FLAG_NEWLEXER,
'xlang',
'Php'
),
Generator::STATE_QUIT => array(
null,
Generator::STATE_FLAG_NEWLEXER,
'html-tag',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array(
'FUNC' => 'preg_match(\'~[a-z]+\\s*\\(~iA\', $text, $matches, 0, $textPos)',
'PROPERTY' => 'preg_match(\'~[-a-z]+~iA\', $text, $matches, 0, $textPos)',
'PHP' => 'preg_match(\'~<\\\\?(php|=|(?!xml))~A\', $text, $matches, 0, $textPos)'
);
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array();
}
}

View File

@ -0,0 +1,218 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* HTML lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Html implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Html';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'<!--' => array('COMMENT', Generator::NEXT),
'PHP' => array('PHP', Generator::NEXT),
'<?' => array(Generator::STATE_SELF, Generator::CURRENT),
'<' => array('TAG', Generator::NEXT),
'&' => array('ENTITY', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'ENTITY' => array(
array(
';' => array('OUT', Generator::CURRENT),
'&' => array('OUT', Generator::CURRENT),
'SPACE' => array('OUT', Generator::CURRENT)
),
Generator::STATE_FLAG_NONE,
'html-entity',
null
),
'TAG' => array(
array(
'>' => array('OUT', Generator::CURRENT),
'SPACE' => array('TAGIN', Generator::NEXT),
'style' => array('STYLE', Generator::CURRENT),
'STYLE' => array('STYLE', Generator::CURRENT),
'script' => array('SCRIPT', Generator::CURRENT),
'SCRIPT' => array('SCRIPT', Generator::CURRENT),
'PHP' => array('PHP', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'html-tag',
null
),
'TAGIN' => array(
array(
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'/>' => array('TAG', Generator::BACK),
'>' => array('TAG', Generator::BACK),
'PHP' => array('PHP', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'html-tagin',
null
),
'STYLE' => array(
array(
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'>' => array('CSS', Generator::NEXT),
'PHP' => array('PHP', Generator::NEXT),
'LINE' => array('TAGIN', Generator::NEXT),
'TAB' => array('TAGIN', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'html-tagin',
null
),
'CSS' => array(
array(
'>' => array(Generator::STATE_RETURN, Generator::CURRENT)
),
Generator::STATE_FLAG_NEWLEXER,
'html-tag',
'Css'
),
'SCRIPT' => array(
array(
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'>' => array('JAVASCRIPT', Generator::NEXT),
'PHP' => array('PHP', Generator::NEXT),
'LINE' => array('TAGIN', Generator::NEXT),
'TAB' => array('TAGIN', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'html-tagin',
null
),
'JAVASCRIPT' => array(
array(
'>' => array(Generator::STATE_RETURN, Generator::CURRENT)
),
Generator::STATE_FLAG_NEWLEXER,
'html-tag',
'Javascript'
),
'QUOTE_DOUBLE' => array(
array(
'"' => array(Generator::STATE_RETURN, Generator::CURRENT),
'PHP' => array('PHP', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'html-quote',
null
),
'QUOTE_SINGLE' => array(
array(
'\'' => array(Generator::STATE_RETURN, Generator::CURRENT),
'PHP' => array('PHP', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'html-quote',
null
),
'COMMENT' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'-->' => array('OUT', Generator::CURRENT),
'PHP' => array('PHP', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'html-comment',
null
),
'PHP' => array(
null,
Generator::STATE_FLAG_NEWLEXER,
'xlang',
'Php'
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array(
'PHP' => 'preg_match(\'~<\\\\?(php|=|(?!xml))~A\', $text, $matches, 0, $textPos)'
);
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array();
}
}

View File

@ -0,0 +1,220 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* HTML lexer without other languages.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class HtmlOnly implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'HtmlOnly';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'<!--' => array('COMMENT', Generator::NEXT),
'<?' => array(Generator::STATE_SELF, Generator::CURRENT),
'<' => array('TAG', Generator::NEXT),
'&' => array('ENTITY', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'ENTITY' => array(
array(
';' => array('OUT', Generator::CURRENT),
'&' => array('OUT', Generator::CURRENT),
'SPACE' => array('OUT', Generator::CURRENT)
),
Generator::STATE_FLAG_NONE,
'html-entity',
null
),
'TAG' => array(
array(
'>' => array('OUT', Generator::CURRENT),
'SPACE' => array('TAGIN', Generator::NEXT),
'style' => array('STYLE', Generator::CURRENT),
'STYLE' => array('STYLE', Generator::CURRENT),
'script' => array('SCRIPT', Generator::CURRENT),
'SCRIPT' => array('SCRIPT', Generator::CURRENT)
),
Generator::STATE_FLAG_NONE,
'html-tag',
null
),
'TAGIN' => array(
array(
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'/>' => array('TAG', Generator::BACK),
'>' => array('TAG', Generator::BACK),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'html-tagin',
null
),
'STYLE' => array(
array(
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'>' => array('STYLE_END', Generator::BACK),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'html-tagin',
null
),
'STYLE_END' => array(
array(
'>' => array('CSS', Generator::CURRENT)
),
Generator::STATE_FLAG_NONE,
'html-tag',
null
),
'CSS' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'</style' => array('TAG', Generator::NEXT),
'</STYLE' => array('TAG', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'SCRIPT' => array(
array(
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'>' => array('SCRIPT_END', Generator::BACK),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'html-tagin',
null
),
'SCRIPT_END' => array(
array(
'>' => array('JAVASCRIPT', Generator::CURRENT)
),
Generator::STATE_FLAG_NONE,
'html-tag',
null
),
'JAVASCRIPT' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'</script' => array('TAG', Generator::NEXT),
'</SCRIPT' => array('TAG', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'QUOTE_DOUBLE' => array(
array(
'"' => array(Generator::STATE_RETURN, Generator::CURRENT)
),
Generator::STATE_FLAG_RECURSION,
'html-quote',
null
),
'QUOTE_SINGLE' => array(
array(
'\'' => array(Generator::STATE_RETURN, Generator::CURRENT)
),
Generator::STATE_FLAG_RECURSION,
'html-quote',
null
),
'COMMENT' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'-->' => array('OUT', Generator::CURRENT)
),
Generator::STATE_FLAG_NONE,
'html-comment',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array();
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array();
}
}

View File

@ -0,0 +1,221 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* Java lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Java implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Java';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'ALPHA' => array('KEYWORD', Generator::BACK),
'NUM' => array('NUMBER', Generator::NEXT),
'DOTNUM' => array('NUMBER', Generator::NEXT),
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'/*' => array('COMMENT_BLOCK', Generator::NEXT),
'//' => array('COMMENT_LINE', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'KEYWORD' => array(
array(
'!ALNUM_' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_KEYWORD | Generator::STATE_FLAG_RECURSION,
null,
null
),
'NUMBER' => array(
array(
'x' => array('HEXA', Generator::NEXT),
'DOTNUM' => array('NUMBER', Generator::NEXT),
'ALL' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'java-num',
null
),
'HEXA' => array(
array(
'!HEXNUM' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'java-num',
null
),
'QUOTE_DOUBLE' => array(
array(
'"' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\\' => array(Generator::STATE_SELF, Generator::NEXT),
'\\"' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'java-quote',
null
),
'QUOTE_SINGLE' => array(
array(
'\'' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\\' => array(Generator::STATE_SELF, Generator::NEXT),
'\\\'' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'java-quote',
null
),
'COMMENT_BLOCK' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'*/' => array(Generator::STATE_RETURN, Generator::CURRENT)
),
Generator::STATE_FLAG_RECURSION,
'java-comment',
null
),
'COMMENT_LINE' => array(
array(
'LINE' => array(Generator::STATE_RETURN, Generator::BACK),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'java-comment',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array();
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array(
'java-keywords',
array(
'abstract' => 1,
'double' => 1,
'int' => 1,
'strictfp' => 1,
'boolean' => 1,
'else' => 1,
'interface' => 1,
'super' => 1,
'break' => 1,
'extends' => 1,
'long' => 1,
'switch' => 1,
'byte' => 1,
'final' => 1,
'native' => 1,
'synchronized' => 1,
'case' => 1,
'finally' => 1,
'new' => 1,
'this' => 1,
'catch' => 1,
'float' => 1,
'package' => 1,
'throw' => 1,
'char' => 1,
'for' => 1,
'private' => 1,
'throws' => 1,
'class' => 1,
'goto' => 1,
'protected' => 1,
'transient' => 1,
'const' => 1,
'if' => 1,
'public' => 1,
'try' => 1,
'continue' => 1,
'implements' => 1,
'return' => 1,
'void' => 1,
'default' => 1,
'import' => 1,
'short' => 1,
'volatile' => 1,
'do' => 1,
'instanceof' => 1,
'static' => 1,
'while' => 1
),
Generator::CASE_SENSITIVE
);
}
}

View File

@ -0,0 +1,260 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* Javascript lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Javascript implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Javascript';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'ALPHA' => array('KEYWORD', Generator::BACK),
'NUM' => array('NUMBER', Generator::NEXT),
'DOTNUM' => array('NUMBER', Generator::NEXT),
'.' => array('KEYWORD', Generator::CURRENT),
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'/*' => array('COMMENT_BLOCK', Generator::NEXT),
'//' => array('COMMENT_LINE', Generator::NEXT),
'REGEXP' => array('REGEXP', Generator::NEXT),
'PHP' => array('PHP', Generator::NEXT),
'</' => array(Generator::STATE_QUIT, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'js-out',
null
),
'KEYWORD' => array(
array(
'!ALNUM_' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_KEYWORD | Generator::STATE_FLAG_RECURSION,
'js-out',
null
),
'NUMBER' => array(
array(
'x' => array('HEXA', Generator::NEXT),
'DOTNUM' => array('NUMBER', Generator::NEXT),
'ALL' => array(Generator::STATE_RETURN, Generator::BACK),
),
Generator::STATE_FLAG_RECURSION,
'js-num',
null
),
'HEXA' => array(
array(
'!HEXNUM' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'js-num',
null
),
'QUOTE_DOUBLE' => array(
array(
'"' => array(Generator::STATE_RETURN, Generator::CURRENT),
'PHP' => array('PHP', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'js-quote',
null
),
'QUOTE_SINGLE' => array(
array(
'\'' => array(Generator::STATE_RETURN, Generator::CURRENT),
'PHP' => array('PHP', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'js-quote',
null
),
'COMMENT_BLOCK' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'*/' => array(Generator::STATE_RETURN, Generator::CURRENT),
'PHP' => array('PHP', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'js-comment',
null
),
'COMMENT_LINE' => array(
array(
'LINE' => array(Generator::STATE_RETURN, Generator::BACK),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'PHP' => array('PHP', Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'js-comment',
null
),
'REGEXP' => array(
array(
'ALL' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'js-quote',
null
),
'PHP' => array(
null,
Generator::STATE_FLAG_NEWLEXER,
'xlang',
'Php'
),
Generator::STATE_QUIT => array(
null,
Generator::STATE_FLAG_NEWLEXER,
'html-tag',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array(
'REGEXP' => 'preg_match(\'~/.*?[^\\\\\\\\]/[gim]*~A\', $text, $matches, 0, $textPos)',
'PHP' => 'preg_match(\'~<\\\\?(php|=|(?!xml))~A\', $text, $matches, 0, $textPos)'
);
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array(
'js-keywords',
array(
'abstract' => 1,
'boolean' => 1,
'break' => 1,
'byte' => 1,
'case' => 1,
'catch' => 1,
'char' => 1,
'class' => 1,
'const' => 1,
'continue' => 1,
'debugger' => 1,
'default' => 1,
'delete' => 1,
'do' => 1,
'double' => 1,
'else' => 1,
'enum' => 1,
'export' => 1,
'extends' => 1,
'false' => 1,
'final' => 1,
'finally' => 1,
'float' => 1,
'for' => 1,
'function' => 1,
'goto' => 1,
'if' => 1,
'implements' => 1,
'import' => 1,
'in' => 1,
'instanceof' => 1,
'int' => 1,
'interface' => 1,
'long' => 1,
'native' => 1,
'new' => 1,
'null' => 1,
'package' => 1,
'private' => 1,
'protected' => 1,
'public' => 1,
'return' => 1,
'short' => 1,
'static' => 1,
'super' => 1,
'switch' => 1,
'synchronized' => 1,
'this' => 1,
'throw' => 1,
'throws' => 1,
'transient' => 1,
'true' => 1,
'try' => 1,
'typeof' => 1,
'var' => 1,
'void' => 1,
'volatile' => 1,
'while' => 1,
'with' => 1,
'document' => 2,
'getAttribute' => 2,
'getElementsByTagName' => 2,
'getElementById' => 2,
),
Generator::CASE_SENSITIVE
);
}
}

View File

@ -0,0 +1,92 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* Minimal lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Minimal implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Minimal';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array();
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array();
}
}

View File

@ -0,0 +1,230 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* Neon lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Neon implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Neon';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'SECTION' => array('SECTION', Generator::NEXT),
'KEY' => array('KEY', Generator::NEXT),
'#' => array('COMMENT', Generator::NEXT),
'-' => array('LIST', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'SECTION' => array(
array(
'<' => array('SEPARATOR', Generator::NEXT),
':' => array('SEPARATOR', Generator::NEXT),
'SECTION' => array(Generator::STATE_SELF, Generator::NEXT),
'KEY' => array('KEY', Generator::NEXT),
'-' => array('LIST', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'neon-section',
null
),
'KEY' => array(
array(
':' => array('SEPARATOR', Generator::NEXT),
'=' => array('SEPARATOR', Generator::NEXT),
'ALL' => array('VALUE', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'neon-key',
null
),
'LIST' => array(
array(
'ALL' => array('VALUE', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'neon-sep',
null
),
'VALUE' => array(
array(
'LINE' => array('OUT', Generator::NEXT),
'KEY' => array('KEY', Generator::NEXT),
'#' => array('COMMENT', Generator::NEXT),
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'[' => array('SEPARATOR', Generator::NEXT),
']' => array('SEPARATOR', Generator::NEXT),
'{' => array('SEPARATOR', Generator::NEXT),
'}' => array('SEPARATOR', Generator::NEXT),
'=' => array('SEPARATOR', Generator::NEXT),
',' => array('SEPARATOR', Generator::NEXT),
':' => array('SEPARATOR', Generator::NEXT),
'TEXT' => array('TEXT', Generator::NEXT),
'NUM' => array('NUMBER', Generator::NEXT),
'DOTNUM' => array('NUMBER', Generator::NEXT),
'VARIABLE' => array('VARIABLE', Generator::NEXT),
'@' => array('REFERENCE', Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'neon-value',
null
),
'TEXT' => array(
array(
'VARIABLE' => array('VARIABLE', Generator::NEXT),
'#' => array('COMMENT', Generator::NEXT),
'LINE' => array('OUT', Generator::NEXT),
),
Generator::STATE_FLAG_NONE,
'neon-value',
null
),
'SEPARATOR' => array(
array(
'ALL' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'neon-sep',
null
),
'COMMENT' => array(
array(
'LINE' => array('OUT', Generator::BACK),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'neon-comment',
null
),
'QUOTE_DOUBLE' => array(
array(
'"' => array(Generator::STATE_RETURN, Generator::CURRENT),
'VARIABLE' => array('VARIABLE', Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'neon-quote',
null
),
'QUOTE_SINGLE' => array(
array(
'\'' => array(Generator::STATE_RETURN, Generator::CURRENT),
'VARIABLE' => array('VARIABLE', Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'neon-quote',
null
),
'VARIABLE' => array(
array(
'%' => array(Generator::STATE_RETURN, Generator::CURRENT)
),
Generator::STATE_FLAG_RECURSION,
'neon-var',
null
),
'NUMBER' => array(
array(
'DOTNUM' => array(Generator::STATE_SELF, Generator::NEXT),
'ALL' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'neon-num',
null
),
'REFERENCE' => array(
array(
'!ALNUM_' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'neon-ref',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array(
'SECTION' => 'preg_match(\'~[\\\\w.]+(?=(\\\\s*<\\\\s*[\\\\w.]+)?\\\\s*:\\\\s*\\n)~Ai\', $text, $matches, 0, $textPos)',
'KEY' => 'preg_match(\'~[\\\\w.]+(?=\\\\s*(?::|=))~Ai\', $text, $matches, 0, $textPos)',
'VARIABLE' => 'preg_match(\'~%\\\\w+(?=%)~Ai\', $text, $matches, 0, $textPos)',
'TEXT' => 'preg_match(\'~[a-z](?![,\\\\]}#\\n])~Ai\', $text, $matches, 0, $textPos)'
);
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,502 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* Python lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2006 Drekin
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Python implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Python';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'ALPHA' => array('KEYWORD', Generator::BACK),
'_' => array('KEYWORD', Generator::BACK),
'\'\'\'' => array('DOCSTRING1', Generator::NEXT),
'"""' => array('DOCSTRING2', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'#' => array('COMMENT_LINE', Generator::NEXT),
'NUM' => array('NUMBER', Generator::NEXT),
'DOTNUM' => array('NUMBER', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'KEYWORD' => array(
array(
'!ALNUM_' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_KEYWORD | Generator::STATE_FLAG_RECURSION,
null,
null
),
'DOCSTRING1' => array(
array(
'\'\'\'' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\\' => array(Generator::STATE_SELF, Generator::NEXT),
'\\\'\'\'' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'py-docstring',
null
),
'DOCSTRING2' => array(
array(
'"""' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\\' => array(Generator::STATE_SELF, Generator::NEXT),
'\\"""' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'py-docstring',
null
),
'QUOTE_SINGLE' => array(
array(
'\'' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\\' => array(Generator::STATE_SELF, Generator::NEXT),
'\\\'' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'py-quote',
null
),
'QUOTE_DOUBLE' => array(
array(
'"' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\\' => array(Generator::STATE_SELF, Generator::NEXT),
'\\"' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'py-quote',
null
),
'COMMENT_LINE' => array(
array(
'LINE' => array(Generator::STATE_RETURN, Generator::BACK),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'py-comment',
null
),
'NUMBER' => array(
array(
'DOTNUM' => array('FRACTION', Generator::NEXT),
'l' => array(Generator::STATE_RETURN, Generator::CURRENT),
'L' => array(Generator::STATE_RETURN, Generator::CURRENT),
'j' => array(Generator::STATE_RETURN, Generator::CURRENT),
'J' => array(Generator::STATE_RETURN, Generator::CURRENT),
'e-' => array('EXPONENT', Generator::NEXT),
'e+' => array('EXPONENT', Generator::NEXT),
'e' => array('EXPONENT', Generator::NEXT),
'x' => array('HEXA', Generator::NEXT),
'X' => array('HEXA', Generator::NEXT),
'ALL' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'py-num',
null
),
'FRACTION' => array(
array(
'j' => array(Generator::STATE_RETURN, Generator::CURRENT),
'J' => array(Generator::STATE_RETURN, Generator::CURRENT),
'e-' => array('EXPONENT', Generator::NEXT),
'e+' => array('EXPONENT', Generator::NEXT),
'e' => array('EXPONENT', Generator::NEXT),
'ALL' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'py-num',
null
),
'EXPONENT' => array(
array(
'j' => array(Generator::STATE_RETURN, Generator::CURRENT),
'J' => array(Generator::STATE_RETURN, Generator::CURRENT),
'!NUM' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'py-num',
null
),
'HEXA' => array(
array(
'L' => array(Generator::STATE_RETURN, Generator::CURRENT),
'l' => array(Generator::STATE_RETURN, Generator::CURRENT),
'!HEXNUM' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'py-num',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array();
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array(
'py-keyword',
array(
'and' => 1,
'as' => 1,
'assert' => 1,
'break' => 1,
'class' => 1,
'continue' => 1,
'def' => 1,
'del' => 1,
'elif' => 1,
'else' => 1,
'except' => 1,
'exec' => 1,
'finally' => 1,
'for' => 1,
'from' => 1,
'global' => 1,
'if' => 1,
'import' => 1,
'in' => 1,
'is' => 1,
'lambda' => 1,
'not' => 1,
'or' => 1,
'pass' => 1,
'print' => 1,
'raise' => 1,
'return' => 1,
'try' => 1,
'while' => 1,
'with' => 1,
'yield' => 1,
'abs' => 2,
'all' => 2,
'any' => 2,
'apply' => 2,
'basestring' => 2,
'bool' => 2,
'buffer' => 2,
'callable' => 2,
'chr' => 2,
'classmethod' => 2,
'cmp' => 2,
'coerce' => 2,
'compile' => 2,
'complex' => 2,
'delattr' => 2,
'dict' => 2,
'dir' => 2,
'divmod' => 2,
'enumerate' => 2,
'eval' => 2,
'execfile' => 2,
'file' => 2,
'filter' => 2,
'float' => 2,
'frozenset' => 2,
'getattr' => 2,
'globals' => 2,
'hasattr' => 2,
'hash' => 2,
'hex' => 2,
'id' => 2,
'input' => 2,
'int' => 2,
'intern' => 2,
'isinstance' => 2,
'issubclass' => 2,
'iter' => 2,
'len' => 2,
'list' => 2,
'locals' => 2,
'long' => 2,
'map' => 2,
'max' => 2,
'min' => 2,
'object' => 2,
'oct' => 2,
'open' => 2,
'ord' => 2,
'pow' => 2,
'property' => 2,
'range' => 2,
'raw_input' => 2,
'reduce' => 2,
'reload' => 2,
'repr' => 2,
'reversed' => 2,
'round' => 2,
'set' => 2,
'setattr' => 2,
'slice' => 2,
'sorted' => 2,
'staticmethod' => 2,
'str' => 2,
'sum' => 2,
'super' => 2,
'tuple' => 2,
'type' => 2,
'unichr' => 2,
'unicode' => 2,
'vars' => 2,
'xrange' => 2,
'zip' => 2,
'ArithmeticError' => 3,
'AssertionError' => 3,
'AttributeError' => 3,
'BaseException' => 3,
'DeprecationWarning' => 3,
'EOFError' => 3,
'Ellipsis' => 3,
'EnvironmentError' => 3,
'Exception' => 3,
'FloatingPointError' => 3,
'FutureWarning' => 3,
'GeneratorExit' => 3,
'IOError' => 3,
'ImportError' => 3,
'ImportWarning' => 3,
'IndentationError' => 3,
'IndexError' => 3,
'KeyError' => 3,
'KeyboardInterrupt' => 3,
'LookupError' => 3,
'MemoryError' => 3,
'NameError' => 3,
'NotImplemented' => 3,
'NotImplementedError' => 3,
'OSError' => 3,
'OverflowError' => 3,
'OverflowWarning' => 3,
'PendingDeprecationWarning' => 3,
'ReferenceError' => 3,
'RuntimeError' => 3,
'RuntimeWarning' => 3,
'StandardError' => 3,
'StopIteration' => 3,
'SyntaxError' => 3,
'SyntaxWarning' => 3,
'SystemError' => 3,
'SystemExit' => 3,
'TabError' => 3,
'TypeError' => 3,
'UnboundLocalError' => 3,
'UnicodeDecodeError' => 3,
'UnicodeEncodeError' => 3,
'UnicodeError' => 3,
'UnicodeTranslateError' => 3,
'UnicodeWarning' => 3,
'UserWarning' => 3,
'ValueError' => 3,
'Warning' => 3,
'WindowsError' => 3,
'ZeroDivisionError' => 3,
'BufferType' => 3,
'BuiltinFunctionType' => 3,
'BuiltinMethodType' => 3,
'ClassType' => 3,
'CodeType' => 3,
'ComplexType' => 3,
'DictProxyType' => 3,
'DictType' => 3,
'DictionaryType' => 3,
'EllipsisType' => 3,
'FileType' => 3,
'FloatType' => 3,
'FrameType' => 3,
'FunctionType' => 3,
'GeneratorType' => 3,
'InstanceType' => 3,
'IntType' => 3,
'LambdaType' => 3,
'ListType' => 3,
'LongType' => 3,
'MethodType' => 3,
'ModuleType' => 3,
'NoneType' => 3,
'ObjectType' => 3,
'SliceType' => 3,
'StringType' => 3,
'StringTypes' => 3,
'TracebackType' => 3,
'TupleType' => 3,
'TypeType' => 3,
'UnboundMethodType' => 3,
'UnicodeType' => 3,
'XRangeType' => 3,
'False' => 3,
'None' => 3,
'True' => 3,
'__abs__' => 3,
'__add__' => 3,
'__all__' => 3,
'__author__' => 3,
'__bases__' => 3,
'__builtins__' => 3,
'__call__' => 3,
'__class__' => 3,
'__cmp__' => 3,
'__coerce__' => 3,
'__contains__' => 3,
'__debug__' => 3,
'__del__' => 3,
'__delattr__' => 3,
'__delitem__' => 3,
'__delslice__' => 3,
'__dict__' => 3,
'__div__' => 3,
'__divmod__' => 3,
'__doc__' => 3,
'__eq__' => 3,
'__file__' => 3,
'__float__' => 3,
'__floordiv__' => 3,
'__future__' => 3,
'__ge__' => 3,
'__getattr__' => 3,
'__getattribute__' => 3,
'__getitem__' => 3,
'__getslice__' => 3,
'__gt__' => 3,
'__hash__' => 3,
'__hex__' => 3,
'__iadd__' => 3,
'__import__' => 3,
'__imul__' => 3,
'__init__' => 3,
'__int__' => 3,
'__invert__' => 3,
'__iter__' => 3,
'__le__' => 3,
'__len__' => 3,
'__long__' => 3,
'__lshift__' => 3,
'__lt__' => 3,
'__members__' => 3,
'__metaclass__' => 3,
'__mod__' => 3,
'__mro__' => 3,
'__mul__' => 3,
'__name__' => 3,
'__ne__' => 3,
'__neg__' => 3,
'__new__' => 3,
'__nonzero__' => 3,
'__oct__' => 3,
'__or__' => 3,
'__path__' => 3,
'__pos__' => 3,
'__pow__' => 3,
'__radd__' => 3,
'__rdiv__' => 3,
'__rdivmod__' => 3,
'__reduce__' => 3,
'__repr__' => 3,
'__rfloordiv__' => 3,
'__rlshift__' => 3,
'__rmod__' => 3,
'__rmul__' => 3,
'__ror__' => 3,
'__rpow__' => 3,
'__rrshift__' => 3,
'__rsub__' => 3,
'__rtruediv__' => 3,
'__rxor__' => 3,
'__setattr__' => 3,
'__setitem__' => 3,
'__setslice__' => 3,
'__self__' => 3,
'__slots__' => 3,
'__str__' => 3,
'__sub__' => 3,
'__truediv__' => 3,
'__version__' => 3,
'__xor__' => 3
),
Generator::CASE_SENSITIVE
);
}
}

View File

@ -0,0 +1,557 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* SQL lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (C) 2005 Matěj 'Finwë' Humpál
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Sql implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Sql';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'OUT';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'OUT' => array(
array(
'ALPHA' => array('FUNCTION', Generator::BACK),
'NUM' => array('NUMBER', Generator::NEXT),
'DOTNUM' => array('NUMBER', Generator::NEXT),
'/*' => array('COMMENT_BLOCK', Generator::NEXT) ,
'//' => array('COMMENT_LINE', Generator::NEXT),
'#' => array('COMMENT_LINE', Generator::NEXT),
'--' => array('COMMENT_LINE', Generator::NEXT),
'"' => array('QUOTE_DOUBLE', Generator::NEXT),
'\'' => array('QUOTE_SINGLE', Generator::NEXT),
'`' => array('QUOTE_BACK_APOSTROPHE', Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_KEYWORD,
null,
null
),
'FUNCTION' => array(
array(
'!ALNUM_' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_KEYWORD | Generator::STATE_FLAG_RECURSION,
null,
null
),
'COMMENT_BLOCK' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT),
'*/' => array(Generator::STATE_RETURN, Generator::CURRENT),
),
Generator::STATE_FLAG_RECURSION,
'sql-comment',
null
),
'COMMENT_LINE' => array(
array(
'LINE' => array(Generator::STATE_RETURN, Generator::BACK),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'sql-comment',
null
),
'QUOTE_DOUBLE' => array(
array(
'"' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\"' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'sql-value',
null
),
'QUOTE_SINGLE' => array(
array(
'\'' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\\'' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'sql-value',
null
),
'QUOTE_BACK_APOSTROPHE' => array(
array(
'`' => array(Generator::STATE_RETURN, Generator::CURRENT),
'\\`' => array(Generator::STATE_SELF, Generator::NEXT),
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'TAB' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'sql-value',
null
),
'NUMBER' => array(
array(
'x' => array('HEXA', Generator::NEXT),
'DOTNUM' => array(Generator::STATE_SELF, Generator::NEXT),
'ALL' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_RECURSION,
'sql-num',
null
),
'HEXA' => array(
array(
'!HEXNUM' => array(Generator::STATE_RETURN, Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'sql-num',
null
),
'OPTION' => array(
array(
'BLOB' => array(Generator::STATE_SELF, Generator::NEXT),
'TEXT' => array(Generator::STATE_SELF, Generator::CURRENT),
'INTEGER' => array(Generator::STATE_SELF, Generator::NEXT),
'CHAR' => array(Generator::STATE_SELF, Generator::NEXT),
'TEXT' => array(Generator::STATE_SELF, Generator::NEXT),
'DATE' => array(Generator::STATE_SELF, Generator::NEXT)
),
Generator::STATE_FLAG_RECURSION,
'sql-option',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array();
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array(
'sql-keyword',
array(
'a' => 1,
'abs' => 2,
'acos' => 2,
'add' => 1,
'add_months' => 1,
'after' => 1,
'all' => 1,
'alter' => 1,
'an' => 1,
'and' => 1,
'any' => 1,
'array' => 1,
'as' => 1,
'asc' => 1,
'ascii' => 2,
'asin' => 2,
'atan' => 2,
'atan2' => 2,
'avg' => 2,
'before' => 1,
'begin' => 1,
'between' => 1,
'bigint' => 3,
'binary' => 1,
'bind' => 1,
'binding' => 1,
'bit' => 1,
'blob' => 3,
'boolean' => 3,
'by' => 1,
'call' => 1,
'cascade' => 1,
'case' => 1,
'cast' => 1,
'ceiling' => 2,
'char' => 3,
'char_length' => 2,
'character' => 2,
'character_length' => 2,
'chartorowid' => 1,
'check' => 1,
'chr' => 1,
'cleanup' => 1,
'close' => 1,
'clustered' => 1,
'coalesce' => 1,
'colgroup' => 1,
'collate' => 1,
'commit' => 1,
'complex' => 1,
'compress' => 1,
'concat' => 2,
'connect' => 1,
'constraint' => 1,
'contains' => 1,
'continue' => 1,
'convert' => 1,
'cos' => 2,
'count' => 2,
'create' => 1,
'cross' => 1,
'curdate' => 2,
'current' => 1,
'cursor' => 1,
'curtime' => 2,
'cvar' => 1,
'database' => 1,
'datapages' => 1,
'date' => 2,
'dayname' => 2,
'dayofmonth' => 2,
'dayofweek' => 2,
'dayofyear' => 2,
'db_name' => 1,
'dba' => 1,
'dec' => 3,
'decimal' => 3,
'declaration' => 1,
'declare' => 1,
'decode' => 2,
'default' => 1,
'definition' => 1,
'degrees' => 1,
'delete' => 1,
'desc' => 1,
'describe' => 1,
'descriptor' => 1,
'dhtype' => 1,
'difference' => 1,
'distinct' => 1,
'double' => 3,
'drop' => 1,
'each' => 1,
'else' => 1,
'end' => 1,
'escape' => 1,
'exclusive' => 1,
'exec' => 1,
'execute' => 1,
'exists' => 1,
'exit' => 1,
'exp' => 2,
'explicit' => 1,
'extent' => 1,
'fetch' => 1,
'field file' => 1,
'float' => 3,
'floor' => 2,
'for' => 1,
'foreign' => 1,
'found' => 1,
'from' => 1,
'full' => 1,
'go' => 1,
'goto' => 1,
'grant' => 1,
'greatest' => 2,
'group' => 1,
'hash' => 1,
'having' => 1,
'hour' => 1,
'identified' => 1,
'ifnull' => 2,
'immediate' => 1,
'in' => 1,
'index' => 1,
'indexpages' => 1,
'indicator' => 1,
'initcap' => 1,
'inner' => 1,
'inout' => 1,
'input' => 1,
'insert' => 1,
'instr' => 1,
'int' => 3,
'integer' => 3,
'interface' => 1,
'intersect' => 1,
'into' => 1,
'is' => 1,
'isnull' => 2,
'java_object' => 3,
'join' => 1,
'key' => 1,
'last_day' => 2,
'lcase' => 2,
'least' => 2,
'left' => 2,
'length' => 2,
'like' => 1,
'link' => 1,
'list' => 1,
'locate' => 1,
'lock' => 1,
'log' => 2,
'log10' => 2,
'long' => 1,
'longblob' => 3,
'longtext' => 3,
'longvarbinary' => 3,
'longvarchar' => 3,
'lower' => 1,
'lpad' => 1,
'ltrim' => 2,
'lvarbinary' => 1,
'lvarchar' => 1,
'main' => 1,
'max' => 2,
'mediumint' => 3,
'metadata_only' => 1,
'min' => 2,
'minus' => 2,
'minute' => 2,
'mod' => 2,
'mode' => 1,
'modify' => 1,
'money' => 1,
'month' => 2,
'monthname' => 2,
'months_between' => 2,
'name' => 1,
'national' => 1,
'natural' => 1,
'nchar' => 1,
'newrow' => 1,
'next_day' => 1,
'nocompress' => 1,
'not' => 1,
'now' => 1,
'nowait' => 1,
'null' => 1,
'nullif' => 1,
'nullvalue' => 1,
'number' => 1,
'numeric' => 1,
'nvl' => 1,
'object_id' => 1,
'odbc_convert' => 1,
'odbcinfo' => 1,
'of' => 1,
'oldrow' => 1,
'on' => 1,
'open' => 1,
'option' => 1,
'or' => 1,
'order' => 1,
'out' => 1,
'outer' => 1,
'output' => 1,
'pctfree' => 1,
'pi' => 1,
'power' => 1,
'precision' => 1,
'prefix' => 1,
'prepare' => 1,
'primary' => 1,
'privileges' => 1,
'procedure' => 1,
'public' => 1,
'quarter' => 2,
'radians' => 2,
'rand' => 2,
'range' => 2,
'raw' => 1,
'real' => 3,
'record' => 1,
'references' => 1,
'referencing' => 1,
'rename' => 1,
'repeat' => 2,
'replace' => 1,
'resource' => 1,
'restrict' => 1,
'result' => 1,
'return' => 2,
'revoke' => 2,
'right' => 2,
'rollback' => 1,
'row' => 2,
'rowid' => 2,
'rowidtochar' => 2,
'rownum' => 2,
'rpad' => 2,
'rtrim' => 2,
'searched_case' => 1,
'second' => 1,
'section' => 1,
'select' => 1,
'service' => 1,
'set' => 1,
'share' => 1,
'short' => 1,
'sign' => 1,
'simple_case' => 1,
'sin' => 2,
'size' => 2,
'smallint' => 3,
'some' => 1,
'soundex' => 1,
'space' => 1,
'sql' => 1,
'sql_bigint' => 3,
'sql_binary' => 3,
'sql_bit' => 3,
'sql_char' => 3,
'sql_date' => 3,
'sql_decimal' => 3,
'sql_double' => 3,
'sql_float' => 1,
'sql_integer' => 3,
'sql_longvarbinary' => 3,
'sql_longvarchar' => 3,
'sql_numeric' => 3,
'sql_real' => 3,
'sql_smallint' => 3,
'sql_time' => 3,
'sql_timestamp' => 1,
'sql_tinyint' => 3,
'sql_tsi_day' => 3,
'sql_tsi_frac_second' => 3,
'sql_tsi_hour' => 3,
'sql_tsi_minute' => 3,
'sql_tsi_month' => 3,
'sql_tsi_quarter' => 3,
'sql_tsi_second' => 3,
'sql_tsi_week' => 3,
'sql_tsi_year' => 3,
'sql_varbinary' => 3,
'sql_varchar' => 3,
'sqlerror' => 1,
'sqlwarning' => 1,
'sqrt' => 1,
'start' => 1,
'statement' => 1,
'statistics' => 1,
'stop' => 1,
'storage_attributes' => 1,
'storage_manager' => 1,
'store_in_progress' => 1,
'string' => 3,
'substr' => 2,
'substring' => 2,
'suffix' => 2,
'sum' => 2,
'suser_name' => 2,
'synonym' => 2,
'sysdate' => 2,
'systime' => 2,
'systimestamp' => 2,
'table' => 1,
'tan' => 2,
'text' => 3,
'then' => 1,
'time' => 2,
'timeout' => 2,
'timestamp' => 3,
'timestampadd' => 2,
'timestampdiff' => 2,
'tinyint' => 3,
'to' => 2,
'to_char' => 2,
'to_date' => 2,
'to_number' => 2,
'to_time' => 2,
'to_timestamp' => 2,
'top' => 1,
'tpe' => 1,
'tran' => 1,
'transaction' => 1,
'translate' => 1,
'trigger' => 1,
'type' => 1,
'ucase' => 1,
'uid' => 1,
'union' => 1,
'unique' => 1,
'unsigned' => 1,
'update' => 1,
'upper' => 1,
'user' => 1,
'user_id' => 1,
'user_name' => 1,
'using' => 1,
'uuid' => 1,
'values' => 1,
'varbinary' => 1,
'varchar' => 3,
'variables' => 1,
'varying' => 1,
'version' => 1,
'view' => 1,
'week' => 2,
'when' => 1,
'whenever' => 1,
'where' => 1,
'with' => 1,
'work' => 1,
'year' => 1
),
Generator::CASE_INSENSITIVE
);
}
}

View File

@ -0,0 +1,297 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Lexer;
use FSHL, FSHL\Generator;
/**
* Texy lexer.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Texy implements FSHL\Lexer
{
/**
* Returns language name.
*
* @return string
*/
public function getLanguage()
{
return 'Texy';
}
/**
* Returns initial state.
*
* @return string
*/
public function getInitialState()
{
return 'LINE_SINGLE';
}
/**
* Returns states.
*
* @return array
*/
public function getStates()
{
return array(
'LINE_BODY' => array(
array(
'/---' => array('BLOCK_IN', Generator::NEXT),
'\---' => array('BLOCK_OUT', Generator::NEXT),
'LINE' => array('LINE', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'LINE' => array(
array(
'LINE' => array('LINE_DOUBLE', Generator::NEXT),
'!SPACE' => array('LINE_SINGLE', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'LINE_SINGLE' => array(
array(
'##' => array('HEADER_IN', Generator::NEXT),
'**' => array('HEADER_IN', Generator::NEXT),
'==' => array('HEADER_IN', Generator::NEXT),
'--' => array('HEADER_IN', Generator::NEXT),
'ALL' => array('LINE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
null,
null
),
'LINE_DOUBLE' => array(
array(
'LINE' => array(Generator::STATE_SELF, Generator::NEXT),
'##' => array('HEADER_IN', Generator::NEXT),
'==' => array('HEADER_IN', Generator::NEXT),
'--' => array('HORIZONTAL_LINE', Generator::NEXT),
'- -' => array('HORIZONTAL_LINE', Generator::NEXT),
'**' => array('HORIZONTAL_LINE', Generator::NEXT),
'* *' => array('HORIZONTAL_LINE', Generator::NEXT),
'ALL' => array('LINE_BODY', Generator::BACK)
),
'texy-err',
null,
null
),
'HEADER_IN' => array(
array(
'=' => array('HEADER_IN', Generator::NEXT),
'#' => array('HEADER_IN', Generator::NEXT),
'-' => array('HEADER_IN', Generator::NEXT),
'*' => array('HEADER_IN', Generator::NEXT),
'LINE' => array('LINE_DOUBLE', Generator::NEXT),
'ALL' => array('HEADER_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hlead',
null
),
'HEADER_BODY' => array(
array(
'=' => array('HEADER_OUT', Generator::NEXT),
'#' => array('HEADER_OUT', Generator::NEXT),
'-' => array('HEADER_OUT', Generator::NEXT),
'*' => array('HEADER_OUT', Generator::NEXT),
'LINE' => array('LINE_DOUBLE', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'texy-hbody',
null
),
'HEADER_OUT' => array(
array(
'LINE' => array('LINE_DOUBLE', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'texy-hlead',
null
),
'HORIZONTAL_LINE' => array(
array(
'LINE' => array('LINE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_IN' => array(
array(
'html' => array('BLOCK_HTML', Generator::NEXT),
'code' => array('BLOCK_CODE', Generator::NEXT),
'div' => array('BLOCK_DUMMY', Generator::NEXT),
'text' => array('BLOCK_TEXT', Generator::NEXT),
'ALL' => array('LINE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_OUT' => array(
array(
'ALL' => array('LINE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_DUMMY' => array(
array(
'ALL' => array('LINE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_TEXT' => array(
array(
'LINE' => array('BLOCK_TEXT_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_TEXT_BODY' => array(
array(
'LINE' => array('BLOCK_TEXT_BODY_LINE', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'texy-text',
null
),
'BLOCK_TEXT_BODY_LINE' => array(
array(
'\---' => array('BLOCK_TEXT_BODY_OUT', Generator::NEXT),
'ALL' => array('BLOCK_TEXT_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-text',
null
),
'BLOCK_TEXT_BODY_OUT' => array(
array(
'ALL' => array('LINE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_HTML' => array(
array(
'LINE' => array('BLOCK_HTML_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_HTML_BODY' => array(
array(
'LINE' => array('BLOCK_HTML_BODY_LINE', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'texy-html',
null
),
'BLOCK_HTML_BODY_LINE' => array(
array(
'\---' => array('BLOCK_HTML_BODY_OUT', Generator::NEXT),
'ALL' => array('BLOCK_HTML_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-html',
null
),
'BLOCK_HTML_BODY_OUT' => array(
array(
'ALL' => array('LINE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_CODE' => array(
array(
'LINE' => array('BLOCK_CODE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
),
'BLOCK_CODE_BODY' => array(
array(
'LINE' => array('BLOCK_CODE_BODY_LINE', Generator::NEXT)
),
Generator::STATE_FLAG_NONE,
'texy-code',
null
),
'BLOCK_CODE_BODY_LINE' => array(
array(
'\---' => array('BLOCK_CODE_BODY_OUT', Generator::NEXT),
'ALL' => array('BLOCK_CODE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-code',
null
),
'BLOCK_CODE_BODY_OUT' => array(
array(
'ALL' => array('LINE_BODY', Generator::BACK)
),
Generator::STATE_FLAG_NONE,
'texy-hr',
null
)
);
}
/**
* Returns special delimiters.
*
* @return array
*/
public function getDelimiters()
{
return array();
}
/**
* Returns keywords.
*
* @return array
*/
public function getKeywords()
{
return array();
}
}

View File

@ -0,0 +1,48 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL;
/**
* Output interface.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
interface Output
{
/**
* Outputs a template part.
*
* @param string $word
* @param string $class
* @return string
*/
public function template($word, $class);
/**
* Outputs a keyword.
*
* @param string $word
* @param string $class
* @return string
*/
public function keyword($word, $class);
}

View File

@ -0,0 +1,89 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Output;
use FSHL;
/**
* HTML output.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class Html implements FSHL\Output
{
/**
* Last used class.
*
* @var string
*/
private $lastClass = null;
/**
* Outputs a template part.
*
* @param string $part
* @param string $class
* @return string
*/
public function template($part, $class)
{
$output = '';
if ($this->lastClass !== $class) {
if (null !== $this->lastClass) {
$output .= '</span>';
}
if (null !== $class) {
$output .= '<span class="' . $class . '">';
}
$this->lastClass = $class;
}
return $output . htmlspecialchars($part, ENT_COMPAT, 'UTF-8');
}
/**
* Outputs a keyword.
*
* @param string $part
* @param string $class
* @return string
*/
public function keyword($part, $class)
{
$output = '';
if ($this->lastClass !== $class) {
if (null !== $this->lastClass) {
$output .= '</span>';
}
if (null !== $class) {
$output .= '<span class="' . $class . '">';
}
$this->lastClass = $class;
}
return $output . htmlspecialchars($part, ENT_COMPAT, 'UTF-8');
}
}

View File

@ -0,0 +1,123 @@
<?php
/**
* FSHL 2.1.0 | Fast Syntax HighLighter |
* -----------------------------------------------------------------------
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
namespace FSHL\Output;
use FSHL;
/**
* HTML output with links to manual.
*
* @copyright Copyright (c) 2002-2005 Juraj 'hvge' Durech
* @copyright Copyright (c) 2011-2012 Jaroslav Hanslík
* @license http://fshl.kukulich.cz/#license
*/
class HtmlManual implements FSHL\Output
{
/**
* Last used class.
*
* @var string
*/
private $lastClass = null;
/**
* Closing tag for link.
*
* @var string
*/
private $closeTag = null;
/**
* Urls list to manual.
*
* @var array
*/
private $manualUrl = array(
'php-keyword1' => 'http://php.net/manual/en/langref.php',
'php-keyword2' => 'http://php.net/%s',
'sql-keyword1' => 'http://search.oracle.com/search/search?group=MySQL&q=%s',
'sql-keyword2' => 'http://search.oracle.com/search/search?group=MySQL&q=%s',
'sql-keyword3' => 'http://search.oracle.com/search/search?group=MySQL&q=%s',
);
/**
* Outputs a template part.
*
* @param string $part
* @param string $class
* @return string
*/
public function template($part, $class)
{
$output = '';
if ($this->lastClass !== $class) {
if (null !== $this->lastClass) {
$output .= '</span>';
}
$output .= $this->closeTag;
$this->closeTag = '';
if (null !== $class) {
$output .= '<span class="' . $class . '">';
}
$this->lastClass = $class;
}
return $output . htmlspecialchars($part, ENT_COMPAT, 'UTF-8');
}
/**
* Outputs a keyword.
*
* @param string $part
* @param string $class
* @return string
*/
public function keyword($part, $class)
{
$output = '';
if ($this->lastClass !== $class) {
if (null !== $this->lastClass) {
$output .= '</span>';
}
$output .= $this->closeTag;
$this->closeTag = '';
if (null !== $class) {
if (isset($this->manualUrl[$class])) {
$output .= '<a href="' . sprintf($this->manualUrl[$class], $part) . '">';
$this->closeTag = '</a>';
}
$output .= '<span class="' . $class . '">';
}
$this->lastClass = $class;
}
return $output . htmlspecialchars($part, ENT_COMPAT, 'UTF-8');
}
}

19
apigen/libs/FSHL/LICENSE Normal file
View File

@ -0,0 +1,19 @@
License
=======
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License
--------------------------
GPL license is very very long, so instead of including it here we offer
you URL with full text: http://www.gnu.org/licenses/gpl-2.0.html

View File

@ -0,0 +1,262 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application;
use Nette;
/**
* Front Controller.
*
* @author David Grudl
*
* @property-read array $requests
* @property-read IPresenter $presenter
* @property-read IRouter $router
* @property-read IPresenterFactory $presenterFactory
*/
class Application extends Nette\Object
{
/** @var int */
public static $maxLoop = 20;
/** @var bool enable fault barrier? */
public $catchExceptions;
/** @var string */
public $errorPresenter;
/** @var array of function(Application $sender); Occurs before the application loads presenter */
public $onStartup;
/** @var array of function(Application $sender, \Exception $e = NULL); Occurs before the application shuts down */
public $onShutdown;
/** @var array of function(Application $sender, Request $request); Occurs when a new request is received */
public $onRequest;
/** @var array of function(Application $sender, IResponse $response); Occurs when a new response is ready for dispatch */
public $onResponse;
/** @var array of function(Application $sender, \Exception $e); Occurs when an unhandled exception occurs in the application */
public $onError;
/** @deprecated */
public $allowedMethods;
/** @var Request[] */
private $requests = array();
/** @var IPresenter */
private $presenter;
/** @var Nette\Http\IRequest */
private $httpRequest;
/** @var Nette\Http\IResponse */
private $httpResponse;
/** @var IPresenterFactory */
private $presenterFactory;
/** @var IRouter */
private $router;
public function __construct(IPresenterFactory $presenterFactory, IRouter $router, Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
$this->httpRequest = $httpRequest;
$this->httpResponse = $httpResponse;
$this->presenterFactory = $presenterFactory;
$this->router = $router;
}
/**
* Dispatch a HTTP request to a front controller.
* @return void
*/
public function run()
{
$request = NULL;
$repeatedError = FALSE;
do {
try {
if (count($this->requests) > self::$maxLoop) {
throw new ApplicationException('Too many loops detected in application life cycle.');
}
if (!$request) {
$this->onStartup($this);
$request = $this->router->match($this->httpRequest);
if (!$request instanceof Request) {
$request = NULL;
throw new BadRequestException('No route for HTTP request.');
}
if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
throw new BadRequestException('Invalid request. Presenter is not achievable.');
}
}
$this->requests[] = $request;
$this->onRequest($this, $request);
// Instantiate presenter
$presenterName = $request->getPresenterName();
try {
$this->presenter = $this->presenterFactory->createPresenter($presenterName);
} catch (InvalidPresenterException $e) {
throw new BadRequestException($e->getMessage(), 404, $e);
}
$this->presenterFactory->getPresenterClass($presenterName);
$request->setPresenterName($presenterName);
$request->freeze();
// Execute presenter
$response = $this->presenter->run($request);
if ($response) {
$this->onResponse($this, $response);
}
// Send response
if ($response instanceof Responses\ForwardResponse) {
$request = $response->getRequest();
continue;
} elseif ($response instanceof IResponse) {
$response->send($this->httpRequest, $this->httpResponse);
}
break;
} catch (\Exception $e) {
// fault barrier
$this->onError($this, $e);
if (!$this->catchExceptions) {
$this->onShutdown($this, $e);
throw $e;
}
if ($repeatedError) {
$e = new ApplicationException('An error occurred while executing error-presenter', 0, $e);
}
if (!$this->httpResponse->isSent()) {
$this->httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
}
if (!$repeatedError && $this->errorPresenter) {
$repeatedError = TRUE;
if ($this->presenter instanceof UI\Presenter) {
try {
$this->presenter->forward(":$this->errorPresenter:", array('exception' => $e));
} catch (AbortException $foo) {
$request = $this->presenter->getLastCreatedRequest();
}
} else {
$request = new Request(
$this->errorPresenter,
Request::FORWARD,
array('exception' => $e)
);
}
// continue
} else { // default error handler
if ($e instanceof BadRequestException) {
$code = $e->getCode();
} else {
$code = 500;
Nette\Diagnostics\Debugger::log($e, Nette\Diagnostics\Debugger::ERROR);
}
require __DIR__ . '/templates/error.phtml';
break;
}
}
} while (1);
$this->onShutdown($this, isset($e) ? $e : NULL);
}
/**
* Returns all processed requests.
* @return Request[]
*/
final public function getRequests()
{
return $this->requests;
}
/**
* Returns current presenter.
* @return IPresenter
*/
final public function getPresenter()
{
return $this->presenter;
}
/********************* services ****************d*g**/
/**
* Returns router.
* @return IRouter
*/
public function getRouter()
{
return $this->router;
}
/**
* Returns presenter factory.
* @return IPresenterFactory
*/
public function getPresenterFactory()
{
return $this->presenterFactory;
}
/********************* request serialization ****************d*g**/
/** @deprecated */
function storeRequest($expiration = '+ 10 minutes')
{
return $this->presenter->storeRequest($expiration);
}
/** @deprecated */
function restoreRequest($key)
{
return $this->presenter->restoreRequest($key);
}
}

View File

@ -0,0 +1,125 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Diagnostics;
use Nette,
Nette\Application\Routers,
Nette\Application\UI\Presenter, // templates
Nette\Diagnostics\Debugger;
/**
* Routing debugger for Debug Bar.
*
* @author David Grudl
*/
class RoutingPanel extends Nette\Object implements Nette\Diagnostics\IBarPanel
{
/** @var Nette\Application\IRouter */
private $router;
/** @var Nette\Http\IRequest */
private $httpRequest;
/** @var array */
private $routers = array();
/** @var Nette\Application\Request */
private $request;
public static function initializePanel(Nette\Application\Application $application)
{
Debugger::$blueScreen->addPanel(function($e) use ($application) {
return $e ? NULL : array(
'tab' => 'Nette Application',
'panel' => '<h3>Requests</h3>' . Nette\Diagnostics\Helpers::clickableDump($application->getRequests())
. '<h3>Presenter</h3>' . Nette\Diagnostics\Helpers::clickableDump($application->getPresenter())
);
});
}
public function __construct(Nette\Application\IRouter $router, Nette\Http\IRequest $httpRequest)
{
$this->router = $router;
$this->httpRequest = $httpRequest;
}
/**
* Renders tab.
* @return string
*/
public function getTab()
{
$this->analyse($this->router);
ob_start();
require __DIR__ . '/templates/RoutingPanel.tab.phtml';
return ob_get_clean();
}
/**
* Renders panel.
* @return string
*/
public function getPanel()
{
ob_start();
require __DIR__ . '/templates/RoutingPanel.panel.phtml';
return ob_get_clean();
}
/**
* Analyses simple route.
* @param Nette\Application\IRouter
* @return void
*/
private function analyse($router, $module = '')
{
if ($router instanceof Routers\RouteList) {
foreach ($router as $subRouter) {
$this->analyse($subRouter, $module . $router->getModule());
}
return;
}
$matched = 'no';
$request = $router->match($this->httpRequest);
if ($request) {
$request->setPresenterName($module . $request->getPresenterName());
$matched = 'may';
if (empty($this->request)) {
$this->request = $request;
$matched = 'yes';
}
}
$this->routers[] = array(
'matched' => $matched,
'class' => get_class($router),
'defaults' => $router instanceof Routers\Route || $router instanceof Routers\SimpleRouter ? $router->getDefaults() : array(),
'mask' => $router instanceof Routers\Route ? $router->getMask() : NULL,
'request' => $request,
'module' => rtrim($module, ':')
);
}
}

View File

@ -0,0 +1,119 @@
<?php
namespace Nette\Application\Diagnostics;
use Nette,
Nette\Application\UI\Presenter,
Nette\Diagnostics\Debugger;
?>
<style>
#nette-debug .nette-RoutingPanel table {
font: 9pt/1.5 Consolas, monospace;
}
#nette-debug .nette-RoutingPanel .yes td {
color: green;
}
#nette-debug .nette-RoutingPanel .may td {
color: #67F;
}
#nette-debug .nette-RoutingPanel pre, #nette-debug .nette-RoutingPanel code {
display: inline;
}
#nette-debug .nette-RoutingPanel code .nette-collapsed {
display: none;
}
</style>
<div class="nette-RoutingPanel">
<h1>
<?php if (empty($this->request)): ?>
no route
<?php else: ?>
<?php echo htmlSpecialChars($this->request->getPresenterName() . ':' . (isset($this->request->parameters[Presenter::ACTION_KEY]) ? $this->request->parameters[Presenter::ACTION_KEY] : Presenter::DEFAULT_ACTION) . (isset($this->request->parameters[Presenter::SIGNAL_KEY]) ? " {$this->request->parameters[Presenter::SIGNAL_KEY]}!" : '')) ?>
<?php endif ?>
</h1>
<?php if (!empty($this->request)): ?>
<?php $params = $this->request->getParameters() ?>
<?php if (empty($params)): ?>
<p>No parameters.</p>
<?php else: ?>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php unset($params[Presenter::ACTION_KEY], $params[Presenter::SIGNAL_KEY]) ?>
<?php foreach ($params as $key => $value): ?>
<tr>
<td><code><?php echo htmlSpecialChars($key) ?></code></td>
<td><?php if (is_string($value)):?><code><?php echo htmlSpecialChars($value) ?></code><?php else: echo Debugger::dump($value, TRUE); endif ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
<?php endif ?>
<h2>Routers</h2>
<?php if (empty($this->routers)): ?>
<p>No routers defined.</p>
<?php else: ?>
<div class="nette-inner">
<table>
<thead>
<tr>
<th>Matched?</th>
<th>Class</th>
<th>Mask</th>
<th>Defaults</th>
<th>Module</th>
<th>Request</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->routers as $router): ?>
<tr class="<?php echo $router['matched'] ?>">
<td><?php echo $router['matched'] ?></td>
<td><code title="<?php echo htmlSpecialChars($router['class']) ?>"><?php echo preg_replace('#.+\\\\#', '', htmlSpecialChars($router['class'])) ?></code></td>
<td><code><strong><?php echo htmlSpecialChars($router['mask']) ?></strong></code></td>
<td><code>
<?php foreach ($router['defaults'] as $key => $value): ?>
<?php echo htmlSpecialChars($key), "&nbsp;=&nbsp;", is_string($value) ? htmlSpecialChars($value) : str_replace("\n</pre", '</pre', Nette\Diagnostics\Helpers::clickableDump($value, TRUE)) ?><br />
<?php endforeach ?>
</code></td>
<td><code><?php echo htmlSpecialChars($router['module']) ?></code></td>
<td><?php if ($router['request']): ?><code>
<?php $params = $router['request']->getParameters(); ?>
<strong><?php echo htmlSpecialChars($router['request']->getPresenterName() . ':' . (isset($params[Presenter::ACTION_KEY]) ? $params[Presenter::ACTION_KEY] : Presenter::DEFAULT_ACTION)) ?></strong><br />
<?php unset($params[Presenter::ACTION_KEY]) ?>
<?php foreach ($params as $key => $value): ?>
<?php echo htmlSpecialChars($key), "&nbsp;=&nbsp;", is_string($value) ? htmlSpecialChars($value) : str_replace("\n</pre", '</pre', Nette\Diagnostics\Helpers::clickableDump($value, TRUE)) ?><br />
<?php endforeach ?>
</code><?php endif ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
<?php endif ?>
</div>

View File

@ -0,0 +1,10 @@
<?php
namespace Nette\Application\Diagnostics;
use Nette,
Nette\Application\UI\Presenter;
?>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJHSURBVDjLlZPNi81hFMc/z7137p1mTCFvNZfGSzLIWNjZKRvFRoqNhRCSYm8xS3+AxRRZ2JAFJWJHSQqTQkbEzYwIM+6Yid/znJfH4prLXShOnb6r8/nWOd8Tcs78bz0/f+KMu50y05nK/wy+uHDylbutqS5extvGcxaWqtoGDA8PZ3dnrs2srQc2Zko41UXLmLdyDW5OfvsUkUgbYGbU63UAQggdmvMzFmzZCgTi7CQmkZwdEaX0JwDgTnGbTCaE0G4zw80omhPI92lcEtkNkdgJCCHwJX7mZvNaB0A14SaYJlwTrpHsTkoFlV1nt2c3x5YYo1/vM9A/gKpxdfwyu/v3teCayKq4JEwT5EB2R6WgYmrs2bYbcUNNUVfEhIfFYy69uci+1fuRX84mkawFSxd/4nVWUopUVIykwlQxRTJBTIDA4Pp1jBZPuNW4wUAPmCqWIn29X1k4f5Ku8g9mpKCkakRLVEs1auVuauVuyqHMo8ejNCe+sWPVTkQKXCMmkeZUmUZjETF1tc6ooly+fgUVw9So1/tRN6YnZji46QghBFKKuAouERNhMlbAHZFE6e7pB+He8MMw+GGI4xtOMf1+lsl3TQ4NHf19BSlaO1DB9BfMHdX0O0iqSgiBbJkjm491hClJbA1LxCURgpPzXwAHhg63necAIi3XngXLcRU0fof8ETMljIyM5LGxMcbHxzvy/6fuXdWgt6+PWncv1e4euqo1ZmabvHs5+jn8yzufO7hiiZmuNpNBM13rbvVSpbrXJE7/BMkHtU9jFIC/AAAAAElFTkSuQmCC"
/><?php if (empty($this->request)): ?>no route<?php else: echo htmlSpecialChars($this->request->getPresenterName() . ':' . (isset($this->request->parameters[Presenter::ACTION_KEY]) ? $this->request->parameters[Presenter::ACTION_KEY] : Presenter::DEFAULT_ACTION) . (isset($this->request->parameters[Presenter::SIGNAL_KEY]) ? " {$this->request->parameters[Presenter::SIGNAL_KEY]}!" : '')); endif ?>

View File

@ -0,0 +1,32 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application;
use Nette;
/**
* Presenter converts Request to IResponse.
*
* @author David Grudl
*/
interface IPresenter
{
/**
* @param Request
* @return IResponse
*/
function run(Request $request);
}

View File

@ -0,0 +1,40 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application;
use Nette;
/**
* Responsible for creating a new instance of given presenter.
*
* @author Jan Tichý <tichy@medio.cz>
*/
interface IPresenterFactory
{
/**
* @param string presenter name
* @return string class name
* @throws InvalidPresenterException
*/
function getPresenterClass(& $name);
/**
* Create new presenter instance.
* @param string presenter name
* @return IPresenter
*/
function createPresenter($name);
}

View File

@ -0,0 +1,32 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application;
use Nette;
/**
* Any response returned by presenter.
*
* @author David Grudl
*/
interface IResponse
{
/**
* Sends response to output.
* @return void
*/
function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse);
}

View File

@ -0,0 +1,46 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application;
use Nette;
/**
* The bi-directional router.
*
* @author David Grudl
*/
interface IRouter
{
/** only matching route */
const ONE_WAY = 1;
/** HTTPS route */
const SECURED = 2;
/**
* Maps HTTP request to a Request object.
* @param Nette\Http\IRequest
* @return Request|NULL
*/
function match(Nette\Http\IRequest $httpRequest);
/**
* Constructs absolute URL from Request object.
* @param Request
* @param Nette\Http\Url referential URI
* @return string|NULL
*/
function constructUrl(Request $appRequest, Nette\Http\Url $refUrl);
}

View File

@ -0,0 +1,164 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace NetteModule;
use Nette,
Nette\Application,
Nette\Application\Responses,
Nette\Http;
/**
* Micro presenter.
*
* @author David Grudl
*
* @property-read Nette\Application\IRequest $request
*/
class MicroPresenter extends Nette\Object implements Application\IPresenter
{
/** @var Nette\DI\Container */
private $context;
/** @var Nette\Application\Request */
private $request;
public function __construct(Nette\DI\Container $context)
{
$this->context = $context;
}
/**
* Gets the context.
* @return \SystemContainer|Nette\DI\Container
*/
final public function getContext()
{
return $this->context;
}
/**
* @param Nette\Application\Request
* @return Nette\Application\IResponse
*/
public function run(Application\Request $request)
{
$this->request = $request;
$httpRequest = $this->context->getByType('Nette\Http\IRequest');
if (!$httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
$refUrl = clone $httpRequest->getUrl();
$url = $this->context->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
if ($url !== NULL && !$httpRequest->getUrl()->isEqual($url)) {
return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
}
}
$params = $request->getParameters();
if (!isset($params['callback'])) {
return;
}
$params['presenter'] = $this;
$callback = new Nette\Callback($params['callback']);
$response = $callback->invokeArgs(Application\UI\PresenterComponentReflection::combineArgs($callback->toReflection(), $params));
if (is_string($response)) {
$response = array($response, array());
}
if (is_array($response)) {
if ($response[0] instanceof \SplFileInfo) {
$response = $this->createTemplate('Nette\Templating\FileTemplate')
->setParameters($response[1])->setFile($response[0]);
} else {
$response = $this->createTemplate('Nette\Templating\Template')
->setParameters($response[1])->setSource($response[0]);
}
}
if ($response instanceof Nette\Templating\ITemplate) {
return new Responses\TextResponse($response);
} else {
return $response;
}
}
/**
* Template factory.
* @param string
* @param callable
* @return Nette\Templating\ITemplate
*/
public function createTemplate($class = NULL, $latteFactory = NULL)
{
$template = $class ? new $class : new Nette\Templating\FileTemplate;
$template->setParameters($this->request->getParameters());
$template->presenter = $this;
$template->context = $context = $this->context;
$url = $context->getByType('Nette\Http\IRequest')->getUrl();
$template->baseUrl = rtrim($url->getBaseUrl(), '/');
$template->basePath = rtrim($url->getBasePath(), '/');
$template->registerHelperLoader('Nette\Templating\Helpers::loader');
$template->setCacheStorage($context->nette->templateCacheStorage);
$template->onPrepareFilters[] = function($template) use ($latteFactory, $context) {
$template->registerFilter($latteFactory ? $latteFactory() : new Nette\Latte\Engine);
};
return $template;
}
/**
* Redirects to another URL.
* @param string
* @param int HTTP code
* @return void
*/
public function redirectUrl($url, $code = Http\IResponse::S302_FOUND)
{
return new Responses\RedirectResponse($url, $code);
}
/**
* Throws HTTP error.
* @param string
* @param int HTTP error code
* @return void
* @throws Nette\Application\BadRequestException
*/
public function error($message = NULL, $code = Http\IResponse::S404_NOT_FOUND)
{
throw new Application\BadRequestException($message, $code);
}
/**
* @return Nette\Application\IRequest
*/
public function getRequest()
{
return $this->request;
}
}

View File

@ -0,0 +1,171 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application;
use Nette;
/**
* Default presenter loader.
*
* @author David Grudl
*/
class PresenterFactory implements IPresenterFactory
{
/** @var bool */
public $caseSensitive = FALSE;
/** @var string */
private $baseDir;
/** @var array */
private $cache = array();
/** @var Nette\DI\Container */
private $container;
/**
* @param string
*/
public function __construct($baseDir, Nette\DI\Container $container)
{
$this->baseDir = $baseDir;
$this->container = $container;
}
/**
* Create new presenter instance.
* @param string presenter name
* @return IPresenter
*/
public function createPresenter($name)
{
$presenter = $this->container->createInstance($this->getPresenterClass($name));
if (method_exists($presenter, 'setContext')) {
$this->container->callMethod(array($presenter, 'setContext'));
}
foreach (array_reverse(get_class_methods($presenter)) as $method) {
if (substr($method, 0, 6) === 'inject') {
$this->container->callMethod(array($presenter, $method));
}
}
if ($presenter instanceof UI\Presenter && $presenter->invalidLinkMode === NULL) {
$presenter->invalidLinkMode = $this->container->parameters['debugMode'] ? UI\Presenter::INVALID_LINK_WARNING : UI\Presenter::INVALID_LINK_SILENT;
}
return $presenter;
}
/**
* @param string presenter name
* @return string class name
* @throws InvalidPresenterException
*/
public function getPresenterClass(& $name)
{
if (isset($this->cache[$name])) {
list($class, $name) = $this->cache[$name];
return $class;
}
if (!is_string($name) || !Nette\Utils\Strings::match($name, "#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*$#")) {
throw new InvalidPresenterException("Presenter name must be alphanumeric string, '$name' is invalid.");
}
$class = $this->formatPresenterClass($name);
if (!class_exists($class)) {
// internal autoloading
$file = $this->formatPresenterFile($name);
if (is_file($file) && is_readable($file)) {
Nette\Utils\LimitedScope::load($file, TRUE);
}
if (!class_exists($class)) {
throw new InvalidPresenterException("Cannot load presenter '$name', class '$class' was not found in '$file'.");
}
}
$reflection = new Nette\Reflection\ClassType($class);
$class = $reflection->getName();
if (!$reflection->implementsInterface('Nette\Application\IPresenter')) {
throw new InvalidPresenterException("Cannot load presenter '$name', class '$class' is not Nette\\Application\\IPresenter implementor.");
}
if ($reflection->isAbstract()) {
throw new InvalidPresenterException("Cannot load presenter '$name', class '$class' is abstract.");
}
// canonicalize presenter name
$realName = $this->unformatPresenterClass($class);
if ($name !== $realName) {
if ($this->caseSensitive) {
throw new InvalidPresenterException("Cannot load presenter '$name', case mismatch. Real name is '$realName'.");
} else {
$this->cache[$name] = array($class, $realName);
$name = $realName;
}
} else {
$this->cache[$name] = array($class, $realName);
}
return $class;
}
/**
* Formats presenter class name from its name.
* @param string
* @return string
*/
public function formatPresenterClass($presenter)
{
/*5.2*return strtr($presenter, ':', '_') . 'Presenter';*/
return str_replace(':', 'Module\\', $presenter) . 'Presenter';
}
/**
* Formats presenter name from class name.
* @param string
* @return string
*/
public function unformatPresenterClass($class)
{
/*5.2*return strtr(substr($class, 0, -9), '_', ':');*/
return str_replace('Module\\', ':', substr($class, 0, -9));
}
/**
* Formats presenter class file name.
* @param string
* @return string
*/
public function formatPresenterFile($presenter)
{
$path = '/' . str_replace(':', 'Module/', $presenter);
return $this->baseDir . substr_replace($path, '/presenters', strrpos($path, '/'), 0) . 'Presenter.php';
}
}

View File

@ -0,0 +1,270 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application;
use Nette;
/**
* Presenter request. Immutable object.
*
* @author David Grudl
*
* @property string $presenterName
* @property array $parameters
* @property array $post
* @property array $files
* @property string $method
*/
final class Request extends Nette\FreezableObject
{
/** method */
const FORWARD = 'FORWARD';
/** flag */
const SECURED = 'secured';
/** flag */
const RESTORED = 'restored';
/** @var string */
private $method;
/** @var array */
private $flags = array();
/** @var string */
private $name;
/** @var array */
private $params;
/** @var array */
private $post;
/** @var array */
private $files;
/**
* @param string fully qualified presenter name (module:module:presenter)
* @param string method
* @param array variables provided to the presenter usually via URL
* @param array variables provided to the presenter via POST
* @param array all uploaded files
* @param array flags
*/
public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
{
$this->name = $name;
$this->method = $method;
$this->params = $params;
$this->post = $post;
$this->files = $files;
$this->flags = $flags;
}
/**
* Sets the presenter name.
* @param string
* @return Request provides a fluent interface
*/
public function setPresenterName($name)
{
$this->updating();
$this->name = $name;
return $this;
}
/**
* Retrieve the presenter name.
* @return string
*/
public function getPresenterName()
{
return $this->name;
}
/**
* Sets variables provided to the presenter.
* @param array
* @return Request provides a fluent interface
*/
public function setParameters(array $params)
{
$this->updating();
$this->params = $params;
return $this;
}
/**
* Returns all variables provided to the presenter (usually via URL).
* @return array
*/
public function getParameters()
{
return $this->params;
}
/** @deprecated */
function setParams(array $params)
{
trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
return $this->setParameters($params);
}
/** @deprecated */
function getParams()
{
trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
return $this->getParameters();
}
/**
* Sets variables provided to the presenter via POST.
* @param array
* @return Request provides a fluent interface
*/
public function setPost(array $params)
{
$this->updating();
$this->post = $params;
return $this;
}
/**
* Returns all variables provided to the presenter via POST.
* @return array
*/
public function getPost()
{
return $this->post;
}
/**
* Sets all uploaded files.
* @param array
* @return Request provides a fluent interface
*/
public function setFiles(array $files)
{
$this->updating();
$this->files = $files;
return $this;
}
/**
* Returns all uploaded files.
* @return array
*/
public function getFiles()
{
return $this->files;
}
/**
* Sets the method.
* @param string
* @return Request provides a fluent interface
*/
public function setMethod($method)
{
$this->method = $method;
return $this;
}
/**
* Returns the method.
* @return string
*/
public function getMethod()
{
return $this->method;
}
/**
* Checks if the method is the given one.
* @param string
* @return bool
*/
public function isMethod($method)
{
return strcasecmp($this->method, $method) === 0;
}
/**
* Checks if the method is POST.
* @return bool
*/
public function isPost()
{
return strcasecmp($this->method, 'post') === 0;
}
/**
* Sets the flag.
* @param string
* @param bool
* @return Request provides a fluent interface
*/
public function setFlag($flag, $value = TRUE)
{
$this->updating();
$this->flags[$flag] = (bool) $value;
return $this;
}
/**
* Checks the flag.
* @param string
* @return bool
*/
public function hasFlag($flag)
{
return !empty($this->flags[$flag]);
}
}

View File

@ -0,0 +1,139 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Responses;
use Nette;
/**
* File download response.
*
* @author David Grudl
*
* @property-read string $file
* @property-read string $name
* @property-read string $contentType
*/
class FileResponse extends Nette\Object implements Nette\Application\IResponse
{
/** @var string */
private $file;
/** @var string */
private $contentType;
/** @var string */
private $name;
/** @var bool */
public $resuming = TRUE;
/**
* @param string file path
* @param string imposed file name
* @param string MIME content type
*/
public function __construct($file, $name = NULL, $contentType = NULL)
{
if (!is_file($file)) {
throw new Nette\Application\BadRequestException("File '$file' doesn't exist.");
}
$this->file = $file;
$this->name = $name ? $name : basename($file);
$this->contentType = $contentType ? $contentType : 'application/octet-stream';
}
/**
* Returns the path to a downloaded file.
* @return string
*/
final public function getFile()
{
return $this->file;
}
/**
* Returns the file name.
* @return string
*/
final public function getName()
{
return $this->name;
}
/**
* Returns the MIME content type of a downloaded file.
* @return string
*/
final public function getContentType()
{
return $this->contentType;
}
/**
* Sends response to output.
* @return void
*/
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
$httpResponse->setContentType($this->contentType);
$httpResponse->setHeader('Content-Disposition', 'attachment; filename="' . $this->name . '"');
$filesize = $length = filesize($this->file);
$handle = fopen($this->file, 'r');
if ($this->resuming) {
$httpResponse->setHeader('Accept-Ranges', 'bytes');
if (preg_match('#^bytes=(\d*)-(\d*)$#', $httpRequest->getHeader('Range'), $matches)) {
list(, $start, $end) = $matches;
if ($start === '') {
$start = max(0, $filesize - $end);
$end = $filesize - 1;
} elseif ($end === '' || $end > $filesize - 1) {
$end = $filesize - 1;
}
if ($end <= $start) {
$httpResponse->setCode(416); // requested range not satisfiable
return;
}
$httpResponse->setCode(206);
$httpResponse->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $filesize);
$length = $end - $start + 1;
fseek($handle, $start);
} else {
$httpResponse->setHeader('Content-Range', 'bytes 0-' . ($filesize - 1) . '/' . $filesize);
}
}
$httpResponse->setHeader('Content-Length', $length);
while (!feof($handle) && $length > 0) {
echo $s = fread($handle, min(4e6, $length));
$length -= strlen($s);
}
fclose($handle);
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Responses;
use Nette;
/**
* Forwards to new request.
*
* @author David Grudl
*
* @property-read Nette\Application\Request $request
*/
class ForwardResponse extends Nette\Object implements Nette\Application\IResponse
{
/** @var Nette\Application\Request */
private $request;
/**
* @param Nette\Application\Request new request
*/
public function __construct(Nette\Application\Request $request)
{
$this->request = $request;
}
/**
* @return Nette\Application\Request
*/
final public function getRequest()
{
return $this->request;
}
/**
* Sends response to output.
* @return void
*/
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
}
}

View File

@ -0,0 +1,83 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Responses;
use Nette;
/**
* JSON response used mainly for AJAX requests.
*
* @author David Grudl
*
* @property-read array|\stdClass $payload
* @property-read string $contentType
*/
class JsonResponse extends Nette\Object implements Nette\Application\IResponse
{
/** @var array|\stdClass */
private $payload;
/** @var string */
private $contentType;
/**
* @param array|\stdClass payload
* @param string MIME content type
*/
public function __construct($payload, $contentType = NULL)
{
if (!is_array($payload) && !is_object($payload)) {
throw new Nette\InvalidArgumentException("Payload must be array or object class, " . gettype($payload) . " given.");
}
$this->payload = $payload;
$this->contentType = $contentType ? $contentType : 'application/json';
}
/**
* @return array|\stdClass
*/
final public function getPayload()
{
return $this->payload;
}
/**
* Returns the MIME content type of a downloaded file.
* @return string
*/
final public function getContentType()
{
return $this->contentType;
}
/**
* Sends response to output.
* @return void
*/
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
$httpResponse->setContentType($this->contentType);
$httpResponse->setExpiration(FALSE);
echo Nette\Utils\Json::encode($this->payload);
}
}

View File

@ -0,0 +1,78 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Responses;
use Nette,
Nette\Http;
/**
* Redirects to new URI.
*
* @author David Grudl
*
* @property-read string $url
* @property-read int $code
*/
class RedirectResponse extends Nette\Object implements Nette\Application\IResponse
{
/** @var string */
private $url;
/** @var int */
private $code;
/**
* @param string URI
* @param int HTTP code 3xx
*/
public function __construct($url, $code = Http\IResponse::S302_FOUND)
{
$this->url = (string) $url;
$this->code = (int) $code;
}
/**
* @return string
*/
final public function getUrl()
{
return $this->url;
}
/**
* @return int
*/
final public function getCode()
{
return $this->code;
}
/**
* Sends response to output.
* @return void
*/
public function send(Http\IRequest $httpRequest, Http\IResponse $httpResponse)
{
$httpResponse->redirect($this->url, $this->code);
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Responses;
use Nette;
/**
* String output response.
*
* @author David Grudl
*
* @property-read mixed $source
*/
class TextResponse extends Nette\Object implements Nette\Application\IResponse
{
/** @var mixed */
private $source;
/**
* @param mixed renderable variable
*/
public function __construct($source)
{
$this->source = $source;
}
/**
* @return mixed
*/
final public function getSource()
{
return $this->source;
}
/**
* Sends response to output.
* @return void
*/
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
if ($this->source instanceof Nette\Templating\ITemplate) {
$this->source->render();
} else {
echo $this->source;
}
}
}

View File

@ -0,0 +1,129 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Routers;
use Nette,
Nette\Application;
/**
* The unidirectional router for CLI. (experimental)
*
* @author David Grudl
*
* @property-read array $defaults
*/
class CliRouter extends Nette\Object implements Application\IRouter
{
const PRESENTER_KEY = 'action';
/** @var array */
private $defaults;
/**
* @param array default values
*/
public function __construct($defaults = array())
{
$this->defaults = $defaults;
}
/**
* Maps command line arguments to a Request object.
* @param Nette\Http\IRequest
* @return Nette\Application\Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
if (empty($_SERVER['argv']) || !is_array($_SERVER['argv'])) {
return NULL;
}
$names = array(self::PRESENTER_KEY);
$params = $this->defaults;
$args = $_SERVER['argv'];
array_shift($args);
$args[] = '--';
foreach ($args as $arg) {
$opt = preg_replace('#/|-+#A', '', $arg);
if ($opt === $arg) {
if (isset($flag) || $flag = array_shift($names)) {
$params[$flag] = $arg;
} else {
$params[] = $arg;
}
$flag = NULL;
continue;
}
if (isset($flag)) {
$params[$flag] = TRUE;
$flag = NULL;
}
if ($opt !== '') {
$pair = explode('=', $opt, 2);
if (isset($pair[1])) {
$params[$pair[0]] = $pair[1];
} else {
$flag = $pair[0];
}
}
}
if (!isset($params[self::PRESENTER_KEY])) {
throw new Nette\InvalidStateException('Missing presenter & action in route definition.');
}
$presenter = $params[self::PRESENTER_KEY];
if ($a = strrpos($presenter, ':')) {
$params[self::PRESENTER_KEY] = substr($presenter, $a + 1);
$presenter = substr($presenter, 0, $a);
}
return new Application\Request(
$presenter,
'CLI',
$params
);
}
/**
* This router is only unidirectional.
* @param Nette\Application\Request
* @param Nette\Http\Url
* @return NULL
*/
public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
{
return NULL;
}
/**
* Returns default values.
* @return array
*/
public function getDefaults()
{
return $this->defaults;
}
}

View File

@ -0,0 +1,825 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Routers;
use Nette,
Nette\Application,
Nette\Utils\Strings;
/**
* The bidirectional route is responsible for mapping
* HTTP request to a Request object for dispatch and vice-versa.
*
* @author David Grudl
*
* @property-read string $mask
* @property-read array $defaults
* @property-read int $flags
* @property-read string|FALSE $targetPresenter
*/
class Route extends Nette\Object implements Application\IRouter
{
const PRESENTER_KEY = 'presenter';
const MODULE_KEY = 'module';
/** flag */
const CASE_SENSITIVE = 256;
/** @internal url type */
const HOST = 1,
PATH = 2,
RELATIVE = 3;
/** key used in {@link Route::$styles} or metadata {@link Route::__construct} */
const VALUE = 'value';
const PATTERN = 'pattern';
const FILTER_IN = 'filterIn';
const FILTER_OUT = 'filterOut';
const FILTER_TABLE = 'filterTable';
const FILTER_STRICT = 'filterStrict';
/** @internal fixity types - how to handle default value? {@link Route::$metadata} */
const OPTIONAL = 0,
PATH_OPTIONAL = 1,
CONSTANT = 2;
/** @var int */
public static $defaultFlags = 0;
/** @var array */
public static $styles = array(
'#' => array( // default style for path parameters
self::PATTERN => '[^/]+',
self::FILTER_IN => 'rawurldecode',
self::FILTER_OUT => array(__CLASS__, 'param2path'),
),
'?#' => array( // default style for query parameters
),
'module' => array(
self::PATTERN => '[a-z][a-z0-9.-]*',
self::FILTER_IN => array(__CLASS__, 'path2presenter'),
self::FILTER_OUT => array(__CLASS__, 'presenter2path'),
),
'presenter' => array(
self::PATTERN => '[a-z][a-z0-9.-]*',
self::FILTER_IN => array(__CLASS__, 'path2presenter'),
self::FILTER_OUT => array(__CLASS__, 'presenter2path'),
),
'action' => array(
self::PATTERN => '[a-z][a-z0-9-]*',
self::FILTER_IN => array(__CLASS__, 'path2action'),
self::FILTER_OUT => array(__CLASS__, 'action2path'),
),
'?module' => array(
),
'?presenter' => array(
),
'?action' => array(
),
);
/** @var string */
private $mask;
/** @var array */
private $sequence;
/** @var string regular expression pattern */
private $re;
/** @var array of [value & fixity, filterIn, filterOut] */
private $metadata = array();
/** @var array */
private $xlat;
/** @var int HOST, PATH, RELATIVE */
private $type;
/** @var int */
private $flags;
/**
* @param string URL mask, e.g. '<presenter>/<action>/<id \d{1,3}>'
* @param array|string default values or metadata
* @param int flags
*/
public function __construct($mask, $metadata = array(), $flags = 0)
{
if (is_string($metadata)) {
$a = strrpos($metadata, ':');
if (!$a) {
throw new Nette\InvalidArgumentException("Second argument must be array or string in format Presenter:action, '$metadata' given.");
}
$metadata = array(
self::PRESENTER_KEY => substr($metadata, 0, $a),
'action' => $a === strlen($metadata) - 1 ? NULL : substr($metadata, $a + 1),
);
} elseif ($metadata instanceof \Closure || $metadata instanceof Nette\Callback) {
$metadata = array(
self::PRESENTER_KEY => 'Nette:Micro',
'callback' => $metadata,
);
}
$this->flags = $flags | static::$defaultFlags;
$this->setMask($mask, $metadata);
}
/**
* Maps HTTP request to a Request object.
* @param Nette\Http\IRequest
* @return Nette\Application\Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
// combine with precedence: mask (params in URL-path), fixity, query, (post,) defaults
// 1) URL MASK
$url = $httpRequest->getUrl();
if ($this->type === self::HOST) {
$path = '//' . $url->getHost() . $url->getPath();
} elseif ($this->type === self::RELATIVE) {
$basePath = $url->getBasePath();
if (strncmp($url->getPath(), $basePath, strlen($basePath)) !== 0) {
return NULL;
}
$path = (string) substr($url->getPath(), strlen($basePath));
} else {
$path = $url->getPath();
}
if ($path !== '') {
$path = rtrim($path, '/') . '/';
}
if (!$matches = Strings::match($path, $this->re)) {
// stop, not matched
return NULL;
}
// deletes numeric keys, restore '-' chars
$params = array();
foreach ($matches as $k => $v) {
if (is_string($k) && $v !== '') {
$params[str_replace('___', '-', $k)] = $v; // trick
}
}
// 2) CONSTANT FIXITY
foreach ($this->metadata as $name => $meta) {
if (isset($params[$name])) {
//$params[$name] = $this->flags & self::CASE_SENSITIVE === 0 ? strtolower($params[$name]) : */$params[$name]; // strtolower damages UTF-8
} elseif (isset($meta['fixity']) && $meta['fixity'] !== self::OPTIONAL) {
$params[$name] = NULL; // cannot be overwriten in 3) and detected by isset() in 4)
}
}
// 3) QUERY
if ($this->xlat) {
$params += self::renameKeys($httpRequest->getQuery(), array_flip($this->xlat));
} else {
$params += $httpRequest->getQuery();
}
// 4) APPLY FILTERS & FIXITY
foreach ($this->metadata as $name => $meta) {
if (isset($params[$name])) {
if (!is_scalar($params[$name])) {
} elseif (isset($meta[self::FILTER_TABLE][$params[$name]])) { // applies filterTable only to scalar parameters
$params[$name] = $meta[self::FILTER_TABLE][$params[$name]];
} elseif (isset($meta[self::FILTER_TABLE]) && !empty($meta[self::FILTER_STRICT])) {
return NULL; // rejected by filterTable
} elseif (isset($meta[self::FILTER_IN])) { // applies filterIn only to scalar parameters
$params[$name] = call_user_func($meta[self::FILTER_IN], (string) $params[$name]);
if ($params[$name] === NULL && !isset($meta['fixity'])) {
return NULL; // rejected by filter
}
}
} elseif (isset($meta['fixity'])) {
$params[$name] = $meta[self::VALUE];
}
}
// 5) BUILD Request
if (!isset($params[self::PRESENTER_KEY])) {
throw new Nette\InvalidStateException('Missing presenter in route definition.');
}
if (isset($this->metadata[self::MODULE_KEY])) {
if (!isset($params[self::MODULE_KEY])) {
throw new Nette\InvalidStateException('Missing module in route definition.');
}
$presenter = $params[self::MODULE_KEY] . ':' . $params[self::PRESENTER_KEY];
unset($params[self::MODULE_KEY], $params[self::PRESENTER_KEY]);
} else {
$presenter = $params[self::PRESENTER_KEY];
unset($params[self::PRESENTER_KEY]);
}
return new Application\Request(
$presenter,
$httpRequest->getMethod(),
$params,
$httpRequest->getPost(),
$httpRequest->getFiles(),
array(Application\Request::SECURED => $httpRequest->isSecured())
);
}
/**
* Constructs absolute URL from Request object.
* @param Nette\Application\Request
* @param Nette\Http\Url
* @return string|NULL
*/
public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
{
if ($this->flags & self::ONE_WAY) {
return NULL;
}
$params = $appRequest->getParameters();
$metadata = $this->metadata;
$presenter = $appRequest->getPresenterName();
$params[self::PRESENTER_KEY] = $presenter;
if (isset($metadata[self::MODULE_KEY])) { // try split into module and [submodule:]presenter parts
$module = $metadata[self::MODULE_KEY];
if (isset($module['fixity']) && strncasecmp($presenter, $module[self::VALUE] . ':', strlen($module[self::VALUE]) + 1) === 0) {
$a = strlen($module[self::VALUE]);
} else {
$a = strrpos($presenter, ':');
}
if ($a === FALSE) {
$params[self::MODULE_KEY] = '';
} else {
$params[self::MODULE_KEY] = substr($presenter, 0, $a);
$params[self::PRESENTER_KEY] = substr($presenter, $a + 1);
}
}
foreach ($metadata as $name => $meta) {
if (!isset($params[$name])) {
continue; // retains NULL values
}
if (isset($meta['fixity'])) {
if ($params[$name] === FALSE) {
$params[$name] = '0';
}
if (is_scalar($params[$name]) ? strcasecmp($params[$name], $meta[self::VALUE]) === 0
: $params[$name] === $meta[self::VALUE]
) { // remove default values; NULL values are retain
unset($params[$name]);
continue;
} elseif ($meta['fixity'] === self::CONSTANT) {
return NULL; // missing or wrong parameter '$name'
}
}
if (!is_scalar($params[$name])) {
} elseif (isset($meta['filterTable2'][$params[$name]])) {
$params[$name] = $meta['filterTable2'][$params[$name]];
} elseif (isset($meta['filterTable2']) && !empty($meta[self::FILTER_STRICT])) {
return NULL;
} elseif (isset($meta[self::FILTER_OUT])) {
$params[$name] = call_user_func($meta[self::FILTER_OUT], $params[$name]);
}
if (isset($meta[self::PATTERN]) && !preg_match($meta[self::PATTERN], rawurldecode($params[$name]))) {
return NULL; // pattern not match
}
}
// compositing path
$sequence = $this->sequence;
$brackets = array();
$required = NULL; // NULL for auto-optional
$url = '';
$i = count($sequence) - 1;
do {
$url = $sequence[$i] . $url;
if ($i === 0) {
break;
}
$i--;
$name = $sequence[$i]; $i--; // parameter name
if ($name === ']') { // opening optional part
$brackets[] = $url;
} elseif ($name[0] === '[') { // closing optional part
$tmp = array_pop($brackets);
if ($required < count($brackets) + 1) { // is this level optional?
if ($name !== '[!') { // and not "required"-optional
$url = $tmp;
}
} else {
$required = count($brackets);
}
} elseif ($name[0] === '?') { // "foo" parameter
continue;
} elseif (isset($params[$name]) && $params[$name] != '') { // intentionally ==
$required = count($brackets); // make this level required
$url = $params[$name] . $url;
unset($params[$name]);
} elseif (isset($metadata[$name]['fixity'])) { // has default value?
if ($required === NULL && !$brackets) { // auto-optional
$url = '';
} else {
$url = $metadata[$name]['defOut'] . $url;
}
} else {
return NULL; // missing parameter '$name'
}
} while (TRUE);
// build query string
if ($this->xlat) {
$params = self::renameKeys($params, $this->xlat);
}
$sep = ini_get('arg_separator.input');
$query = http_build_query($params, '', $sep ? $sep[0] : '&');
if ($query != '') { // intentionally ==
$url .= '?' . $query;
}
// absolutize path
if ($this->type === self::RELATIVE) {
$url = '//' . $refUrl->getAuthority() . $refUrl->getBasePath() . $url;
} elseif ($this->type === self::PATH) {
$url = '//' . $refUrl->getAuthority() . $url;
}
if (strpos($url, '//', 2) !== FALSE) {
return NULL; // TODO: implement counterpart in match() ?
}
$url = ($this->flags & self::SECURED ? 'https:' : 'http:') . $url;
return $url;
}
/**
* Parse mask and array of default values; initializes object.
* @param string
* @param array
* @return void
*/
private function setMask($mask, array $metadata)
{
$this->mask = $mask;
// detect '//host/path' vs. '/abs. path' vs. 'relative path'
if (substr($mask, 0, 2) === '//') {
$this->type = self::HOST;
} elseif (substr($mask, 0, 1) === '/') {
$this->type = self::PATH;
} else {
$this->type = self::RELATIVE;
}
foreach ($metadata as $name => $meta) {
if (!is_array($meta)) {
$metadata[$name] = array(self::VALUE => $meta, 'fixity' => self::CONSTANT);
} elseif (array_key_exists(self::VALUE, $meta)) {
$metadata[$name]['fixity'] = self::CONSTANT;
}
}
// PARSE MASK
// <parameter-name[=default] [pattern] [#class]> or [ or ] or ?...
$parts = Strings::split($mask, '/<([^>#= ]+)(=[^># ]*)? *([^>#]*)(#?[^>\[\]]*)>|(\[!?|\]|\s*\?.*)/');
$this->xlat = array();
$i = count($parts) - 1;
// PARSE QUERY PART OF MASK
if (isset($parts[$i - 1]) && substr(ltrim($parts[$i - 1]), 0, 1) === '?') {
// name=<parameter-name [pattern][#class]>
$matches = Strings::matchAll($parts[$i - 1], '/(?:([a-zA-Z0-9_.-]+)=)?<([^># ]+) *([^>#]*)(#?[^>]*)>/');
foreach ($matches as $match) {
list(, $param, $name, $pattern, $class) = $match; // $pattern is not used
if ($class !== '') {
if (!isset(static::$styles[$class])) {
throw new Nette\InvalidStateException("Parameter '$name' has '$class' flag, but Route::\$styles['$class'] is not set.");
}
$meta = static::$styles[$class];
} elseif (isset(static::$styles['?' . $name])) {
$meta = static::$styles['?' . $name];
} else {
$meta = static::$styles['?#'];
}
if (isset($metadata[$name])) {
$meta = $metadata[$name] + $meta;
}
if (array_key_exists(self::VALUE, $meta)) {
$meta['fixity'] = self::OPTIONAL;
}
unset($meta['pattern']);
$meta['filterTable2'] = empty($meta[self::FILTER_TABLE]) ? NULL : array_flip($meta[self::FILTER_TABLE]);
$metadata[$name] = $meta;
if ($param !== '') {
$this->xlat[$name] = $param;
}
}
$i -= 6;
}
// PARSE PATH PART OF MASK
$brackets = 0; // optional level
$re = '';
$sequence = array();
$autoOptional = TRUE;
do {
array_unshift($sequence, $parts[$i]);
$re = preg_quote($parts[$i], '#') . $re;
if ($i === 0) {
break;
}
$i--;
$part = $parts[$i]; // [ or ]
if ($part === '[' || $part === ']' || $part === '[!') {
$brackets += $part[0] === '[' ? -1 : 1;
if ($brackets < 0) {
throw new Nette\InvalidArgumentException("Unexpected '$part' in mask '$mask'.");
}
array_unshift($sequence, $part);
$re = ($part[0] === '[' ? '(?:' : ')?') . $re;
$i -= 5;
continue;
}
$class = $parts[$i]; $i--; // validation class
$pattern = trim($parts[$i]); $i--; // validation condition (as regexp)
$default = $parts[$i]; $i--; // default value
$name = $parts[$i]; $i--; // parameter name
array_unshift($sequence, $name);
if ($name[0] === '?') { // "foo" parameter
$re = '(?:' . preg_quote(substr($name, 1), '#') . '|' . $pattern . ')' . $re;
$sequence[1] = substr($name, 1) . $sequence[1];
continue;
}
// check name (limitation by regexp)
if (preg_match('#[^a-z0-9_-]#i', $name)) {
throw new Nette\InvalidArgumentException("Parameter name must be alphanumeric string due to limitations of PCRE, '$name' given.");
}
// pattern, condition & metadata
if ($class !== '') {
if (!isset(static::$styles[$class])) {
throw new Nette\InvalidStateException("Parameter '$name' has '$class' flag, but Route::\$styles['$class'] is not set.");
}
$meta = static::$styles[$class];
} elseif (isset(static::$styles[$name])) {
$meta = static::$styles[$name];
} else {
$meta = static::$styles['#'];
}
if (isset($metadata[$name])) {
$meta = $metadata[$name] + $meta;
}
if ($pattern == '' && isset($meta[self::PATTERN])) {
$pattern = $meta[self::PATTERN];
}
if ($default !== '') {
$meta[self::VALUE] = (string) substr($default, 1);
$meta['fixity'] = self::PATH_OPTIONAL;
}
$meta['filterTable2'] = empty($meta[self::FILTER_TABLE]) ? NULL : array_flip($meta[self::FILTER_TABLE]);
if (array_key_exists(self::VALUE, $meta)) {
if (isset($meta['filterTable2'][$meta[self::VALUE]])) {
$meta['defOut'] = $meta['filterTable2'][$meta[self::VALUE]];
} elseif (isset($meta[self::FILTER_OUT])) {
$meta['defOut'] = call_user_func($meta[self::FILTER_OUT], $meta[self::VALUE]);
} else {
$meta['defOut'] = $meta[self::VALUE];
}
}
$meta[self::PATTERN] = "#(?:$pattern)$#A" . ($this->flags & self::CASE_SENSITIVE ? '' : 'iu');
// include in expression
$re = '(?P<' . str_replace('-', '___', $name) . '>(?U)' . $pattern . ')' . $re; // str_replace is dirty trick to enable '-' in parameter name
if ($brackets) { // is in brackets?
if (!isset($meta[self::VALUE])) {
$meta[self::VALUE] = $meta['defOut'] = NULL;
}
$meta['fixity'] = self::PATH_OPTIONAL;
} elseif (!$autoOptional) {
unset($meta['fixity']);
} elseif (isset($meta['fixity'])) { // auto-optional
$re = '(?:' . $re . ')?';
$meta['fixity'] = self::PATH_OPTIONAL;
} else {
$autoOptional = FALSE;
}
$metadata[$name] = $meta;
} while (TRUE);
if ($brackets) {
throw new Nette\InvalidArgumentException("Missing closing ']' in mask '$mask'.");
}
$this->re = '#' . $re . '/?$#A' . ($this->flags & self::CASE_SENSITIVE ? '' : 'iu');
$this->metadata = $metadata;
$this->sequence = $sequence;
}
/**
* Returns mask.
* @return string
*/
public function getMask()
{
return $this->mask;
}
/**
* Returns default values.
* @return array
*/
public function getDefaults()
{
$defaults = array();
foreach ($this->metadata as $name => $meta) {
if (isset($meta['fixity'])) {
$defaults[$name] = $meta[self::VALUE];
}
}
return $defaults;
}
/**
* Returns flags.
* @return int
*/
public function getFlags()
{
return $this->flags;
}
/********************* Utilities ****************d*g**/
/**
* Proprietary cache aim.
* @return string|FALSE
*/
public function getTargetPresenter()
{
if ($this->flags & self::ONE_WAY) {
return FALSE;
}
$m = $this->metadata;
$module = '';
if (isset($m[self::MODULE_KEY])) {
if (isset($m[self::MODULE_KEY]['fixity']) && $m[self::MODULE_KEY]['fixity'] === self::CONSTANT) {
$module = $m[self::MODULE_KEY][self::VALUE] . ':';
} else {
return NULL;
}
}
if (isset($m[self::PRESENTER_KEY]['fixity']) && $m[self::PRESENTER_KEY]['fixity'] === self::CONSTANT) {
return $module . $m[self::PRESENTER_KEY][self::VALUE];
}
return NULL;
}
/**
* Rename keys in array.
* @param array
* @param array
* @return array
*/
private static function renameKeys($arr, $xlat)
{
if (empty($xlat)) {
return $arr;
}
$res = array();
$occupied = array_flip($xlat);
foreach ($arr as $k => $v) {
if (isset($xlat[$k])) {
$res[$xlat[$k]] = $v;
} elseif (!isset($occupied[$k])) {
$res[$k] = $v;
}
}
return $res;
}
/********************* Inflectors ****************d*g**/
/**
* camelCaseAction name -> dash-separated.
* @param string
* @return string
*/
private static function action2path($s)
{
$s = preg_replace('#(.)(?=[A-Z])#', '$1-', $s);
$s = strtolower($s);
$s = rawurlencode($s);
return $s;
}
/**
* dash-separated -> camelCaseAction name.
* @param string
* @return string
*/
private static function path2action($s)
{
$s = strtolower($s);
$s = preg_replace('#-(?=[a-z])#', ' ', $s);
$s = substr(ucwords('x' . $s), 1);
//$s = lcfirst(ucwords($s));
$s = str_replace(' ', '', $s);
return $s;
}
/**
* PascalCase:Presenter name -> dash-and-dot-separated.
* @param string
* @return string
*/
private static function presenter2path($s)
{
$s = strtr($s, ':', '.');
$s = preg_replace('#([^.])(?=[A-Z])#', '$1-', $s);
$s = strtolower($s);
$s = rawurlencode($s);
return $s;
}
/**
* dash-and-dot-separated -> PascalCase:Presenter name.
* @param string
* @return string
*/
private static function path2presenter($s)
{
$s = strtolower($s);
$s = preg_replace('#([.-])(?=[a-z])#', '$1 ', $s);
$s = ucwords($s);
$s = str_replace('. ', ':', $s);
$s = str_replace('- ', '', $s);
return $s;
}
/**
* Url encode.
* @param string
* @return string
*/
private static function param2path($s)
{
return str_replace('%2F', '/', rawurlencode($s));
}
/********************* Route::$styles manipulator ****************d*g**/
/**
* Creates new style.
* @param string style name (#style, urlParameter, ?queryParameter)
* @param string optional parent style name
* @return void
*/
public static function addStyle($style, $parent = '#')
{
if (isset(static::$styles[$style])) {
throw new Nette\InvalidArgumentException("Style '$style' already exists.");
}
if ($parent !== NULL) {
if (!isset(static::$styles[$parent])) {
throw new Nette\InvalidArgumentException("Parent style '$parent' doesn't exist.");
}
static::$styles[$style] = static::$styles[$parent];
} else {
static::$styles[$style] = array();
}
}
/**
* Changes style property value.
* @param string style name (#style, urlParameter, ?queryParameter)
* @param string property name (Route::PATTERN, Route::FILTER_IN, Route::FILTER_OUT, Route::FILTER_TABLE)
* @param mixed property value
* @return void
*/
public static function setStyleProperty($style, $key, $value)
{
if (!isset(static::$styles[$style])) {
throw new Nette\InvalidArgumentException("Style '$style' doesn't exist.");
}
static::$styles[$style][$key] = $value;
}
}

View File

@ -0,0 +1,146 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Routers;
use Nette;
/**
* The router broker.
*
* @author David Grudl
* @property-read string $module
*/
class RouteList extends Nette\ArrayList implements Nette\Application\IRouter
{
/** @var array */
private $cachedRoutes;
/** @var string */
private $module;
public function __construct($module = NULL)
{
$this->module = $module ? $module . ':' : '';
}
/**
* Maps HTTP request to a Request object.
* @param Nette\Http\IRequest
* @return Nette\Application\Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
foreach ($this as $route) {
$appRequest = $route->match($httpRequest);
if ($appRequest !== NULL) {
$appRequest->setPresenterName($this->module . $appRequest->getPresenterName());
return $appRequest;
}
}
return NULL;
}
/**
* Constructs absolute URL from Request object.
* @param Nette\Application\Request
* @param Nette\Http\Url
* @return string|NULL
*/
public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\Url $refUrl)
{
if ($this->cachedRoutes === NULL) {
$routes = array();
$routes['*'] = array();
foreach ($this as $route) {
$presenter = $route instanceof Route ? $route->getTargetPresenter() : NULL;
if ($presenter === FALSE) {
continue;
}
if (is_string($presenter)) {
$presenter = strtolower($presenter);
if (!isset($routes[$presenter])) {
$routes[$presenter] = $routes['*'];
}
$routes[$presenter][] = $route;
} else {
foreach ($routes as $id => $foo) {
$routes[$id][] = $route;
}
}
}
$this->cachedRoutes = $routes;
}
if ($this->module) {
if (strncasecmp($tmp = $appRequest->getPresenterName(), $this->module, strlen($this->module)) === 0) {
$appRequest = clone $appRequest;
$appRequest->setPresenterName(substr($tmp, strlen($this->module)));
} else {
return NULL;
}
}
$presenter = strtolower($appRequest->getPresenterName());
if (!isset($this->cachedRoutes[$presenter])) {
$presenter = '*';
}
foreach ($this->cachedRoutes[$presenter] as $route) {
$url = $route->constructUrl($appRequest, $refUrl);
if ($url !== NULL) {
return $url;
}
}
return NULL;
}
/**
* Adds the router.
* @param mixed
* @param Nette\Application\IRouter
* @return void
*/
public function offsetSet($index, $route)
{
if (!$route instanceof Nette\Application\IRouter) {
throw new Nette\InvalidArgumentException("Argument must be IRouter descendant.");
}
parent::offsetSet($index, $route);
}
/**
* @return string
*/
public function getModule()
{
return $this->module;
}
}

View File

@ -0,0 +1,163 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\Routers;
use Nette,
Nette\Application;
/**
* The bidirectional route for trivial routing via query parameters.
*
* @author David Grudl
*
* @property-read array $defaults
* @property-read int $flags
*/
class SimpleRouter extends Nette\Object implements Application\IRouter
{
const PRESENTER_KEY = 'presenter';
const MODULE_KEY = 'module';
/** @var string */
private $module = '';
/** @var array */
private $defaults;
/** @var int */
private $flags;
/**
* @param array default values
* @param int flags
*/
public function __construct($defaults = array(), $flags = 0)
{
if (is_string($defaults)) {
$a = strrpos($defaults, ':');
if (!$a) {
throw new Nette\InvalidArgumentException("Argument must be array or string in format Presenter:action, '$defaults' given.");
}
$defaults = array(
self::PRESENTER_KEY => substr($defaults, 0, $a),
'action' => $a === strlen($defaults) - 1 ? Application\UI\Presenter::DEFAULT_ACTION : substr($defaults, $a + 1),
);
}
if (isset($defaults[self::MODULE_KEY])) {
$this->module = $defaults[self::MODULE_KEY] . ':';
unset($defaults[self::MODULE_KEY]);
}
$this->defaults = $defaults;
$this->flags = $flags;
}
/**
* Maps HTTP request to a Request object.
* @param Nette\Http\IRequest
* @return Nette\Application\Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
if ($httpRequest->getUrl()->getPathInfo() !== '') {
return NULL;
}
// combine with precedence: get, (post,) defaults
$params = $httpRequest->getQuery();
$params += $this->defaults;
if (!isset($params[self::PRESENTER_KEY])) {
throw new Nette\InvalidStateException('Missing presenter.');
}
$presenter = $this->module . $params[self::PRESENTER_KEY];
unset($params[self::PRESENTER_KEY]);
return new Application\Request(
$presenter,
$httpRequest->getMethod(),
$params,
$httpRequest->getPost(),
$httpRequest->getFiles(),
array(Application\Request::SECURED => $httpRequest->isSecured())
);
}
/**
* Constructs absolute URL from Request object.
* @param Nette\Application\Request
* @param Nette\Http\Url
* @return string|NULL
*/
public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
{
if ($this->flags & self::ONE_WAY) {
return NULL;
}
$params = $appRequest->getParameters();
// presenter name
$presenter = $appRequest->getPresenterName();
if (strncasecmp($presenter, $this->module, strlen($this->module)) === 0) {
$params[self::PRESENTER_KEY] = substr($presenter, strlen($this->module));
} else {
return NULL;
}
// remove default values; NULL values are retain
foreach ($this->defaults as $key => $value) {
if (isset($params[$key]) && $params[$key] == $value) { // intentionally ==
unset($params[$key]);
}
}
$url = ($this->flags & self::SECURED ? 'https://' : 'http://') . $refUrl->getAuthority() . $refUrl->getPath();
$sep = ini_get('arg_separator.input');
$query = http_build_query($params, '', $sep ? $sep[0] : '&');
if ($query != '') { // intentionally ==
$url .= '?' . $query;
}
return $url;
}
/**
* Returns default values.
* @return array
*/
public function getDefaults()
{
return $this->defaults;
}
/**
* Returns flags.
* @return int
*/
public function getFlags()
{
return $this->flags;
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Signal exception.
*
* @author David Grudl
*/
class BadSignalException extends Nette\Application\BadRequestException
{
/** @var int */
protected $defaultCode = 403;
}

View File

@ -0,0 +1,225 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Control is renderable Presenter component.
*
* @author David Grudl
*
* @property-read Nette\Templating\ITemplate $template
* @property-read string $snippetId
*/
abstract class Control extends PresenterComponent implements IRenderable
{
/** @var Nette\Templating\ITemplate */
private $template;
/** @var array */
private $invalidSnippets = array();
/** @var bool */
public $snippetMode;
/********************* template factory ****************d*g**/
/**
* @return Nette\Templating\ITemplate
*/
final public function getTemplate()
{
if ($this->template === NULL) {
$value = $this->createTemplate();
if (!$value instanceof Nette\Templating\ITemplate && $value !== NULL) {
$class2 = get_class($value); $class = get_class($this);
throw new Nette\UnexpectedValueException("Object returned by $class::createTemplate() must be instance of Nette\\Templating\\ITemplate, '$class2' given.");
}
$this->template = $value;
}
return $this->template;
}
/**
* @param string|NULL
* @return Nette\Templating\ITemplate
*/
protected function createTemplate($class = NULL)
{
$template = $class ? new $class : new Nette\Templating\FileTemplate;
$presenter = $this->getPresenter(FALSE);
$template->onPrepareFilters[] = $this->templatePrepareFilters;
$template->registerHelperLoader('Nette\Templating\Helpers::loader');
// default parameters
$template->control = $template->_control = $this;
$template->presenter = $template->_presenter = $presenter;
if ($presenter instanceof Presenter) {
$template->setCacheStorage($presenter->getContext()->nette->templateCacheStorage);
$template->user = $presenter->getUser();
$template->netteHttpResponse = $presenter->getHttpResponse();
$template->netteCacheStorage = $presenter->getContext()->getByType('Nette\Caching\IStorage');
$template->baseUri = $template->baseUrl = rtrim($presenter->getHttpRequest()->getUrl()->getBaseUrl(), '/');
$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
// flash message
if ($presenter->hasFlashSession()) {
$id = $this->getParameterId('flash');
$template->flashes = $presenter->getFlashSession()->$id;
}
}
if (!isset($template->flashes) || !is_array($template->flashes)) {
$template->flashes = array();
}
return $template;
}
/**
* Descendant can override this method to customize template compile-time filters.
* @param Nette\Templating\Template
* @return void
*/
public function templatePrepareFilters($template)
{
$template->registerFilter($this->getPresenter()->getContext()->nette->createLatte());
}
/**
* Returns widget component specified by name.
* @param string
* @return Nette\ComponentModel\IComponent
*/
public function getWidget($name)
{
trigger_error(__METHOD__ . '() is deprecated, use getComponent() instead.', E_USER_WARNING);
return $this->getComponent($name);
}
/**
* Saves the message to template, that can be displayed after redirect.
* @param string
* @param string
* @return \stdClass
*/
public function flashMessage($message, $type = 'info')
{
$id = $this->getParameterId('flash');
$messages = $this->getPresenter()->getFlashSession()->$id;
$messages[] = $flash = (object) array(
'message' => $message,
'type' => $type,
);
$this->getTemplate()->flashes = $messages;
$this->getPresenter()->getFlashSession()->$id = $messages;
return $flash;
}
/********************* rendering ****************d*g**/
/**
* Forces control or its snippet to repaint.
* @param string
* @return void
*/
public function invalidateControl($snippet = NULL)
{
$this->invalidSnippets[$snippet] = TRUE;
}
/**
* Allows control or its snippet to not repaint.
* @param string
* @return void
*/
public function validateControl($snippet = NULL)
{
if ($snippet === NULL) {
$this->invalidSnippets = array();
} else {
unset($this->invalidSnippets[$snippet]);
}
}
/**
* Is required to repaint the control or its snippet?
* @param string snippet name
* @return bool
*/
public function isControlInvalid($snippet = NULL)
{
if ($snippet === NULL) {
if (count($this->invalidSnippets) > 0) {
return TRUE;
} else {
$queue = array($this);
do {
foreach (array_shift($queue)->getComponents() as $component) {
if ($component instanceof IRenderable) {
if ($component->isControlInvalid()) {
// $this->invalidSnippets['__child'] = TRUE; // as cache
return TRUE;
}
} elseif ($component instanceof Nette\ComponentModel\IContainer) {
$queue[] = $component;
}
}
} while ($queue);
return FALSE;
}
} else {
return isset($this->invalidSnippets[NULL]) || isset($this->invalidSnippets[$snippet]);
}
}
/**
* Returns snippet HTML ID.
* @param string snippet name
* @return string
*/
public function getSnippetId($name = NULL)
{
// HTML 4 ID & NAME: [A-Za-z][A-Za-z0-9:_.-]*
return 'snippet-' . $this->getUniqueId() . '-' . $name;
}
}

View File

@ -0,0 +1,147 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Web form adapted for Presenter.
*
* @author David Grudl
*
* @property-read Presenter $presenter
*/
class Form extends Nette\Forms\Form implements ISignalReceiver
{
/**
* Application form constructor.
*/
public function __construct(Nette\ComponentModel\IContainer $parent = NULL, $name = NULL)
{
parent::__construct();
$this->monitor('Nette\Application\UI\Presenter');
if ($parent !== NULL) {
$parent->addComponent($this, $name);
}
}
/**
* Returns the presenter where this component belongs to.
* @param bool throw exception if presenter doesn't exist?
* @return Presenter|NULL
*/
public function getPresenter($need = TRUE)
{
return $this->lookup('Nette\Application\UI\Presenter', $need);
}
/**
* This method will be called when the component (or component's parent)
* becomes attached to a monitored object. Do not call this method yourself.
* @param Nette\ComponentModel\IComponent
* @return void
*/
protected function attached($presenter)
{
if ($presenter instanceof Presenter) {
$name = $this->lookupPath('Nette\Application\UI\Presenter');
if (!isset($this->getElementPrototype()->id)) {
$this->getElementPrototype()->id = 'frm-' . $name;
}
$this->setAction(new Link(
$presenter,
$name . self::NAME_SEPARATOR . 'submit!',
array()
));
// fill-in the form with HTTP data
if ($this->isSubmitted()) {
foreach ($this->getControls() as $control) {
if (!$control->isDisabled()) {
$control->loadHttpData();
}
}
}
}
parent::attached($presenter);
}
/**
* Tells if the form is anchored.
* @return bool
*/
public function isAnchored()
{
return (bool) $this->getPresenter(FALSE);
}
/**
* Internal: receives submitted HTTP data.
* @return array
*/
protected function receiveHttpData()
{
$presenter = $this->getPresenter();
if (!$presenter->isSignalReceiver($this, 'submit')) {
return;
}
$isPost = $this->getMethod() === self::POST;
$request = $presenter->getRequest();
if ($request->isMethod('forward') || $request->isMethod('post') !== $isPost) {
return;
}
if ($isPost) {
return Nette\Utils\Arrays::mergeTree($request->getPost(), $request->getFiles());
} else {
return $request->getParameters();
}
}
/********************* interface ISignalReceiver ****************d*g**/
/**
* This method is called by presenter.
* @param string
* @return void
*/
public function signalReceived($signal)
{
if ($signal === 'submit') {
if (!$this->getPresenter()->getRequest()->hasFlag(Nette\Application\Request::RESTORED)) {
$this->fireEvents();
}
} else {
$class = get_class($this);
throw new BadSignalException("Missing handler for signal '$signal' in $class.");
}
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Component with ability to repaint.
*
* @author David Grudl
*/
interface IRenderable
{
/**
* Forces control to repaint.
* @return void
*/
function invalidateControl();
/**
* Is required to repaint the control?
* @return bool
*/
function isControlInvalid();
}

View File

@ -0,0 +1,32 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Component with ability to receive signal.
*
* @author David Grudl
*/
interface ISignalReceiver
{
/**
* @param string
* @return void
*/
function signalReceived($signal); // handleSignal
}

View File

@ -0,0 +1,40 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Component with ability to save and load its state.
*
* @author David Grudl
*/
interface IStatePersistent
{
/**
* Loads state informations.
* @param array
* @return void
*/
function loadState(array $params);
/**
* Saves state informations for next request.
* @param array
* @return void
*/
function saveState(array & $params);
}

View File

@ -0,0 +1,36 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Link generation exception.
*
* @author David Grudl
*/
class InvalidLinkException extends \Exception
{
/*5.2*
public function __construct($message = '', $code = 0, \Exception $previous = NULL)
{
if (PHP_VERSION_ID < 50300) {
$this->previous = $previous;
parent::__construct($message, $code);
} else {
parent::__construct($message, $code, $previous);
}
}
*/
}

View File

@ -0,0 +1,117 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Lazy encapsulation of PresenterComponent::link().
* Do not instantiate directly, use PresenterComponent::lazyLink()
*
* @author David Grudl
* @internal
*
* @property-read string $destination
* @property-read array $parameters
*/
class Link extends Nette\Object
{
/** @var PresenterComponent */
private $component;
/** @var string */
private $destination;
/** @var array */
private $params;
/**
* Link specification.
* @param PresenterComponent
* @param string
* @param array
*/
public function __construct(PresenterComponent $component, $destination, array $params)
{
$this->component = $component;
$this->destination = $destination;
$this->params = $params;
}
/**
* Returns link destination.
* @return string
*/
public function getDestination()
{
return $this->destination;
}
/**
* Changes link parameter.
* @param string
* @param mixed
* @return Link provides a fluent interface
*/
public function setParameter($key, $value)
{
$this->params[$key] = $value;
return $this;
}
/**
* Returns link parameter.
* @param string
* @return mixed
*/
public function getParameter($key)
{
return isset($this->params[$key]) ? $this->params[$key] : NULL;
}
/**
* Returns link parameters.
* @return array
*/
public function getParameters()
{
return $this->params;
}
/**
* Converts link to URL.
* @return string
*/
public function __toString()
{
try {
return $this->component->link($this->destination, $this->params);
} catch (\Exception $e) {
Nette\Diagnostics\Debugger::toStringException($e);
}
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* Component multiplier.
*
* @author David Grudl
*/
class Multiplier extends PresenterComponent
{
/** @var Nette\Callback */
private $factory;
public function __construct($factory)
{
parent::__construct();
$this->factory = new Nette\Callback($factory);
}
protected function createComponent($name)
{
return $this->factory->invoke($name, $this);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,450 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette;
/**
* PresenterComponent is the base class for all Presenter components.
*
* Components are persistent objects located on a presenter. They have ability to own
* other child components, and interact with user. Components have properties
* for storing their status, and responds to user command.
*
* @author David Grudl
*
* @property-read Presenter $presenter
* @property-read string $uniqueId
*/
abstract class PresenterComponent extends Nette\ComponentModel\Container implements ISignalReceiver, IStatePersistent, \ArrayAccess
{
/** @var array */
protected $params = array();
/**
*/
public function __construct(Nette\ComponentModel\IContainer $parent = NULL, $name = NULL)
{
$this->monitor('Nette\Application\UI\Presenter');
parent::__construct($parent, $name);
}
/**
* Returns the presenter where this component belongs to.
* @param bool throw exception if presenter doesn't exist?
* @return Presenter|NULL
*/
public function getPresenter($need = TRUE)
{
return $this->lookup('Nette\Application\UI\Presenter', $need);
}
/**
* Returns a fully-qualified name that uniquely identifies the component
* within the presenter hierarchy.
* @return string
*/
public function getUniqueId()
{
return $this->lookupPath('Nette\Application\UI\Presenter', TRUE);
}
/**
* This method will be called when the component (or component's parent)
* becomes attached to a monitored object. Do not call this method yourself.
* @param Nette\ComponentModel\IComponent
* @return void
*/
protected function attached($presenter)
{
if ($presenter instanceof Presenter) {
$this->loadState($presenter->popGlobalParameters($this->getUniqueId()));
}
}
/**
* Calls public method if exists.
* @param string
* @param array
* @return bool does method exist?
*/
protected function tryCall($method, array $params)
{
$rc = $this->getReflection();
if ($rc->hasMethod($method)) {
$rm = $rc->getMethod($method);
if ($rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic()) {
$this->checkRequirements($rm);
$rm->invokeArgs($this, $rc->combineArgs($rm, $params));
return TRUE;
}
}
return FALSE;
}
/**
* Checks for requirements such as authorization.
* @return void
*/
public function checkRequirements($element)
{
}
/**
* Access to reflection.
* @return PresenterComponentReflection
*/
public /**/static/**/ function getReflection()
{
return new PresenterComponentReflection(/*5.2*$this*//**/get_called_class()/**/);
}
/********************* interface IStatePersistent ****************d*g**/
/**
* Loads state informations.
* @param array
* @return void
*/
public function loadState(array $params)
{
$reflection = $this->getReflection();
foreach ($reflection->getPersistentParams() as $name => $meta) {
if (isset($params[$name])) { // NULLs are ignored
$type = gettype($meta['def'] === NULL ? $params[$name] : $meta['def']); // compatible with 2.0.x
if (!$reflection->convertType($params[$name], $type)) {
throw new Nette\Application\BadRequestException("Invalid value for persistent parameter '$name' in '{$this->getName()}', expected " . ($type === 'NULL' ? 'scalar' : $type) . ".");
}
$this->$name = & $params[$name];
} else {
$params[$name] = & $this->$name;
}
}
$this->params = $params;
}
/**
* Saves state informations for next request.
* @param array
* @param PresenterComponentReflection (internal, used by Presenter)
* @return void
*/
public function saveState(array & $params, $reflection = NULL)
{
$reflection = $reflection === NULL ? $this->getReflection() : $reflection;
foreach ($reflection->getPersistentParams() as $name => $meta) {
if (isset($params[$name])) {
// injected value
} elseif (array_key_exists($name, $params)) { // NULLs are skipped
continue;
} elseif (!isset($meta['since']) || $this instanceof $meta['since']) {
$params[$name] = $this->$name; // object property value
} else {
continue; // ignored parameter
}
$type = gettype($meta['def'] === NULL ? $params[$name] : $meta['def']); // compatible with 2.0.x
if (!PresenterComponentReflection::convertType($params[$name], $type)) {
throw new InvalidLinkException("Invalid value for persistent parameter '$name' in '{$this->getName()}', expected " . ($type === 'NULL' ? 'scalar' : $type) . ".");
}
if ($params[$name] === $meta['def'] || ($meta['def'] === NULL && is_scalar($params[$name]) && (string) $params[$name] === '')) {
$params[$name] = NULL; // value transmit is unnecessary
}
}
}
/**
* Returns component param.
* If no key is passed, returns the entire array.
* @param string key
* @param mixed default value
* @return mixed
*/
final public function getParameter($name = NULL, $default = NULL)
{
if (func_num_args() === 0) {
return $this->params;
} elseif (isset($this->params[$name])) {
return $this->params[$name];
} else {
return $default;
}
}
/**
* Returns a fully-qualified name that uniquely identifies the parameter.
* @param string
* @return string
*/
final public function getParameterId($name)
{
$uid = $this->getUniqueId();
return $uid === '' ? $name : $uid . self::NAME_SEPARATOR . $name;
}
/** @deprecated */
function getParam($name = NULL, $default = NULL)
{
//trigger_error(__METHOD__ . '() is deprecated; use getParameter() instead.', E_USER_WARNING);
return func_num_args() ? $this->getParameter($name, $default) : $this->getParameter();
}
/** @deprecated */
function getParamId($name)
{
trigger_error(__METHOD__ . '() is deprecated; use getParameterId() instead.', E_USER_WARNING);
return $this->getParameterId($name);
}
/**
* Returns array of classes persistent parameters. They have public visibility and are non-static.
* This default implementation detects persistent parameters by annotation @persistent.
* @return array
*/
public static function getPersistentParams()
{
/*5.2*$arg = func_get_arg(0);*/
$rc = new Nette\Reflection\ClassType(/*5.2*$arg*//**/get_called_class()/**/);
$params = array();
foreach ($rc->getProperties(\ReflectionProperty::IS_PUBLIC) as $rp) {
if (!$rp->isStatic() && $rp->hasAnnotation('persistent')) {
$params[] = $rp->getName();
}
}
return $params;
}
/********************* interface ISignalReceiver ****************d*g**/
/**
* Calls signal handler method.
* @param string
* @return void
* @throws BadSignalException if there is not handler method
*/
public function signalReceived($signal)
{
if (!$this->tryCall($this->formatSignalMethod($signal), $this->params)) {
$class = get_class($this);
throw new BadSignalException("There is no handler for signal '$signal' in class $class.");
}
}
/**
* Formats signal handler method name -> case sensitivity doesn't matter.
* @param string
* @return string
*/
public function formatSignalMethod($signal)
{
return $signal == NULL ? NULL : 'handle' . $signal; // intentionally ==
}
/********************* navigation ****************d*g**/
/**
* Generates URL to presenter, action or signal.
* @param string destination in format "[[module:]presenter:]action" or "signal!" or "this"
* @param array|mixed
* @return string
* @throws InvalidLinkException
*/
public function link($destination, $args = array())
{
if (!is_array($args)) {
$args = func_get_args();
array_shift($args);
}
try {
return $this->getPresenter()->createRequest($this, $destination, $args, 'link');
} catch (InvalidLinkException $e) {
return $this->getPresenter()->handleInvalidLink($e);
}
}
/**
* Returns destination as Link object.
* @param string destination in format "[[module:]presenter:]view" or "signal!"
* @param array|mixed
* @return Link
*/
public function lazyLink($destination, $args = array())
{
if (!is_array($args)) {
$args = func_get_args();
array_shift($args);
}
return new Link($this, $destination, $args);
}
/**
* Determines whether it links to the current page.
* @param string destination in format "[[module:]presenter:]action" or "signal!" or "this"
* @param array|mixed
* @return bool
* @throws InvalidLinkException
*/
public function isLinkCurrent($destination = NULL, $args = array())
{
if ($destination !== NULL) {
if (!is_array($args)) {
$args = func_get_args();
array_shift($args);
}
$this->link($destination, $args);
}
return $this->getPresenter()->getLastCreatedRequestFlag('current');
}
/**
* Redirect to another presenter, action or signal.
* @param int [optional] HTTP error code
* @param string destination in format "[[module:]presenter:]view" or "signal!"
* @param array|mixed
* @return void
* @throws Nette\Application\AbortException
*/
public function redirect($code, $destination = NULL, $args = array())
{
if (!is_numeric($code)) { // first parameter is optional
$args = $destination;
$destination = $code;
$code = NULL;
}
if (!is_array($args)) {
$args = func_get_args();
if (is_numeric(array_shift($args))) {
array_shift($args);
}
}
$presenter = $this->getPresenter();
$presenter->redirectUrl($presenter->createRequest($this, $destination, $args, 'redirect'), $code);
}
/********************* interface \ArrayAccess ****************d*g**/
/**
* Adds the component to the container.
* @param string component name
* @param Nette\ComponentModel\IComponent
* @return void
*/
final public function offsetSet($name, $component)
{
$this->addComponent($component, $name);
}
/**
* Returns component specified by name. Throws exception if component doesn't exist.
* @param string component name
* @return Nette\ComponentModel\IComponent
* @throws Nette\InvalidArgumentException
*/
final public function offsetGet($name)
{
return $this->getComponent($name, TRUE);
}
/**
* Does component specified by name exists?
* @param string component name
* @return bool
*/
final public function offsetExists($name)
{
return $this->getComponent($name, FALSE) !== NULL;
}
/**
* Removes component from the container.
* @param string component name
* @return void
*/
final public function offsetUnset($name)
{
$component = $this->getComponent($name, FALSE);
if ($component !== NULL) {
$this->removeComponent($component);
}
}
}

View File

@ -0,0 +1,174 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application\UI;
use Nette,
Nette\Application\BadRequestException;
/**
* Helpers for Presenter & PresenterComponent.
*
* @author David Grudl
* @internal
*/
class PresenterComponentReflection extends Nette\Reflection\ClassType
{
/** @var array getPersistentParams cache */
private static $ppCache = array();
/** @var array getPersistentComponents cache */
private static $pcCache = array();
/** @var array isMethodCallable cache */
private static $mcCache = array();
/**
* @param string|NULL
* @return array of persistent parameters.
*/
public function getPersistentParams($class = NULL)
{
$class = $class === NULL ? $this->getName() : $class; // TODO
$params = & self::$ppCache[$class];
if ($params !== NULL) {
return $params;
}
$params = array();
if (is_subclass_of($class, 'Nette\Application\UI\PresenterComponent')) {
$defaults = get_class_vars($class);
foreach (/**/$class::getPersistentParams()/**//*5.2*call_user_func(array($class, 'getPersistentParams'), $class)*/ as $name => $meta) {
if (is_string($meta)) {
$name = $meta;
}
$params[$name] = array(
'def' => $defaults[$name],
'since' => $class,
);
}
foreach ($this->getPersistentParams(get_parent_class($class)) as $name => $param) {
if (isset($params[$name])) {
$params[$name]['since'] = $param['since'];
continue;
}
$params[$name] = $param;
}
}
return $params;
}
/**
* @param string|NULL
* @return array of persistent components.
*/
public function getPersistentComponents($class = NULL)
{
$class = $class === NULL ? $this->getName() : $class;
$components = & self::$pcCache[$class];
if ($components !== NULL) {
return $components;
}
$components = array();
if (is_subclass_of($class, 'Nette\Application\UI\Presenter')) {
foreach (/**/$class::getPersistentComponents()/**//*5.2*call_user_func(array($class, 'getPersistentComponents'), $class)*/ as $name => $meta) {
if (is_string($meta)) {
$name = $meta;
}
$components[$name] = array('since' => $class);
}
$components = $this->getPersistentComponents(get_parent_class($class)) + $components;
}
return $components;
}
/**
* Is a method callable? It means class is instantiable and method has
* public visibility, is non-static and non-abstract.
* @param string method name
* @return bool
*/
public function hasCallableMethod($method)
{
$class = $this->getName();
$cache = & self::$mcCache[strtolower($class . ':' . $method)];
if ($cache === NULL) try {
$cache = FALSE;
$rm = Nette\Reflection\Method::from($class, $method);
$cache = $this->isInstantiable() && $rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic();
} catch (\ReflectionException $e) {
}
return $cache;
}
/**
* @return array
*/
public static function combineArgs(\ReflectionFunctionAbstract $method, $args)
{
$res = array();
$i = 0;
foreach ($method->getParameters() as $param) {
$name = $param->getName();
if (isset($args[$name])) { // NULLs are ignored
$res[$i++] = $args[$name];
$type = $param->isArray() ? 'array' : ($param->isDefaultValueAvailable() ? gettype($param->getDefaultValue()) : 'NULL');
if (!self::convertType($res[$i-1], $type)) {
$mName = $method instanceof \ReflectionMethod ? $method->getDeclaringClass()->getName() . '::' . $method->getName() : $method->getName();
throw new BadRequestException("Invalid value for parameter '$name' in method $mName(), expected " . ($type === 'NULL' ? 'scalar' : $type) . ".");
}
} else {
$res[$i++] = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : ($param->isArray() ? array() : NULL);
}
}
return $res;
}
/**
* Non data-loss type conversion.
* @param mixed
* @param string
* @return bool
*/
public static function convertType(& $val, $type)
{
if ($val === NULL || is_object($val)) {
// ignore
} elseif ($type === 'array') {
if (!is_array($val)) {
return FALSE;
}
} elseif (!is_scalar($val)) {
return FALSE;
} elseif ($type !== 'NULL') {
$old = $val = ($val === FALSE ? '0' : (string) $val);
settype($val, $type);
if ($old !== ($val === FALSE ? '0' : (string) $val)) {
return FALSE; // data-loss occurs
}
}
return TRUE;
}
}

View File

@ -0,0 +1,92 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Application;
use Nette;
/**
* The exception that is thrown when user attempts to terminate the current presenter or application.
* This is special "silent exception" with no error message or code.
*/
class AbortException extends \Exception
{
}
/**
* Application fatal error.
*/
class ApplicationException extends \Exception
{
/*5.2*
public function __construct($message = '', $code = 0, \Exception $previous = NULL)
{
if (PHP_VERSION_ID < 50300) {
$this->previous = $previous;
parent::__construct($message, $code);
} else {
parent::__construct($message, $code, $previous);
}
}
*/
}
/**
* The exception that is thrown when a presenter cannot be loaded.
*/
class InvalidPresenterException extends \Exception
{
}
/**
* Bad HTTP / presenter request exception.
*/
class BadRequestException extends \Exception
{
/** @var int */
protected $defaultCode = 404;
public function __construct($message = '', $code = 0, \Exception $previous = NULL)
{
if ($code < 200 || $code > 504) {
$code = $this->defaultCode;
}
/*5.2*if (PHP_VERSION_ID < 50300) {
$this->previous = $previous;
parent::__construct($message, $code);
} else*/ {
parent::__construct($message, $code, $previous);
}
}
}
/**
* Forbidden request exception - access denied.
*/
class ForbiddenRequestException extends BadRequestException
{
/** @var int */
protected $defaultCode = 403;
}

View File

@ -0,0 +1,37 @@
<?php
/**
* Default error page.
* @param int $code
*/
namespace Nette\Application;
$messages = array(
0 => array('Oops...', 'Your browser sent a request that this server could not understand or process.'),
403 => array('Access Denied', 'You do not have permission to view this page. Please try contact the web site administrator if you believe you should be able to view this page.'),
404 => array('Page Not Found', 'The page you requested could not be found. It is possible that the address is incorrect, or that the page no longer exists. Please use a search engine to find what you are looking for.'),
405 => array('Method Not Allowed', 'The requested method is not allowed for the URL.'),
410 => array('Page Not Found', 'The page you requested has been taken off the site. We apologize for the inconvenience.'),
500 => array('Server Error', 'We\'re sorry! The server encountered an internal error and was unable to complete your request. Please try again later.'),
);
$message = isset($messages[$code]) ? $messages[$code] : $messages[0];
?>
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name=robots content=noindex><meta name=generator content="Nette Framework">
<style>
body { color: #333; background: white; width: 500px; margin: 100px auto }
h1 { font: bold 47px/1.5 sans-serif; margin: .6em 0 }
p { font: 21px/1.5 Georgia,serif; margin: 1.5em 0 }
small { font-size: 70%; color: gray }
</style>
<title><?php echo $message[0] ?></title>
<h1><?php echo $message[0] ?></h1>
<p><?php echo $message[1] ?></p>
<?php if ($code): ?><p><small>error <?php echo $code ?></small></p><?php endif ?>

View File

@ -0,0 +1,428 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Caching;
use Nette;
/**
* Implements the cache for a application.
*
* @author David Grudl
*
* @property-read IStorage $storage
* @property-read string $namespace
*/
class Cache extends Nette\Object implements \ArrayAccess
{
/** dependency */
const PRIORITY = 'priority',
EXPIRATION = 'expire',
EXPIRE = 'expire',
SLIDING = 'sliding',
TAGS = 'tags',
FILES = 'files',
ITEMS = 'items',
CONSTS = 'consts',
CALLBACKS = 'callbacks',
ALL = 'all';
/** @internal */
const NAMESPACE_SEPARATOR = "\x00";
/** @var IStorage */
private $storage;
/** @var string */
private $namespace;
/** @var string last query cache used by offsetGet() */
private $key;
/** @var mixed last query cache used by offsetGet() */
private $data;
public function __construct(IStorage $storage, $namespace = NULL)
{
$this->storage = $storage;
$this->namespace = $namespace . self::NAMESPACE_SEPARATOR;
}
/**
* Returns cache storage.
* @return IStorage
*/
public function getStorage()
{
return $this->storage;
}
/**
* Returns cache namespace.
* @return string
*/
public function getNamespace()
{
return (string) substr($this->namespace, 0, -1);
}
/**
* Returns new nested cache object.
* @param string
* @return Cache
*/
public function derive($namespace)
{
$derived = new static($this->storage, $this->namespace . $namespace);
return $derived;
}
/**
* Reads the specified item from the cache or generate it.
* @param mixed key
* @param callable
* @return mixed|NULL
*/
public function load($key, $fallback = NULL)
{
$data = $this->storage->read($this->generateKey($key));
if ($data === NULL && $fallback) {
return $this->save($key, new Nette\Callback($fallback));
}
return $data;
}
/**
* Writes item into the cache.
* Dependencies are:
* - Cache::PRIORITY => (int) priority
* - Cache::EXPIRATION => (timestamp) expiration
* - Cache::SLIDING => (bool) use sliding expiration?
* - Cache::TAGS => (array) tags
* - Cache::FILES => (array|string) file names
* - Cache::ITEMS => (array|string) cache items
* - Cache::CONSTS => (array|string) cache items
*
* @param mixed key
* @param mixed value
* @param array dependencies
* @return mixed value itself
* @throws Nette\InvalidArgumentException
*/
public function save($key, $data, array $dp = NULL)
{
$this->release();
$key = $this->generateKey($key);
if ($data instanceof Nette\Callback || $data instanceof \Closure) {
$this->storage->lock($key);
$data = Nette\Callback::create($data)->invokeArgs(array(&$dp));
}
if ($data === NULL) {
$this->storage->remove($key);
} else {
$this->storage->write($key, $data, $this->completeDependencies($dp, $data));
return $data;
}
}
private function completeDependencies($dp, $data)
{
if (is_object($data)) {
$dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkSerializationVersion'), get_class($data),
Nette\Reflection\ClassType::from($data)->getAnnotation('serializationVersion'));
}
// convert expire into relative amount of seconds
if (isset($dp[Cache::EXPIRATION])) {
$dp[Cache::EXPIRATION] = Nette\DateTime::from($dp[Cache::EXPIRATION])->format('U') - time();
}
// convert FILES into CALLBACKS
if (isset($dp[self::FILES])) {
//clearstatcache();
foreach (array_unique((array) $dp[self::FILES]) as $item) {
$dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkFile'), $item, @filemtime($item)); // @ - stat may fail
}
unset($dp[self::FILES]);
}
// add namespaces to items
if (isset($dp[self::ITEMS])) {
$dp[self::ITEMS] = array_unique((array) $dp[self::ITEMS]);
foreach ($dp[self::ITEMS] as $k => $item) {
$dp[self::ITEMS][$k] = $this->generateKey($item);
}
}
// convert CONSTS into CALLBACKS
if (isset($dp[self::CONSTS])) {
foreach (array_unique((array) $dp[self::CONSTS]) as $item) {
$dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkConst'), $item, constant($item));
}
unset($dp[self::CONSTS]);
}
if (!is_array($dp)) {
$dp = array();
}
return $dp;
}
/**
* Removes item from the cache.
* @param mixed key
* @return void
*/
public function remove($key)
{
$this->save($key, NULL);
}
/**
* Removes items from the cache by conditions.
* Conditions are:
* - Cache::PRIORITY => (int) priority
* - Cache::TAGS => (array) tags
* - Cache::ALL => TRUE
*
* @param array
* @return void
*/
public function clean(array $conds = NULL)
{
$this->release();
$this->storage->clean((array) $conds);
}
/**
* Caches results of function/method calls.
* @param mixed
* @return mixed
*/
public function call($function)
{
$key = func_get_args();
return $this->load($key, function() use ($function, $key) {
array_shift($key);
return Nette\Callback::create($function)->invokeArgs($key);
});
}
/**
* Caches results of function/method calls.
* @param mixed
* @param array dependencies
* @return Closure
*/
public function wrap($function, array $dp = NULL)
{
$cache = $this;
return function() use ($cache, $function, $dp) {
$key = array($function, func_get_args());
$data = $cache->load($key);
if ($data === NULL) {
$data = $cache->save($key, Nette\Callback::create($function)->invokeArgs($key[1]), $dp);
}
return $data;
};
}
/**
* Starts the output cache.
* @param mixed key
* @return OutputHelper|NULL
*/
public function start($key)
{
$data = $this->load($key);
if ($data === NULL) {
return new OutputHelper($this, $key);
}
echo $data;
}
/**
* Generates internal cache key.
*
* @param string
* @return string
*/
protected function generateKey($key)
{
return $this->namespace . md5(is_scalar($key) ? $key : serialize($key));
}
/********************* interface ArrayAccess ****************d*g**/
/**
* Inserts (replaces) item into the cache (\ArrayAccess implementation).
* @param mixed key
* @param mixed
* @return void
* @throws Nette\InvalidArgumentException
*/
public function offsetSet($key, $data)
{
$this->save($key, $data);
}
/**
* Retrieves the specified item from the cache or NULL if the key is not found (\ArrayAccess implementation).
* @param mixed key
* @return mixed|NULL
* @throws Nette\InvalidArgumentException
*/
public function offsetGet($key)
{
$key = is_scalar($key) ? (string) $key : serialize($key);
if ($this->key !== $key) {
$this->key = $key;
$this->data = $this->load($key);
}
return $this->data;
}
/**
* Exists item in cache? (\ArrayAccess implementation).
* @param mixed key
* @return bool
* @throws Nette\InvalidArgumentException
*/
public function offsetExists($key)
{
$this->release();
return $this->offsetGet($key) !== NULL;
}
/**
* Removes the specified item from the cache.
* @param mixed key
* @return void
* @throws Nette\InvalidArgumentException
*/
public function offsetUnset($key)
{
$this->save($key, NULL);
}
/**
* Discards the internal cache used by ArrayAccess.
* @return void
*/
public function release()
{
$this->key = $this->data = NULL;
}
/********************* dependency checkers ****************d*g**/
/**
* Checks CALLBACKS dependencies.
* @param array
* @return bool
*/
public static function checkCallbacks($callbacks)
{
foreach ($callbacks as $callback) {
$func = array_shift($callback);
if (!call_user_func_array($func, $callback)) {
return FALSE;
}
}
return TRUE;
}
/**
* Checks CONSTS dependency.
* @param string
* @param mixed
* @return bool
*/
private static function checkConst($const, $value)
{
return defined($const) && constant($const) === $value;
}
/**
* Checks FILES dependency.
* @param string
* @param int
* @return bool
*/
private static function checkFile($file, $time)
{
return @filemtime($file) == $time; // @ - stat may fail
}
/**
* Checks object @serializationVersion label.
* @param string
* @param mixed
* @return bool
*/
private static function checkSerializationVersion($class, $value)
{
return Nette\Reflection\ClassType::from($class)->getAnnotation('serializationVersion') === $value;
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Caching;
use Nette;
/**
* Cache storage.
*
* @author David Grudl
*/
interface IStorage
{
/**
* Read from cache.
* @param string key
* @return mixed|NULL
*/
function read($key);
/**
* Prevents item reading and writing. Lock is released by write() or remove().
* @param string key
* @return void
*/
function lock($key);
/**
* Writes item into the cache.
* @param string key
* @param mixed data
* @param array dependencies
* @return void
*/
function write($key, $data, array $dependencies);
/**
* Removes item from the cache.
* @param string key
* @return void
*/
function remove($key);
/**
* Removes items from the cache by conditions.
* @param array conditions
* @return void
*/
function clean(array $conds);
}

View File

@ -0,0 +1,59 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Caching;
use Nette;
/**
* Output caching helper.
*
* @author David Grudl
*/
class OutputHelper extends Nette\Object
{
/** @var array */
public $dependencies;
/** @var Cache */
private $cache;
/** @var string */
private $key;
public function __construct(Cache $cache, $key)
{
$this->cache = $cache;
$this->key = $key;
ob_start();
}
/**
* Stops and saves the cache.
* @param array dependencies
* @return void
*/
public function end(array $dp = NULL)
{
if ($this->cache === NULL) {
throw new Nette\InvalidStateException('Output cache has already been saved.');
}
$this->cache->save($this->key, ob_get_flush(), (array) $dp + (array) $this->dependencies);
$this->cache = NULL;
}
}

View File

@ -0,0 +1,81 @@
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
namespace Nette\Caching\Storages;
use Nette;
/**
* Cache dummy storage.
*
* @author David Grudl
*/
class DevNullStorage extends Nette\Object implements Nette\Caching\IStorage
{
/**
* Read from cache.
* @param string key
* @return mixed|NULL
*/
public function read($key)
{
}
/**
* Prevents item reading and writing. Lock is released by write() or remove().
* @param string key
* @return void
*/
public function lock($key)
{
}
/**
* Writes item into the cache.
* @param string key
* @param mixed data
* @param array dependencies
* @return void
*/
public function write($key, $data, array $dp)
{
}
/**
* Removes item from the cache.
* @param string key
* @return void
*/
public function remove($key)
{
}
/**
* Removes items from the cache by conditions & garbage collector.
* @param array conditions
* @return void
*/
public function clean(array $conds)
{
}
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More