summaryrefslogtreecommitdiffstats
path: root/tools/ContextGenerator.php
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ContextGenerator.php')
-rw-r--r--tools/ContextGenerator.php38
1 files changed, 19 insertions, 19 deletions
diff --git a/tools/ContextGenerator.php b/tools/ContextGenerator.php
index 503c0e9..5c6b747 100644
--- a/tools/ContextGenerator.php
+++ b/tools/ContextGenerator.php
@@ -18,19 +18,19 @@ class ContextGenerator
*
* @var array
*/
- public static $LABELS_FLAGS = array(
+ public static $LABELS_FLAGS = [
'(R)' => 2, // reserved
'(D)' => 8, // data type
'(K)' => 16, // keyword
'(F)' => 32, // function name
- );
+ ];
/**
* Documentation links for each context.
*
* @var array
*/
- public static $LINKS = array(
+ public static $LINKS = [
'MySql50000' => 'https://dev.mysql.com/doc/refman/5.0/en/keywords.html',
'MySql50100' => 'https://dev.mysql.com/doc/refman/5.1/en/keywords.html',
'MySql50500' => 'https://dev.mysql.com/doc/refman/5.5/en/keywords.html',
@@ -41,7 +41,7 @@ class ContextGenerator
'MariaDb100100' => 'https://mariadb.com/kb/en/the-mariadb-library/reserved-words/',
'MariaDb100200' => 'https://mariadb.com/kb/en/the-mariadb-library/reserved-words/',
'MariaDb100300' => 'https://mariadb.com/kb/en/the-mariadb-library/reserved-words/',
- );
+ ];
/**
* The template of a context.
@@ -124,12 +124,12 @@ class ContextGenerator
*/
public static function readWords(array $files)
{
- $words = array();
+ $words = [];
foreach ($files as $file) {
$words = array_merge($words, file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
}
- $types = array();
+ $types = [];
for ($i = 0, $count = count($words); $i !== $count; ++$i) {
$type = 1;
@@ -155,21 +155,21 @@ class ContextGenerator
}
$value = strtoupper($value);
- if (!isset($types[$value])) {
+ if (! isset($types[$value])) {
$types[$value] = $type;
} else {
$types[$value] |= $type;
}
}
- $ret = array();
+ $ret = [];
foreach ($types as $word => $type) {
$len = strlen($word);
- if (!isset($ret[$type])) {
- $ret[$type] = array();
+ if (! isset($ret[$type])) {
+ $ret[$type] = [];
}
- if (!isset($ret[$type][$len])) {
- $ret[$type][$len] = array();
+ if (! isset($ret[$type][$len])) {
+ $ret[$type][$len] = [];
}
$ret[$type][$len][] = $word;
}
@@ -254,7 +254,7 @@ class ContextGenerator
public static function formatName($name)
{
/* Split name and version */
- $parts = array();
+ $parts = [];
if (preg_match('/([^[0-9]*)([0-9]*)/', $name, $parts) === false) {
return $name;
}
@@ -334,18 +334,18 @@ class ContextGenerator
file_put_contents(
$output . '/' . $class . '.php',
static::generate(
- array(
+ [
'name' => $formattedName,
'class' => $class,
'link' => static::$LINKS[$name],
'keywords' => static::readWords(
- array(
+ [
$directory . '_common.txt',
$directory . '_functions' . $file,
$directory . $file,
- )
+ ]
),
- )
+ ]
)
);
}
@@ -389,9 +389,9 @@ if (count($argv) >= 3) {
$output = rtrim($argv[2], '/');
// Checking if all directories are valid.
- if (!is_dir($input)) {
+ if (! is_dir($input)) {
throw new \Exception('The input directory does not exist.');
- } elseif (!is_dir($output)) {
+ } elseif (! is_dir($output)) {
throw new \Exception('The output directory does not exist.');
}