summaryrefslogtreecommitdiffstats
path: root/tools/ContextGenerator.php
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ContextGenerator.php')
-rw-r--r--tools/ContextGenerator.php43
1 files changed, 22 insertions, 21 deletions
diff --git a/tools/ContextGenerator.php b/tools/ContextGenerator.php
index d4c5407..ac24156 100644
--- a/tools/ContextGenerator.php
+++ b/tools/ContextGenerator.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Tools;
@@ -18,19 +19,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
- );
+ '(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',
@@ -40,8 +41,8 @@ class ContextGenerator
'MariaDb100000' => 'https://mariadb.com/kb/en/the-mariadb-library/reserved-words/',
'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/'
- );
+ 'MariaDb100300' => 'https://mariadb.com/kb/en/the-mariadb-library/reserved-words/',
+ ];
/**
* The template of a context.
@@ -56,7 +57,6 @@ class ContextGenerator
*/
const TEMPLATE =
'<?php' . "\n" .
- '' . "\n" .
'/**' . "\n" .
' * Context for %1$s.' . "\n" .
' *' . "\n" .
@@ -64,6 +64,7 @@ class ContextGenerator
' *' . "\n" .
' * @see %3$s' . "\n" .
' */' . "\n" .
+ 'declare(strict_types=1);' . "\n" .
'' . "\n" .
'namespace PhpMyAdmin\\SqlParser\\Contexts;' . "\n" .
'' . "\n" .
@@ -90,9 +91,9 @@ class ContextGenerator
' *' . "\n" .
' * @var array' . "\n" .
' */' . "\n" .
- ' public static $KEYWORDS = array(' . "\n" .
+ ' public static $KEYWORDS = [' . "\n" .
'%4$s' .
- ' );' . "\n" .
+ ' ];' . "\n" .
'}' . "\n";
/**
@@ -124,12 +125,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;
@@ -162,14 +163,14 @@ class ContextGenerator
}
}
- $ret = array();
+ $ret = [];
foreach ($types as $word => $type) {
$len = strlen($word);
if (! isset($ret[$type])) {
- $ret[$type] = array();
+ $ret[$type] = [];
}
if (! isset($ret[$type][$len])) {
- $ret[$type][$len] = array();
+ $ret[$type][$len] = [];
}
$ret[$type][$len][] = $word;
}
@@ -254,7 +255,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 +335,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
- )
- )
- )
+ $directory . $file,
+ ]
+ ),
+ ]
)
);
}