Move the Power, Plugin and Module builders into the container. Many more PHP 8 improvments.

This commit is contained in:
2023-01-29 22:12:42 +02:00
parent e6c02a29f6
commit 7edbe20c33
68 changed files with 3443 additions and 1681 deletions

View File

@@ -30,14 +30,14 @@ abstract class ArrayHelper
*/
public static function check($array, $removeEmptyString = false)
{
if (is_array($array) && ($nr = count((array)$array)) > 0)
if (is_array($array) && ($nr = count((array) $array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
$array = array_filter($array);
if (empty($array))
if ($array === [])
{
return false;
}

View File

@@ -48,7 +48,7 @@ abstract class FileHelper
*
* @since 3.0.9
*/
public static function zip($workingDirectory, &$filepath)
public static function zip($workingDirectory, &$filepath): bool
{
// store the current joomla working directory
$joomla = getcwd();
@@ -65,11 +65,11 @@ abstract class FileHelper
// get a list of files in the current directory tree (also the hidden files)
$files = Folder::files('.', '', true, true, array('.svn', 'CVS', '.DS_Store', '__MACOSX'), array('.*~'));
$zipArray = array();
$zipArray = [];
// setup the zip array
foreach ($files as $file)
{
$tmp = array();
$tmp = [];
$tmp['name'] = str_replace('./', '', (string) $file);
$tmp['data'] = self::getContent($file);
$tmp['time'] = filemtime($file);
@@ -80,15 +80,10 @@ abstract class FileHelper
chdir($joomla);
// get the zip adapter
$adapter = new Archive();
$zip = $adapter->getAdapter('zip');
$zip = (new Archive())->getAdapter('zip');
//create the zip file
if ($zip->create($filepath, $zipArray))
{
return true;
}
return false;
return (bool) $zip->create($filepath, $zipArray);
}
/**
@@ -116,7 +111,7 @@ abstract class FileHelper
// start curl
$ch = curl_init();
// set the options
$options = array();
$options = [];
$options[CURLOPT_URL] = $path;
$options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12';
$options[CURLOPT_RETURNTRANSFER] = TRUE;

View File

@@ -67,7 +67,7 @@ abstract class JsonHelper
{
if (StringHelper::check($table))
{
$names = array();
$names = [];
foreach ($result as $val)
{
if ($external)

View File

@@ -31,7 +31,7 @@ abstract class ClassfunctionHelper
*
* @since 3.0.9
*/
public static function safe($name)
public static function safe($name): string
{
// remove numbers if the first character is a number
if (is_numeric(substr((string) $name, 0, 1)))

View File

@@ -399,7 +399,7 @@ abstract class StringHelper
public static function random($size): string
{
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$key = [];
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)