Fixes to be compliant with PHPMD & PHPCS

This commit is contained in:
Paolo
2022-03-07 12:16:56 +01:00
parent 07e416c2f4
commit 4ea2772a8d
7 changed files with 47 additions and 41 deletions
+20 -13
View File
@@ -2,6 +2,9 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \stdClass as stdClass;
use \PharData as PharData;
/**
* Library to manage core extensions
*/
@@ -194,8 +197,7 @@ class ExtensionsLib
$result = $this->_ci->ExtensionsModel->loadWhere(array('name' => $extensionName));
if (hasData($result)) // if something was found
{
$extsArray = array();
foreach ($result->retval as $key => $extension) // loops on them
foreach ($result->retval as $extension) // loops on them
{
// Remove them all
$result = $this->_ci->ExtensionsModel->delete($extension->extension_id);
@@ -397,6 +399,7 @@ class ExtensionsLib
*/
private function _chkExtensionJson($extensionName, $extensionDB)
{
$fhcomplete_version = 0;
$this->_printStart('Parsing and checking extension.json');
// Decodes extension.json
@@ -597,19 +600,23 @@ class ExtensionsLib
// Loops through the versions
for ($sqlDir = $startVersion; $sqlDir <= $extensionJson->version; $sqlDir++)
{
// If a directory with the same value of the version is present in the sql scripts directory
if (($files = glob($pkgSQLsPath.'/'.$sqlDir.'/*'.ExtensionsLib::SQL_FILE_EXTENSION)) != false)
{
// Search for a directory with the same value of the version in the sql scripts directory
$files = glob($pkgSQLsPath.'/'.$sqlDir.'/*'.ExtensionsLib::SQL_FILE_EXTENSION);
// If found
if ($files != false)
{
// Loads every sql files
foreach ($files as $file)
{
$sql = file_get_contents($file); // gets the entire content of the file
foreach ($files as $file)
{
$sql = file_get_contents($file); // gets the entire content of the file
$this->_printMessage('Executing query:');
$this->_printMessage($sql);
// Try to execute that
if (!isSuccess($result = @$this->_ci->ExtensionsModel->executeQuery($sql)))
$result = @$this->_ci->ExtensionsModel->executeQuery($sql);
if (!isSuccess($result))
{
$this->_errorOccurred = true;
$this->_printFailure(' error occurred while executing the query');
@@ -622,8 +629,8 @@ class ExtensionsLib
var_dump($result->retval); // KEEP IT!!!
$this->_ci->eprintflib->printEOL();
}
}
}
}
}
}
$this->_printSuccess(!$this->_errorOccurred);
@@ -684,7 +691,7 @@ class ExtensionsLib
foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $rootPath => $targetDirectories)
{
foreach ($targetDirectories as $key => $targetDirectory)
foreach ($targetDirectories as $targetDirectory)
{
if (file_exists($rootPath.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName))
{
@@ -738,7 +745,7 @@ class ExtensionsLib
// For every target directory
foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $rootPath => $targetDirectories)
{
foreach ($targetDirectories as $key => $targetDirectory)
foreach ($targetDirectories as $targetDirectory)
{
// If destination of the symlink does not exist
if (!file_exists($rootPath.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName))
+7 -5
View File
@@ -2,6 +2,8 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \Netcarver\Textile\Parser as NTParser;
class PhrasesLib
{
// Directory name where all the category files are
@@ -41,7 +43,7 @@ class PhrasesLib
$this->_ci->load->model('system/Phrasentext_model', 'PhrasentextModel');
// Workaround to use more parameters in the construct since PHP doesn't support many constructors
$this->_extend_construct(func_get_args());
$this->_extendConstruct(func_get_args());
}
// -----------------------------------------------------------------------------------------------------------------
@@ -78,7 +80,7 @@ class PhrasesLib
if (hasData($result))
{
// Textile parser
$textileParser = new \Netcarver\Textile\Parser();
$textileParser = new NTParser();
for ($i = 0; $i < count($result->retval); $i++)
{
@@ -182,13 +184,12 @@ class PhrasesLib
* - could be an array of categories, and for each category there is an array of phrases
* language: optional parameter must be a string. It's used to load phrases
*/
private function _extend_construct($params)
private function _extendConstruct($params)
{
// Checks if the $params is an array with at least one element
if (!isEmptyArray($params))
{
$parameters = $params[0]; // temporary variable
$isIndexArray = false; //flag for indexed array
// If there are parameters
if (!isEmptyArray($parameters))
@@ -325,6 +326,8 @@ class PhrasesLib
&& $phrasesCategoryFile != '..'
&& $pathInfo['extension'] == 'php')
{
$phrases = null; // define the variable
// Include the php file that contains phrases for that category
require_once($phrasesDirectory.$phrasesCategoryFile);
@@ -415,7 +418,6 @@ class PhrasesLib
$phrase[self::PHRASE]
)
);
}
else // otherwise if the phrase already exists in the database
{