* enforced v7.1 compliance, preparations for v7.2
 * removed deprecated usage of each()
 * prefer array deconstruction via [] instead of calling list()
 * try to catch failed session_start()
 * prefer ... - Token instead of calling func_get_args() func_num_args()
 * enforce return types in AjaxHandler
 * revision push
This commit is contained in:
Sarjuuk
2018-11-27 00:43:32 +01:00
parent f8a34aa98e
commit d9cd24026c
46 changed files with 299 additions and 342 deletions

View File

@@ -27,7 +27,7 @@ function build($syncMe = null)
CLI::write();
// files with template
foreach (FileGen::$tplFiles as $name => list($file, $destPath, $deps))
foreach (FileGen::$tplFiles as $name => [$file, $destPath, $deps])
{
$reqDBC = [];

View File

@@ -30,7 +30,7 @@ function dbconfig()
$port = 0;
if (strstr($dbInfo['host'], ':'))
list($dbInfo['host'], $port) = explode(':', $dbInfo['host']);
[$dbInfo['host'], $port] = explode(':', $dbInfo['host']);
if ($dbInfo['host'])
{

View File

@@ -127,7 +127,7 @@ function firstrun()
$port = 0;
if (strstr($AoWoWconf[$what]['host'], ':'))
list($AoWoWconf[$what]['host'], $port) = explode(':', $AoWoWconf[$what]['host']);
[$AoWoWconf[$what]['host'], $port] = explode(':', $AoWoWconf[$what]['host']);
if ($link = @mysqli_connect($AoWoWconf[$what]['host'], $AoWoWconf[$what]['user'], $AoWoWconf[$what]['pass'], $AoWoWconf[$what]['db'], $port ?: $defPort))
mysqli_close($link);
@@ -175,7 +175,7 @@ function firstrun()
'static_host' => [$prot, $res['static_host'], '/css/aowow.css']
);
foreach ($cases as $conf => list($protocol, $host, $testFile))
foreach ($cases as $conf => [$protocol, $host, $testFile])
{
if ($host)
{

View File

@@ -13,7 +13,7 @@ if (!CLI)
function update()
{
list($date, $part) = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
[$date, $part] = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
CLI::write('checking sql updates');
@@ -21,7 +21,7 @@ function update()
foreach (glob('setup/updates/*.sql') as $file)
{
$pi = pathinfo($file);
list($fDate, $fPart) = explode('_', $pi['filename']);
[$fDate, $fPart] = explode('_', $pi['filename']);
$fData = intVal($fDate);
@@ -59,7 +59,7 @@ function update()
CLI::write($nFiles ? 'applied '.$nFiles.' update(s)' : 'db is already up to date', CLI::LOG_OK);
// fetch sql/build after applying updates, as they may contain sync-prompts
list($sql, $build) = array_values(DB::Aowow()->selectRow('SELECT `sql`, `build` FROM ?_dbversion'));
[$sql, $build] = array_values(DB::Aowow()->selectRow('SELECT `sql`, `build` FROM ?_dbversion'));
sleep(1);

View File

@@ -561,7 +561,7 @@ class DBC
if ($this->isGameTable)
$row[-1] = $i;
foreach ($this->fileRefs as $locId => list($handle, $fullPath, $header))
foreach ($this->fileRefs as $locId => [$handle, $fullPath, $header])
{
$rec = unpack($unpackStr, fread($handle, $header['recordSize']));

View File

@@ -157,10 +157,10 @@ class FileGen
self::$cliOpts[$opt] = true;
}
public static function hasOpt(/* ...$opt */)
public static function hasOpt(string ...$opts) : int
{
$result = 0x0;
foreach (func_get_args() as $idx => $arg)
foreach ($opts as $idx => $arg)
{
if (!is_string($arg))
continue;
@@ -204,7 +204,7 @@ class FileGen
if (!empty(self::$tplFiles[$key]))
{
list($file, $destPath, $deps) = self::$tplFiles[$key];
[$file, $destPath, $deps] = self::$tplFiles[$key];
if ($content = file_get_contents(FileGen::$tplPath.$file.'.in'))
{

View File

@@ -191,7 +191,7 @@ if (!CLI)
$checkSourceDirs = function($sub) use ($imgPath, &$paths, $modeMask)
{
$hasMissing = false;
foreach ($paths as $idx => list($subDir, $isLocalized, $realPath))
foreach ($paths as $idx => [$subDir, $isLocalized, $realPath])
{
if ($realPath && !$isLocalized)
continue;
@@ -236,7 +236,7 @@ if (!CLI)
$locList[] = $xp;
CLI::write('required resources overview:', CLI::LOG_INFO);
foreach ($paths as list($path, $isLocalized, $realPath))
foreach ($paths as [$path, $isLocalized, $realPath])
{
if (!$realPath)
CLI::write(CLI::red('MISSING').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $locList).']/').$path);

View File

@@ -193,7 +193,7 @@ if (!CLI)
$checkSourceDirs = function($sub) use ($imgPath, &$paths)
{
$hasMissing = false;
foreach ($paths as $pathIdx => list($subDir, , , , , $realPath))
foreach ($paths as $pathIdx => [$subDir, , , , , $realPath])
{
if ($realPath)
continue;
@@ -243,7 +243,7 @@ if (!CLI)
$locList[] = $xp;
CLI::write('required resources overview:', CLI::LOG_INFO);
foreach ($paths as list($path, , , , , $realPath))
foreach ($paths as [$path, , , , , $realPath])
{
if ($realPath)
CLI::write(CLI::green(' FOUND ').' - '.str_pad($path, 53).' @ '.$realPath);
@@ -310,7 +310,7 @@ if (!CLI)
$dbcEntries = array_intersect_key($dbcEntries, array_unique($dbcEntries));
$allPaths = [];
foreach ($paths as $i => list($inPath, $outInfo, $pattern, $isIcon, $tileSize, $path))
foreach ($paths as $i => [$inPath, $outInfo, $pattern, $isIcon, $tileSize, $path])
{
$search = $path.$pattern;
if ($pattern)
@@ -346,7 +346,7 @@ if (!CLI)
$nFiles = count($outInfo) * ($tileSize ? array_sum(array_map('count', $cuNames[$i])) : count($files));
foreach ($outInfo as list($dest, $ext, $srcSize, $destSize, $borderOffset))
foreach ($outInfo as [$dest, $ext, $srcSize, $destSize, $borderOffset])
{
if ($tileSize)
{