From 700d6e04625cac22ae54a6e5e23b610b68fa6fec Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Tue, 30 May 2023 08:53:11 +0000 Subject: [PATCH] chore: apply PSR-12 manual changes --- common/cache/class.KeyValueCache.php | 5 +- common/cache/class.PartitionedCachable.php | 5 +- common/class.Collection.php | 6 +- common/class.Utils.php | 12 ++- .../class.ComponentCollection.php | 7 +- .../configuration/class.ComponentFactory.php | 16 +++- .../class.FileSystemComponent.php | 16 +++- common/configuration/class.Mock.php | 5 +- common/exception/class.ClientException.php | 3 +- .../exception/class.InvalidArgumentType.php | 3 +- common/exception/class.ResourceNotFound.php | 3 +- common/ext/class.Extension.php | 10 ++- common/ext/class.ExtensionHandler.php | 5 +- common/ext/class.ExtensionInstaller.php | 13 ++- common/ext/class.ExtensionModel.php | 8 +- common/ext/class.ExtensionUninstaller.php | 12 ++- common/ext/class.ExtensionUpdater.php | 5 +- common/ext/class.GenerisInstaller.php | 4 +- common/ext/class.UpdateExtensions.php | 13 ++- common/http/class.Request.php | 3 +- common/http/class.Response.php | 4 +- common/oatbox/Configurable.php | 4 +- common/oatbox/action/ActionService.php | 12 ++- common/oatbox/cache/KeyValueCache.php | 5 +- common/oatbox/extension/Manifest.php | 16 +++- .../extension/script/OptionContainer.php | 5 +- .../oatbox/extension/script/ScriptAction.php | 5 +- common/oatbox/filesystem/Directory.php | 13 ++- common/oatbox/filesystem/File.php | 12 ++- common/oatbox/install/Installer.php | 5 +- common/oatbox/log/ContainerLoggerTrait.php | 3 +- common/oatbox/log/LoggerAggregator.php | 4 +- common/oatbox/log/StreamHandler.php | 22 +++-- common/oatbox/log/logger/TaoLog.php | 13 ++- common/oatbox/log/logger/TaoMonolog.php | 28 ++++-- common/oatbox/service/ServiceConfigDriver.php | 3 +- common/oatbox/service/SimpleConfigDriver.php | 3 +- common/oatbox/task/AbstractTaskAction.php | 3 +- common/oatbox/task/Queue.php | 9 +- common/oatbox/task/RunTasks.php | 4 +- .../oatbox/task/TaskInterface/TaskPayLoad.php | 6 +- common/oatbox/task/TaskRunner.php | 8 +- .../InMemoryQueuePersistence.php | 3 +- .../oatbox/task/implementation/SyncQueue.php | 9 +- .../task/implementation/TaskQueuePayload.php | 10 ++- common/oatbox/user/UserLanguageService.php | 3 +- .../user/UserLanguageServiceInterface.php | 4 +- common/oatbox/user/auth/AuthFactory.php | 5 +- .../persistence/class.InMemoryAdvKvDriver.php | 3 +- .../persistence/class.KeyValuePersistence.php | 11 ++- common/persistence/class.PhpFileDriver.php | 80 ++++++++++++++++- common/persistence/class.SqlKvDriver.php | 26 ++++-- common/persistence/sql/SetupDb.php | 5 +- common/persistence/sql/class.Platform.php | 3 +- .../persistence/sql/class.UpdateMultiple.php | 3 +- common/report/class.Report.php | 20 ++++- .../php/class.KeyValueSessionHandler.php | 4 +- common/uri/class.MicrotimeUriProvider.php | 4 +- .../user/auth/class.AuthFailedException.php | 3 +- config/default/ontology.conf.php | 2 + helpers/class.ExtensionHelper.php | 9 +- helpers/class.File.php | 88 +++++++++++++++++-- helpers/class.InstallHelper.php | 3 +- helpers/class.RdfDiff.php | 13 ++- helpers/class.Report.php | 7 +- helpers/class.VersionedFile.php | 7 +- scripts/tools/CleanUpOrphanFiles.php | 21 ++++- .../tools/FileSerializerMigration/Migrate.php | 7 +- .../MigrationHelper.php | 7 +- scripts/update/Updater.php | 4 + 70 files changed, 574 insertions(+), 131 deletions(-) diff --git a/common/cache/class.KeyValueCache.php b/common/cache/class.KeyValueCache.php index b6181749c..f2d444216 100644 --- a/common/cache/class.KeyValueCache.php +++ b/common/cache/class.KeyValueCache.php @@ -47,7 +47,10 @@ class common_cache_KeyValueCache extends ConfigurableService implements common_c protected function getPersistence() { if (is_null($this->persistence)) { - $this->persistence = $this->getServiceLocator()->get('generis/persistences')->getPersistenceById($this->getOption(self::OPTION_PERSISTENCE)); + $this->persistence = $this + ->getServiceLocator() + ->get('generis/persistences') + ->getPersistenceById($this->getOption(self::OPTION_PERSISTENCE)); } return $this->persistence; } diff --git a/common/cache/class.PartitionedCachable.php b/common/cache/class.PartitionedCachable.php index 04f7e10f8..fca16552f 100644 --- a/common/cache/class.PartitionedCachable.php +++ b/common/cache/class.PartitionedCachable.php @@ -126,7 +126,10 @@ public function __sleep() } } if ($containsNonSerializable && $containsSerializable) { - throw new common_exception_Error('Serializable ' . $this->getSerial() . ' mixed serializable and non serializable values in property ' . $propertyName); + throw new common_exception_Error( + 'Serializable ' . $this->getSerial() + . ' mixed serializable and non serializable values in property ' . $propertyName + ); } } else { if (is_object($value) && $value instanceof self) { diff --git a/common/class.Collection.php b/common/class.Collection.php index e203e5d64..fd600803c 100644 --- a/common/class.Collection.php +++ b/common/class.Collection.php @@ -319,7 +319,11 @@ public function intersect(common_Collection $collection) $returnValue = new common_Collection(new common_Object(__METHOD__)); - $returnValue->sequence = array_uintersect($this->sequence, $collection->sequence, 'core_kernel_classes_ContainerComparator::compare'); + $returnValue->sequence = array_uintersect( + $this->sequence, + $collection->sequence, + 'core_kernel_classes_ContainerComparator::compare' + ); return $returnValue; diff --git a/common/class.Utils.php b/common/class.Utils.php index c790d3619..00f356cd4 100644 --- a/common/class.Utils.php +++ b/common/class.Utils.php @@ -64,7 +64,13 @@ public static function isUri($strarg) $returnValue = (bool) false; $uri = trim($strarg); if (!empty($uri)) { - if ((preg_match("/^(http|https|file|ftp):\/\/[\/:.A-Za-z0-9_-]+#[A-Za-z0-9_-]+$/", $uri) && strpos($uri, '#') > 0) || strpos($uri, "#") === 0) { + if ( + ( + preg_match("/^(http|https|file|ftp):\/\/[\/:.A-Za-z0-9_-]+#[A-Za-z0-9_-]+$/", $uri) + && strpos($uri, '#') > 0 + ) + || strpos($uri, "#") === 0 + ) { $returnValue = true; } } @@ -156,7 +162,9 @@ public static function toPHPVariableString($value) break; default: // resource and unexpected types - throw new common_exception_Error("Could not convert variable of type " . gettype($value) . " to PHP variable string"); + throw new common_exception_Error( + "Could not convert variable of type " . gettype($value) . " to PHP variable string" + ); } return (string) $returnValue; diff --git a/common/configuration/class.ComponentCollection.php b/common/configuration/class.ComponentCollection.php index 3da3754ce..0c8544cbb 100644 --- a/common/configuration/class.ComponentCollection.php +++ b/common/configuration/class.ComponentCollection.php @@ -211,7 +211,8 @@ public function check() array_push($traversed, $node); // mark the node as 'traversed'. if ($status == common_configuration_Report::VALID) { - $stack = self::pushTransitionsOnStack($stack, $this->getTransitions($node)); // put all transitions from the node to stack. + // put all transitions from the node to stack. + $stack = self::pushTransitionsOnStack($stack, $this->getTransitions($node)); while (count($stack) > 0) { $transition = array_pop($stack); @@ -232,7 +233,9 @@ public function check() $returnValue = $this->getReports(); } else { - throw new common_configuration_CyclicDependencyException("The dependency graph is cyclic. Please review your dependencies."); + throw new common_configuration_CyclicDependencyException( + "The dependency graph is cyclic. Please review your dependencies." + ); } } diff --git a/common/configuration/class.ComponentFactory.php b/common/configuration/class.ComponentFactory.php index 03383d4d8..63251c97b 100644 --- a/common/configuration/class.ComponentFactory.php +++ b/common/configuration/class.ComponentFactory.php @@ -254,7 +254,15 @@ public static function buildFromArray($array) if (!empty($array)) { if (!empty($array['type'])) { - $acceptedTypes = ['PHPRuntime', 'PHPINIValue', 'PHPExtension', 'PHPDatabaseDriver', 'FileSystemComponent', 'Custom', 'Mock']; + $acceptedTypes = [ + 'PHPRuntime', + 'PHPINIValue', + 'PHPExtension', + 'PHPDatabaseDriver', + 'FileSystemComponent', + 'Custom', + 'Mock' + ]; $cleanType = preg_replace('/^Check/i', '', $array['type']); if (in_array($cleanType, $acceptedTypes)) { if (!empty($array['value'])) { @@ -334,7 +342,11 @@ public static function buildFromArray($array) throw new common_configuration_ComponentFactoryException($msg); } - $returnValue = self::buildFileSystemComponent($values['location'], $values['rights'], $optional); + $returnValue = self::buildFileSystemComponent( + $values['location'], + $values['rights'], + $optional + ); break; case 'Custom': diff --git a/common/configuration/class.FileSystemComponent.php b/common/configuration/class.FileSystemComponent.php index 4f769476f..4dc94847e 100644 --- a/common/configuration/class.FileSystemComponent.php +++ b/common/configuration/class.FileSystemComponent.php @@ -84,8 +84,13 @@ class common_configuration_FileSystemComponent extends common_configuration_Comp * @throws common_configuration_MalformedRightsException * @return mixed */ - public function __construct($location, $expectedRights, $optional = false, $recursive = false, $mustCheckIfEmpty = false) - { + public function __construct( + $location, + $expectedRights, + $optional = false, + $recursive = false, + $mustCheckIfEmpty = false + ) { parent::__construct('tao.configuration.filesystem', $optional); $this->setExpectedRights($expectedRights); @@ -275,7 +280,8 @@ public function check() return new common_configuration_Report( common_configuration_Report::VALID, - "File system component '${name}' in '${location} is compliant with expected rights (${expectedRights}).'", + "File system component '${name}' in '${location} is compliant with expected rights " + . "(${expectedRights}).'", $this ); } @@ -304,7 +310,9 @@ private function hasLocationAccess($location = null, $rule = 'Readable') $funcName = 'is_' . strtolower($rule); $returnValue = $funcName($location); } else { - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($location, \RecursiveDirectoryIterator::SKIP_DOTS)); + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($location, \RecursiveDirectoryIterator::SKIP_DOTS) + ); try { $method = 'is' . $rule; diff --git a/common/configuration/class.Mock.php b/common/configuration/class.Mock.php index daca452f3..5bb95f26a 100644 --- a/common/configuration/class.Mock.php +++ b/common/configuration/class.Mock.php @@ -57,8 +57,9 @@ class common_configuration_Mock extends common_configuration_Component * * @access public * @author Jerome Bogaerts, - * @param int expectedStatus The expected status of the report that will be provided by the check method. Must correspond to a constant of the Report class. - * @param string name The name of the mock configuration component to make it identifiable among others. + * @param int $expectedStatus The expected status of the report that will be provided by the check method. Must + * correspond to a constant of the Report class. + * @param string $name The name of the mock configuration component to make it identifiable among others. * @return mixed */ public function __construct($expectedStatus, $name) diff --git a/common/exception/class.ClientException.php b/common/exception/class.ClientException.php index 63e3abc12..3e97b3443 100644 --- a/common/exception/class.ClientException.php +++ b/common/exception/class.ClientException.php @@ -24,7 +24,8 @@ * @package generis */ -abstract class common_exception_ClientException extends common_Exception implements common_exception_UserReadableException +abstract class common_exception_ClientException extends common_Exception implements + common_exception_UserReadableException { public function __construct($message = null, $code = 0) { diff --git a/common/exception/class.InvalidArgumentType.php b/common/exception/class.InvalidArgumentType.php index f6d21efc0..e3189080f 100644 --- a/common/exception/class.InvalidArgumentType.php +++ b/common/exception/class.InvalidArgumentType.php @@ -57,7 +57,8 @@ public function __construct($class = null, $function = 0, $position = 0, $expect { $object = is_object($object) ? get_class($object) : gettype($object); - $message = 'Argument ' . $position . ' passed to ' . $class . '::' . $function . '() must be an ' . $expectedType . ', ' . $object . ' given'; + $message = 'Argument ' . $position . ' passed to ' . $class . '::' . $function . '() must be an ' + . $expectedType . ', ' . $object . ' given'; parent::__construct($message); } } diff --git a/common/exception/class.ResourceNotFound.php b/common/exception/class.ResourceNotFound.php index 752abdc39..a65a86370 100644 --- a/common/exception/class.ResourceNotFound.php +++ b/common/exception/class.ResourceNotFound.php @@ -18,7 +18,8 @@ * Copyright (c) 2019 (original work) Open Assessment Technologies SA ; */ -class common_exception_ResourceNotFound extends \common_exception_NotFound implements \common_exception_UserReadableException +class common_exception_ResourceNotFound extends \common_exception_NotFound implements + \common_exception_UserReadableException { /** * @inheritdoc diff --git a/common/ext/class.Extension.php b/common/ext/class.Extension.php index 945d725da..0a06bf1ff 100755 --- a/common/ext/class.Extension.php +++ b/common/ext/class.Extension.php @@ -384,7 +384,10 @@ public function getManifest() if (is_file($manifestFile) && is_readable($manifestFile)) { $this->manifest = new Manifest($manifestFile); } else { - throw new ManifestNotFoundException("Extension Manifest not found for extension '" . $this->id . "'.", $this->id); + throw new ManifestNotFoundException( + "Extension Manifest not found for extension '" . $this->id . "'.", + $this->id + ); } } $this->manifest->setServiceLocator($this->getServiceLocator()); @@ -418,7 +421,10 @@ public function load() $this->getExtensionManager()->getExtensionById($extId); } } catch (ManifestNotFoundException $e) { - throw new common_ext_MissingExtensionException($e->getExtensionId() . ' not found but required for ' . $this->getId(), $e->getExtensionId()); + throw new common_ext_MissingExtensionException( + $e->getExtensionId() . ' not found but required for ' . $this->getId(), + $e->getExtensionId() + ); } $loader = new common_ext_ExtensionLoader($this); diff --git a/common/ext/class.ExtensionHandler.php b/common/ext/class.ExtensionHandler.php index 5e8f6735d..9803a671c 100644 --- a/common/ext/class.ExtensionHandler.php +++ b/common/ext/class.ExtensionHandler.php @@ -75,7 +75,10 @@ protected function getExtension() */ protected function runExtensionScript($script, array $arguments = []) { - $this->log('d', 'Running custom extension script ' . $script . ' for extension ' . $this->getExtension()->getId()); + $this->log( + 'd', + 'Running custom extension script ' . $script . ' for extension ' . $this->getExtension()->getId() + ); if (file_exists($script)) { require_once $script; } elseif (class_exists($script) && is_subclass_of($script, \oat\oatbox\action\Action::class)) { diff --git a/common/ext/class.ExtensionInstaller.php b/common/ext/class.ExtensionInstaller.php index 1fc21cba1..ccad6dac4 100755 --- a/common/ext/class.ExtensionInstaller.php +++ b/common/ext/class.ExtensionInstaller.php @@ -195,10 +195,19 @@ protected function installCustomScript() foreach ($this->extension->getManifest()->getInstallPHPFiles() as $script) { if (is_string($script)) { $this->runExtensionScript($script); - } elseif (is_array($script) && isset($script[0]) && is_string($script[0]) && !empty($script[0]) && isset($script[1]) && is_array($script[1])) { + } elseif ( + is_array($script) + && isset($script[0]) + && is_string($script[0]) + && !empty($script[0]) + && isset($script[1]) + && is_array($script[1]) + ) { $this->runExtensionScript($script[0], $script[1]); } else { - \common_Logger::w("Ignored custom install script because it's call definition is malformed in extension manifest!"); + \common_Logger::w( + "Ignored custom install script because it's call definition is malformed in extension manifest!" + ); } } } diff --git a/common/ext/class.ExtensionModel.php b/common/ext/class.ExtensionModel.php index d0ed1f902..fb8ff7961 100644 --- a/common/ext/class.ExtensionModel.php +++ b/common/ext/class.ExtensionModel.php @@ -40,11 +40,15 @@ public function addModelFiles($extension) { foreach ($extension->getManifest()->getInstallModelFiles() as $rdfpath) { if (!file_exists($rdfpath)) { - throw new common_ext_InstallationException("Unable to load ontology in '${rdfpath}' because the file does not exist."); + throw new common_ext_InstallationException( + "Unable to load ontology in '${rdfpath}' because the file does not exist." + ); } if (!is_readable($rdfpath)) { - throw new common_ext_InstallationException("Unable to load ontology in '${rdfpath}' because the file is not readable."); + throw new common_ext_InstallationException( + "Unable to load ontology in '${rdfpath}' because the file is not readable." + ); } $iterator = new FileIterator($rdfpath); diff --git a/common/ext/class.ExtensionUninstaller.php b/common/ext/class.ExtensionUninstaller.php index bfb53ebd7..f086390ee 100755 --- a/common/ext/class.ExtensionUninstaller.php +++ b/common/ext/class.ExtensionUninstaller.php @@ -49,17 +49,23 @@ public function uninstall() // uninstall possible if (is_null($this->extension->getManifest()->getUninstallData())) { - throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Uninstall not supported'); + throw new common_Exception( + 'Problem uninstalling extension ' . $this->extension->getId() . ' : Uninstall not supported' + ); } // installed? if (!common_ext_ExtensionsManager::singleton()->isInstalled($this->extension->getId())) { - throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Not installed'); + throw new common_Exception( + 'Problem uninstalling extension ' . $this->extension->getId() . ' : Not installed' + ); } // check dependcies if (helpers_ExtensionHelper::isRequired($this->extension)) { - throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Still required'); + throw new common_Exception( + 'Problem uninstalling extension ' . $this->extension->getId() . ' : Still required' + ); }; common_Logger::d('uninstall script for ' . $this->extension->getId()); diff --git a/common/ext/class.ExtensionUpdater.php b/common/ext/class.ExtensionUpdater.php index f723f30d2..44aa8306f 100644 --- a/common/ext/class.ExtensionUpdater.php +++ b/common/ext/class.ExtensionUpdater.php @@ -149,7 +149,10 @@ public function safeLoadService($configId) } else { $namespace = substr($class_name, 0, $split); $class = substr($class_name, $split + 1); - eval('namespace ' . $namespace . '; ' . 'class ' . $class . ' extends \\oat\\oatbox\\service\\ConfigurableService {}'); + eval( + 'namespace ' . $namespace . '; ' . 'class ' . $class + . ' extends \\oat\\oatbox\\service\\ConfigurableService {}' + ); } }; $serviceManager = $this->getServiceManager(); diff --git a/common/ext/class.GenerisInstaller.php b/common/ext/class.GenerisInstaller.php index 62354afbc..201c6a442 100644 --- a/common/ext/class.GenerisInstaller.php +++ b/common/ext/class.GenerisInstaller.php @@ -49,7 +49,9 @@ class common_ext_GenerisInstaller extends common_ext_ExtensionInstaller public function install() { if ($this->extension->getId() != 'generis') { - throw new common_ext_ExtensionException('Tried to install "' . $this->extension->getId() . '" extension using the GenerisInstaller'); + throw new common_ext_ExtensionException( + 'Tried to install "' . $this->extension->getId() . '" extension using the GenerisInstaller' + ); } $this->installLoadDefaultConfig(); diff --git a/common/ext/class.UpdateExtensions.php b/common/ext/class.UpdateExtensions.php index bd87692b5..fdfee1ade 100644 --- a/common/ext/class.UpdateExtensions.php +++ b/common/ext/class.UpdateExtensions.php @@ -72,7 +72,9 @@ public function __invoke($params) $report->add(new Report(Report::TYPE_ERROR, $ex->getMessage())); break; } catch (Exception $e) { - $this->logError('Exception during update of ' . $ext->getId() . ': ' . get_class($e) . ' "' . $e->getMessage() . '"'); + $this->logError( + 'Exception during update of ' . $ext->getId() . ': ' . get_class($e) . ' "' . $e->getMessage() . '"' + ); $report->setType(Report::TYPE_ERROR); $report->setMessage('Update failed'); $report->add(new Report(Report::TYPE_ERROR, 'Exception during update of ' . $ext->getId() . '.')); @@ -99,7 +101,10 @@ protected function updateExtension(common_ext_Extension $ext) $installed = $this->getExtensionManager()->getInstalledVersion($ext->getId()); $codeVersion = $ext->getVersion(); if ($installed !== $codeVersion) { - $report = new Report(Report::TYPE_INFO, $ext->getName() . ' requires update from ' . $installed . ' to ' . $codeVersion); + $report = new Report( + Report::TYPE_INFO, + $ext->getName() . ' requires update from ' . $installed . ' to ' . $codeVersion + ); try { $updater = $ext->getUpdater(); $returnedVersion = $updater->update($installed); @@ -147,7 +152,9 @@ protected function updateExtension(common_ext_Extension $ext) protected function getMissingExtensions() { - $missingId = \helpers_ExtensionHelper::getMissingExtensionIds($this->getExtensionManager()->getInstalledExtensions()); + $missingId = \helpers_ExtensionHelper::getMissingExtensionIds( + $this->getExtensionManager()->getInstalledExtensions() + ); $missingExt = []; foreach ($missingId as $extId) { diff --git a/common/http/class.Request.php b/common/http/class.Request.php index 5ec4e0cee..aabe59081 100755 --- a/common/http/class.Request.php +++ b/common/http/class.Request.php @@ -39,7 +39,8 @@ class common_http_Request * The scheme in used (http|https) will be derived from * * * $_SERVER['HTTPS'] in case of a standard deployment - * * $_SERVER['HTTP_X_FORWARDED_PROTO'] or $_SERVER['HTTP_X_FORWARDED_SSL'] in case of being deployed behing a load balancer/proxy. + * * $_SERVER['HTTP_X_FORWARDED_PROTO'] or $_SERVER['HTTP_X_FORWARDED_SSL'] in case of being deployed behing a load + * balancer/proxy. * * If no clues about whether HTTPS is in use are found, HTTP will be the scheme of the current request. * diff --git a/common/http/class.Response.php b/common/http/class.Response.php index fb670c8d4..cd51dec3b 100755 --- a/common/http/class.Response.php +++ b/common/http/class.Response.php @@ -30,7 +30,9 @@ class common_http_Response { public $httpCode; - public $headerOut; //CURLINFO_HEADER_OUT The request string sent. For this to work, add the CURLINFO_HEADER_OUT option to the handle by calling curl_setopt() + // CURLINFO_HEADER_OUT The request string sent. For this to work, add the CURLINFO_HEADER_OUT option to the handle + // by calling curl_setopt() + public $headerOut; public $effectiveUrl; // Last effective URL public $responseData; } diff --git a/common/oatbox/Configurable.php b/common/oatbox/Configurable.php index 6107a365f..036af79f8 100644 --- a/common/oatbox/Configurable.php +++ b/common/oatbox/Configurable.php @@ -72,7 +72,9 @@ public function setOptions(array $options) if (is_object($options) && method_exists($options, 'toArray')) { $options = $options->toArray(); } else { - throw new \common_exception_Error('Options submitted to ' . get_called_class() . ' must be an array or implement toArray'); + throw new \common_exception_Error( + 'Options submitted to ' . get_called_class() . ' must be an array or implement toArray' + ); } } $this->options = $options; diff --git a/common/oatbox/action/ActionService.php b/common/oatbox/action/ActionService.php index a2974480d..c4bb0797b 100644 --- a/common/oatbox/action/ActionService.php +++ b/common/oatbox/action/ActionService.php @@ -29,7 +29,10 @@ class ActionService extends ConfigurableService { public const SERVICE_ID = 'generis/actionService'; - public static $blackList = ['\\oatbox\\composer\\ExtensionInstaller','\\oatbox\\composer\\ExtensionInstallerPlugin']; + public static $blackList = [ + '\\oatbox\\composer\\ExtensionInstaller', + '\\oatbox\\composer\\ExtensionInstallerPlugin' + ]; /** * @@ -55,7 +58,12 @@ public function getAvailableActions() $actions = $this->getCache()->get(__FUNCTION__); if (is_null($actions)) { $actions = []; - foreach ($this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->getInstalledExtensions() as $ext) { + $installedExtensions = $this + ->getServiceLocator() + ->get(common_ext_ExtensionsManager::SERVICE_ID) + ->getInstalledExtensions(); + + foreach ($installedExtensions as $ext) { $actions = array_merge($actions, $this->getActionsInDirectory($ext->getDir())); } $actions = array_merge($actions, $this->getActionsInDirectory(VENDOR_PATH . 'oat-sa')); diff --git a/common/oatbox/cache/KeyValueCache.php b/common/oatbox/cache/KeyValueCache.php index 666597fda..b7adf2245 100644 --- a/common/oatbox/cache/KeyValueCache.php +++ b/common/oatbox/cache/KeyValueCache.php @@ -93,7 +93,10 @@ protected function dateIntervalToSeconds(DateInterval $dateInterval): int protected function getPersistence() { if (is_null($this->persistence)) { - $this->persistence = $this->getServiceLocator()->get(PersistenceManager::SERVICE_ID)->getPersistenceById($this->getOption(self::OPTION_PERSISTENCE)); + $this->persistence = $this + ->getServiceLocator() + ->get(PersistenceManager::SERVICE_ID) + ->getPersistenceById($this->getOption(self::OPTION_PERSISTENCE)); } return $this->persistence; } diff --git a/common/oatbox/extension/Manifest.php b/common/oatbox/extension/Manifest.php index ac303e89d..aafdd1b8b 100644 --- a/common/oatbox/extension/Manifest.php +++ b/common/oatbox/extension/Manifest.php @@ -82,12 +82,16 @@ public function __construct($filePath, ComposerInfo $composerInfo = null) { // the file exists, we can refer to the $filePath. if (!is_readable($filePath)) { - throw new ManifestNotFoundException("The Extension Manifest file located at '${filePath}' could not be read."); + throw new ManifestNotFoundException( + "The Extension Manifest file located at '${filePath}' could not be read." + ); } $this->manifest = require($filePath); // mandatory if (empty($this->manifest['name'])) { - throw new exception\MalformedManifestException("The 'name' component is mandatory in manifest located at '{$this->filePath}'."); + throw new exception\MalformedManifestException( + "The 'name' component is mandatory in manifest located at '{$this->filePath}'." + ); } $this->composerInfo = $composerInfo; $this->filePath = $filePath; @@ -198,7 +202,9 @@ public function getInstallPHPFiles(): array { $result = []; if (isset($this->manifest['install']['php'])) { - $result = is_array($this->manifest['install']['php']) ? $this->manifest['install']['php'] : [$this->manifest['install']['php']]; + $result = is_array($this->manifest['install']['php']) + ? $this->manifest['install']['php'] + : [$this->manifest['install']['php']]; } return $result; } @@ -306,7 +312,9 @@ public static function extractChecks(string $file) { // the file exists, we can refer to the $filePath. if (!is_readable($file)) { - throw new ManifestNotFoundException(sprintf('The Extension Manifest file located at %s could not be read.', $file)); + throw new ManifestNotFoundException( + sprintf('The Extension Manifest file located at %s could not be read.', $file) + ); } $manifest = require($file); diff --git a/common/oatbox/extension/script/OptionContainer.php b/common/oatbox/extension/script/OptionContainer.php index e4d4fa873..d13c3e689 100644 --- a/common/oatbox/extension/script/OptionContainer.php +++ b/common/oatbox/extension/script/OptionContainer.php @@ -137,7 +137,10 @@ private static function extract(array $options, array $values) } else { // Edge case. Option found, but it is the last value of the $value array. if ($required) { - throw new MissingOptionException("No value given for required argument '${optionName}'.", $optionName); + throw new MissingOptionException( + "No value given for required argument '${optionName}'.", + $optionName + ); } elseif (isset($optionParams['defaultValue'])) { $returnValue[$optionName] = self::cast($optionParams['defaultValue'], $castTo); } diff --git a/common/oatbox/extension/script/ScriptAction.php b/common/oatbox/extension/script/ScriptAction.php index afca61a69..5c2721626 100644 --- a/common/oatbox/extension/script/ScriptAction.php +++ b/common/oatbox/extension/script/ScriptAction.php @@ -126,7 +126,10 @@ private function displayUsage(array $params) if (!empty($usageDescription) && is_array($usageDescription)) { if (!empty($usageDescription['prefix']) && in_array('-' . $usageDescription['prefix'], $params)) { return true; - } elseif (!empty($usageDescription['longPrefix']) && in_array('--' . $usageDescription['longPrefix'], $params)) { + } elseif ( + !empty($usageDescription['longPrefix']) + && in_array('--' . $usageDescription['longPrefix'], $params) + ) { return true; } } diff --git a/common/oatbox/filesystem/Directory.php b/common/oatbox/filesystem/Directory.php index 1b836afff..be239d313 100644 --- a/common/oatbox/filesystem/Directory.php +++ b/common/oatbox/filesystem/Directory.php @@ -186,15 +186,22 @@ public function rename($path) foreach ($filePaths as $renaming) { try { if ($this->getFileSystem()->rename($renaming['source'], $renaming['destination']) === false) { - throw new \common_exception_FileSystemError("Unable to rename '" . $renaming['source'] . "' into '" . $renaming['destination'] . "'."); + throw new \common_exception_FileSystemError( + "Unable to rename '" . $renaming['source'] . "' into '" . $renaming['destination'] . "'." + ); } } catch (FileExistsException $e) { - throw new \common_exception_FileSystemError("Unable to rename '" . $renaming['source'] . "' into '" . $renaming['destination'] . "'. File already exists."); + throw new \common_exception_FileSystemError( + "Unable to rename '" . $renaming['source'] . "' into '" . $renaming['destination'] + . "'. File already exists." + ); } } if (!$this->deleteSelf()) { - throw new \common_exception_FileSystemError("Could not finalize renaming of '" . $this->getPrefix() . "' into '${path}'."); + throw new \common_exception_FileSystemError( + "Could not finalize renaming of '" . $this->getPrefix() . "' into '${path}'." + ); } return true; diff --git a/common/oatbox/filesystem/File.php b/common/oatbox/filesystem/File.php index 1503bf64c..7ccdba8fc 100644 --- a/common/oatbox/filesystem/File.php +++ b/common/oatbox/filesystem/File.php @@ -121,7 +121,9 @@ public function write($mixed, $mimeType = null) $resource = StreamWrapper::getResource($mixed); if (!is_resource($resource)) { - throw new \common_Exception('Unable to create resource from the given stream. Write to filesystem aborted.'); + throw new \common_Exception( + 'Unable to create resource from the given stream. Write to filesystem aborted.' + ); } return $this->getFileSystem()->writeStream($this->getPrefix(), $resource, $config); } else { @@ -169,7 +171,9 @@ public function update($mixed, $mimeType = null) $resource = StreamWrapper::getResource($mixed); if (!is_resource($resource)) { - throw new \common_Exception('Unable to create resource from the given stream. Write to filesystem aborted.'); + throw new \common_Exception( + 'Unable to create resource from the given stream. Write to filesystem aborted.' + ); } return $this->getFileSystem()->updateStream($this->getPrefix(), $resource, $config); } @@ -211,7 +215,9 @@ public function put($mixed, $mimeType = null) $resource = StreamWrapper::getResource($mixed); if (!is_resource($resource)) { - throw new \common_Exception('Unable to create resource from the given stream. Write to filesystem aborted.'); + throw new \common_Exception( + 'Unable to create resource from the given stream. Write to filesystem aborted.' + ); } return $this->getFileSystem()->putStream($this->getPrefix(), $resource, $config); } diff --git a/common/oatbox/install/Installer.php b/common/oatbox/install/Installer.php index ff712b964..82767f475 100755 --- a/common/oatbox/install/Installer.php +++ b/common/oatbox/install/Installer.php @@ -115,7 +115,10 @@ protected function installFilesystem() public function setupExtensionManager(): void { - $this->getServiceManager()->register(\common_ext_ExtensionsManager::SERVICE_ID, new \common_ext_ExtensionsManager()); + $this->getServiceManager()->register( + \common_ext_ExtensionsManager::SERVICE_ID, + new \common_ext_ExtensionsManager() + ); } /** diff --git a/common/oatbox/log/ContainerLoggerTrait.php b/common/oatbox/log/ContainerLoggerTrait.php index 88f374f17..7352e7ebe 100644 --- a/common/oatbox/log/ContainerLoggerTrait.php +++ b/common/oatbox/log/ContainerLoggerTrait.php @@ -48,7 +48,8 @@ public function initContainer($container, $key = '') $this->getContainer()->offsetGet(LoggerService::SERVICE_ID)->getLogger() ); - // @TODO: implemented because of the legacy, we will don't need it when we're using the container in every case. + // @TODO: implemented because of the legacy, we will don't need it when we're using the container in every + // case. if (!empty($key)) { try { return $this->getContainer()->offsetGet($key); diff --git a/common/oatbox/log/LoggerAggregator.php b/common/oatbox/log/LoggerAggregator.php index 1a6fa7fbc..1b076d1b9 100644 --- a/common/oatbox/log/LoggerAggregator.php +++ b/common/oatbox/log/LoggerAggregator.php @@ -53,7 +53,9 @@ public function __construct($options = []) foreach ($this->getOptions() as $logger) { if (!$logger instanceof LoggerInterface) { - throw new \common_Exception('Non PSR-3 compatible logger ' . get_class($logger) . ' added to ' . __CLASS__); + throw new \common_Exception( + 'Non PSR-3 compatible logger ' . get_class($logger) . ' added to ' . __CLASS__ + ); } } diff --git a/common/oatbox/log/StreamHandler.php b/common/oatbox/log/StreamHandler.php index db1fcd2a8..623ce3814 100644 --- a/common/oatbox/log/StreamHandler.php +++ b/common/oatbox/log/StreamHandler.php @@ -50,8 +50,10 @@ class StreamHandler extends MonologStreamHandler public const PARAM_LOG_LEVEL = '--log-level'; /** - * @param resource|string $defaultStream (Unless this parameter is specified on the command line as --log-file, otherwise it is ignored) resource where data will be output - * @param int $defaultLevel (Unless this parameter is specified on the command line as --log-level, otherwise it is ignored) The minimum logging level at which this handler will be triggered + * @param resource|string $defaultStream (Unless this parameter is specified on the command line as --log-file, + * otherwise it is ignored) resource where data will be output + * @param int $defaultLevel (Unless this parameter is specified on the command line as --log-level, otherwise it is + * ignored) The minimum logging level at which this handler will be triggered * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) * @param bool $useLocking Try to lock log file before doing any writes @@ -59,8 +61,13 @@ class StreamHandler extends MonologStreamHandler * @throws \Exception If a missing directory is not buildable * @throws \InvalidArgumentException If stream is not a resource or string */ - public function __construct($defaultStream, int $defaultLevel = Logger::DEBUG, bool $bubble = true, $filePermission = null, bool $useLocking = false) - { + public function __construct( + $defaultStream, + int $defaultLevel = Logger::DEBUG, + bool $bubble = true, + $filePermission = null, + bool $useLocking = false + ) { $stream = $this->getScriptParameter(self::PARAM_LOG_FILE) ?: $defaultStream; $logLevel = $this->getLogLevelParameter() ?: $defaultLevel; parent::__construct($stream, $logLevel, $bubble, $filePermission, $useLocking); @@ -92,7 +99,12 @@ private function getLogLevelParameter(): ?int $errorLevels = Logger::getLevels(); if (!isset($errorLevels[$logLevelParameter])) { - throw new \Exception(sprintf('Such log level doesn`t exist. Please, use one of: %s', implode(', ', array_flip($errorLevels)))); + throw new \Exception( + sprintf( + 'Such log level doesn`t exist. Please, use one of: %s', + implode(', ', array_flip($errorLevels)) + ) + ); } return $errorLevels[$logLevelParameter]; diff --git a/common/oatbox/log/logger/TaoLog.php b/common/oatbox/log/logger/TaoLog.php index f36108d8b..0eec2feb8 100644 --- a/common/oatbox/log/logger/TaoLog.php +++ b/common/oatbox/log/logger/TaoLog.php @@ -95,7 +95,18 @@ public function log($level, $message, array $context = []) $message = (string) $message; } $level = \common_log_Logger2Psr::getCommonFromPsrLevel($level); - $this->getDispatcher()->log(new \common_log_Item($message, $level, time(), $stack, $context, $requestURI, $errorFile, $errorLine)); + $this->getDispatcher()->log( + new \common_log_Item( + $message, + $level, + time(), + $stack, + $context, + $requestURI, + $errorFile, + $errorLine + ) + ); } /** diff --git a/common/oatbox/log/logger/TaoMonolog.php b/common/oatbox/log/logger/TaoMonolog.php index a35640a59..fd0ea2428 100644 --- a/common/oatbox/log/logger/TaoMonolog.php +++ b/common/oatbox/log/logger/TaoMonolog.php @@ -78,7 +78,9 @@ protected function buildLogger() if ($this->hasOption('processors')) { $processorsOptions = $this->getOption('processors'); if (!is_array($processorsOptions)) { - throw new \common_configuration_ComponentFactoryException('Handler processors options as to be formatted as array'); + throw new \common_configuration_ComponentFactoryException( + 'Handler processors options as to be formatted as array' + ); } foreach ($processorsOptions as $processorsOption) { @@ -97,11 +99,15 @@ protected function buildLogger() protected function buildHandler(array $options) { if (!isset($options['class'])) { - throw new \common_configuration_ComponentFactoryException('Handler options has to contain a class attribute.'); + throw new \common_configuration_ComponentFactoryException( + 'Handler options has to contain a class attribute.' + ); } if (!is_a($options['class'], HandlerInterface::class, true)) { - throw new \common_configuration_ComponentFactoryException('Handler class option has to be a HandlerInterface.'); + throw new \common_configuration_ComponentFactoryException( + 'Handler class option has to be a HandlerInterface.' + ); } $handlerOptions = []; @@ -114,7 +120,9 @@ protected function buildHandler(array $options) if (isset($options['processors'])) { $processorsOptions = $options['processors']; if (!is_array($processorsOptions)) { - throw new \common_configuration_ComponentFactoryException('Handler processors options as to be formatted as array'); + throw new \common_configuration_ComponentFactoryException( + 'Handler processors options as to be formatted as array' + ); } foreach ($processorsOptions as $processorsOption) { @@ -140,7 +148,9 @@ protected function buildProcessor($options) return $options; } else { if (!isset($options['class'])) { - throw new \common_configuration_ComponentFactoryException('Processor options has to contain a class attribute.'); + throw new \common_configuration_ComponentFactoryException( + 'Processor options has to contain a class attribute.' + ); } $processorOptions = []; @@ -166,11 +176,15 @@ protected function buildFormatter($options) return $options; } else { if (!isset($options['class'])) { - throw new \common_configuration_ComponentFactoryException('Formatter options has to contain a class attribute.'); + throw new \common_configuration_ComponentFactoryException( + 'Formatter options has to contain a class attribute.' + ); } if (!is_a($options['class'], FormatterInterface::class, true)) { - throw new \common_configuration_ComponentFactoryException('Formatter class option has to be a FormatterInterface.'); + throw new \common_configuration_ComponentFactoryException( + 'Formatter class option has to be a FormatterInterface.' + ); } $formatterOptions = []; diff --git a/common/oatbox/service/ServiceConfigDriver.php b/common/oatbox/service/ServiceConfigDriver.php index e21533ccf..255d65b15 100644 --- a/common/oatbox/service/ServiceConfigDriver.php +++ b/common/oatbox/service/ServiceConfigDriver.php @@ -46,7 +46,8 @@ protected function getContent($key, $value) if (! $value instanceof ConfigurableService) { return null; } - $content = $value->getHeader() . PHP_EOL . "return " . common_Utils::toHumanReadablePhpString($value) . ";" . PHP_EOL; + $content = $value->getHeader() . PHP_EOL . "return " . common_Utils::toHumanReadablePhpString($value) . ";" + . PHP_EOL; return $content; } diff --git a/common/oatbox/service/SimpleConfigDriver.php b/common/oatbox/service/SimpleConfigDriver.php index b0ab436b5..4adada39c 100644 --- a/common/oatbox/service/SimpleConfigDriver.php +++ b/common/oatbox/service/SimpleConfigDriver.php @@ -38,7 +38,8 @@ class SimpleConfigDriver extends common_persistence_PhpFileDriver implements Con */ protected function getContent($key, $value) { - return $this->getDefaultHeader($key) . PHP_EOL . "return " . common_Utils::toHumanReadablePhpString($value) . ";" . PHP_EOL; + return $this->getDefaultHeader($key) . PHP_EOL . "return " . common_Utils::toHumanReadablePhpString($value) + . ";" . PHP_EOL; } /** diff --git a/common/oatbox/task/AbstractTaskAction.php b/common/oatbox/task/AbstractTaskAction.php index 949db475c..4fd806792 100644 --- a/common/oatbox/task/AbstractTaskAction.php +++ b/common/oatbox/task/AbstractTaskAction.php @@ -30,7 +30,8 @@ * * @author Aleh Hutnikau * - * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\tao\model\taskQueue\Task\FilesystemAwareTrait instead. + * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\tao\model\taskQueue\Task\FilesystemAwareTrait + * instead. */ abstract class AbstractTaskAction extends AbstractAction { diff --git a/common/oatbox/task/Queue.php b/common/oatbox/task/Queue.php index a272669ae..4db5d3508 100644 --- a/common/oatbox/task/Queue.php +++ b/common/oatbox/task/Queue.php @@ -33,12 +33,14 @@ interface Queue extends \IteratorAggregate public const CONFIG_ID = 'generis/taskqueue'; /** - * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\tao\model\taskQueue\QueueDispatcherInterface::SERVICE_ID instead. + * @deprecated since version 7.10.0, to be removed in 8.0. Use + * \oat\tao\model\taskQueue\QueueDispatcherInterface::SERVICE_ID instead. */ public const SERVICE_ID = 'generis/taskqueue'; /** - * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\tao\model\taskQueue\QueueDispatcherInterface::FILE_SYSTEM_ID instead. + * @deprecated since version 7.10.0, to be removed in 8.0. Use + * \oat\tao\model\taskQueue\QueueDispatcherInterface::FILE_SYSTEM_ID instead. */ public const FILE_SYSTEM_ID = 'taskQueueStorage'; @@ -47,7 +49,8 @@ interface Queue extends \IteratorAggregate * @param $parameters * @param $label * @param $task - * @param boolean $repeatedly Whether task created repeatedly (for example when execution of task was failed and task puts to the queue again). + * @param boolean $repeatedly Whether task created repeatedly (for example when execution of task was failed and + * task puts to the queue again). * @return mixed * * @deprecated since version 7.10.0, to be removed in 8.0. diff --git a/common/oatbox/task/RunTasks.php b/common/oatbox/task/RunTasks.php index ac43b7a52..11dd12466 100644 --- a/common/oatbox/task/RunTasks.php +++ b/common/oatbox/task/RunTasks.php @@ -44,8 +44,8 @@ class RunTasks extends ConfigurableService implements Action protected $params = []; /** - * @param array $params - * $params[0] (int) tasks limit. If parameter is not given or equals 0 then all tasks in queue will be executed. + * @param array $params $params[0] (int) tasks limit. If parameter is not given or equals 0 then all tasks in queue + * will be executed. * @return \common_report_Report */ public function __invoke($params) diff --git a/common/oatbox/task/TaskInterface/TaskPayLoad.php b/common/oatbox/task/TaskInterface/TaskPayLoad.php index 7b9562112..5fe75b43e 100644 --- a/common/oatbox/task/TaskInterface/TaskPayLoad.php +++ b/common/oatbox/task/TaskInterface/TaskPayLoad.php @@ -30,7 +30,11 @@ */ interface TaskPayLoad extends DatatablePayload, ServiceLocatorAwareInterface { - public function __construct(TaskPersistenceInterface $persistence, $currentUserId = null, DatatableRequestInterface $request = null); + public function __construct( + TaskPersistenceInterface $persistence, + $currentUserId = null, + DatatableRequestInterface $request = null + ); /** * @deprecated since version 7.10.0, to be removed in 8.0. diff --git a/common/oatbox/task/TaskRunner.php b/common/oatbox/task/TaskRunner.php index bbf91b70c..fd3231933 100644 --- a/common/oatbox/task/TaskRunner.php +++ b/common/oatbox/task/TaskRunner.php @@ -29,7 +29,8 @@ use common_report_Report as Report; /** - * @deprecated since version 7.10.0, to be removed in 8.0. Use any implementation of \oat\tao\model\taskQueue\Worker\WorkerInterface instead. + * @deprecated since version 7.10.0, to be removed in 8.0. Use any implementation of + * \oat\tao\model\taskQueue\Worker\WorkerInterface instead. */ class TaskRunner implements TaskRunnerInterface { @@ -42,7 +43,10 @@ public function run(Task $task) { \common_Logger::d('Running task ' . $task->getId()); - $report = new Report(\common_report_Report::TYPE_INFO, __('Running task %s at %s', $task->getId(), microtime(true))); + $report = new Report( + \common_report_Report::TYPE_INFO, + __('Running task %s at %s', $task->getId(), microtime(true)) + ); /** @var TaskQueue $queue */ $queue = $this->getServiceLocator()->get(Queue::SERVICE_ID); $queue->updateTaskStatus($task->getId(), Task::STATUS_RUNNING); diff --git a/common/oatbox/task/implementation/InMemoryQueuePersistence.php b/common/oatbox/task/implementation/InMemoryQueuePersistence.php index 35d57fc6d..4104e01ec 100644 --- a/common/oatbox/task/implementation/InMemoryQueuePersistence.php +++ b/common/oatbox/task/implementation/InMemoryQueuePersistence.php @@ -26,7 +26,8 @@ use Zend\ServiceManager\ServiceLocatorAwareTrait; /** - * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\tao\model\taskQueue\Queue\Broker\InMemoryQueueBroker instead. + * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\tao\model\taskQueue\Queue\Broker\InMemoryQueueBroker + * instead. */ class InMemoryQueuePersistence implements TaskPersistenceInterface { diff --git a/common/oatbox/task/implementation/SyncQueue.php b/common/oatbox/task/implementation/SyncQueue.php index f8426b5d4..02873a34d 100644 --- a/common/oatbox/task/implementation/SyncQueue.php +++ b/common/oatbox/task/implementation/SyncQueue.php @@ -102,10 +102,15 @@ public function linkTask(Task $task, \core_kernel_classes_Resource $resource = n $taskResource = parent::linkTask($task, $resource); $report = $task->getReport(); if (!empty($report)) { - //serialize only two first report levels because sometimes serialized report is huge and it does not fit into `k_po` index of statemetns table. + // serialize only two first report levels because sometimes serialized report is huge and it does not fit + // into `k_po` index of statemetns table. $serializableReport = new Report($report->getType(), $report->getMessage(), $report->getData()); foreach ($report as $subReport) { - $serializableSubReport = new Report($subReport->getType(), $subReport->getMessage(), $subReport->getData()); + $serializableSubReport = new Report( + $subReport->getType(), + $subReport->getMessage(), + $subReport->getData() + ); $serializableReport->add($serializableSubReport); } $taskResource->setPropertyValue( diff --git a/common/oatbox/task/implementation/TaskQueuePayload.php b/common/oatbox/task/implementation/TaskQueuePayload.php index e2afb77a1..3b8fadf31 100644 --- a/common/oatbox/task/implementation/TaskQueuePayload.php +++ b/common/oatbox/task/implementation/TaskQueuePayload.php @@ -17,7 +17,8 @@ use Zend\ServiceManager\ServiceLocatorAwareTrait; /** - * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\tao\model\taskQueue\TaskLog\DataTablePayload instead. + * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\tao\model\taskQueue\TaskLog\DataTablePayload + * instead. */ class TaskQueuePayload implements TaskPayLoad { @@ -91,8 +92,11 @@ public function count() return $this->persistence->count($params); } - public function __construct(TaskPersistenceInterface $persistence, $currentUserId = null, DatatableRequestInterface $request = null) - { + public function __construct( + TaskPersistenceInterface $persistence, + $currentUserId = null, + DatatableRequestInterface $request = null + ) { $this->persistence = $persistence; $this->currentUserId = $currentUserId; diff --git a/common/oatbox/user/UserLanguageService.php b/common/oatbox/user/UserLanguageService.php index 5e2880a1b..7aa2e8d40 100644 --- a/common/oatbox/user/UserLanguageService.php +++ b/common/oatbox/user/UserLanguageService.php @@ -73,7 +73,8 @@ public function getInterfaceLanguage(User $user) */ public function isDataLanguageEnabled() { - return !$this->hasOption(self::OPTION_LOCK_DATA_LANGUAGE) || $this->getOption(self::OPTION_LOCK_DATA_LANGUAGE) === false; + return !$this->hasOption(self::OPTION_LOCK_DATA_LANGUAGE) + || $this->getOption(self::OPTION_LOCK_DATA_LANGUAGE) === false; } public function getAuthoringLanguage(): string diff --git a/common/oatbox/user/UserLanguageServiceInterface.php b/common/oatbox/user/UserLanguageServiceInterface.php index 35415376c..4f19b7fb2 100644 --- a/common/oatbox/user/UserLanguageServiceInterface.php +++ b/common/oatbox/user/UserLanguageServiceInterface.php @@ -53,8 +53,8 @@ public function getInterfaceLanguage(User $user); public function isDataLanguageEnabled(); /** - * When a custom interface language is set, it overrides the interface language retrieved in the getInterfaceLanguage - * method. + * When a custom interface language is set, it overrides the interface language retrieved in the + * getInterfaceLanguage method. * * @param ?string $customInterfaceLanguage */ diff --git a/common/oatbox/user/auth/AuthFactory.php b/common/oatbox/user/auth/AuthFactory.php index 76b899dc6..6417f9ed2 100755 --- a/common/oatbox/user/auth/AuthFactory.php +++ b/common/oatbox/user/auth/AuthFactory.php @@ -43,7 +43,10 @@ public static function createAdapters() if (isset($adapterConf['driver'])) { $className = $adapterConf['driver']; unset($adapterConf['driver']); - if (class_exists($className) && in_array(__NAMESPACE__ . '\LoginAdapter', class_implements($className))) { + if ( + class_exists($className) + && in_array(__NAMESPACE__ . '\LoginAdapter', class_implements($className)) + ) { $adapter = new $className(); $adapter->setOptions($adapterConf); $adapters[] = $adapter; diff --git a/common/persistence/class.InMemoryAdvKvDriver.php b/common/persistence/class.InMemoryAdvKvDriver.php index 04db3ef36..a934183f3 100644 --- a/common/persistence/class.InMemoryAdvKvDriver.php +++ b/common/persistence/class.InMemoryAdvKvDriver.php @@ -19,7 +19,8 @@ * */ -class common_persistence_InMemoryAdvKvDriver extends common_persistence_InMemoryKvDriver implements common_persistence_AdvKvDriver +class common_persistence_InMemoryAdvKvDriver extends common_persistence_InMemoryKvDriver implements + common_persistence_AdvKvDriver { public const HPREFIX = 'hPrfx_'; diff --git a/common/persistence/class.KeyValuePersistence.php b/common/persistence/class.KeyValuePersistence.php index 67a3c04ed..fac94e581 100755 --- a/common/persistence/class.KeyValuePersistence.php +++ b/common/persistence/class.KeyValuePersistence.php @@ -220,8 +220,15 @@ public function purge() * @return mixed * @throws common_Exception */ - protected function setLargeValue($key, $value, $level = 0, $flush = true, $toTransform = true, $ttl = null, $nx = false) - { + protected function setLargeValue( + $key, + $value, + $level = 0, + $flush = true, + $toTransform = true, + $ttl = null, + $nx = false + ) { if (!$this->isLarge($value)) { if ($flush) { $this->set($key, $value, $ttl, $nx); diff --git a/common/persistence/class.PhpFileDriver.php b/common/persistence/class.PhpFileDriver.php index ebf5364d6..a434e8887 100755 --- a/common/persistence/class.PhpFileDriver.php +++ b/common/persistence/class.PhpFileDriver.php @@ -44,7 +44,72 @@ class common_persistence_PhpFileDriver implements common_persistence_KvDriver, c * List of characters permited in filename * @var array */ - private static $ALLOWED_CHARACTERS = ['A' => '','B' => '','C' => '','D' => '','E' => '','F' => '','G' => '','H' => '','I' => '','J' => '','K' => '','L' => '','M' => '','N' => '','O' => '','P' => '','Q' => '','R' => '','S' => '','T' => '','U' => '','V' => '','W' => '','X' => '','Y' => '','Z' => '','a' => '','b' => '','c' => '','d' => '','e' => '','f' => '','g' => '','h' => '','i' => '','j' => '','k' => '','l' => '','m' => '','n' => '','o' => '','p' => '','q' => '','r' => '','s' => '','t' => '','u' => '','v' => '','w' => '','x' => '','y' => '','z' => '',0 => '',1 => '',2 => '',3 => '',4 => '',5 => '',6 => '',7 => '',8 => '',9 => '','_' => '','-' => '']; + private static $ALLOWED_CHARACTERS = [ + 'A' => '', + 'B' => '', + 'C' => '', + 'D' => '', + 'E' => '', + 'F' => '', + 'G' => '', + 'H' => '', + 'I' => '', + 'J' => '', + 'K' => '', + 'L' => '', + 'M' => '', + 'N' => '', + 'O' => '', + 'P' => '', + 'Q' => '', + 'R' => '', + 'S' => '', + 'T' => '', + 'U' => '', + 'V' => '', + 'W' => '', + 'X' => '', + 'Y' => '', + 'Z' => '', + 'a' => '', + 'b' => '', + 'c' => '', + 'd' => '', + 'e' => '', + 'f' => '', + 'g' => '', + 'h' => '', + 'i' => '', + 'j' => '', + 'k' => '', + 'l' => '', + 'm' => '', + 'n' => '', + 'o' => '', + 'p' => '', + 'q' => '', + 'r' => '', + 's' => '', + 't' => '', + 'u' => '', + 'v' => '', + 'w' => '', + 'x' => '', + 'y' => '', + 'z' => '', + 0 => '', + 1 => '', + 2 => '', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => '', + '_' => '', + '-' => '', + ]; /** * absolute path of the directory to use @@ -92,7 +157,8 @@ class common_persistence_PhpFileDriver implements common_persistence_KvDriver, c public function connect($id, array $params) { $this->directory = isset($params['dir']) - ? $params['dir'] . ($params['dir'][strlen($params['dir']) - 1] === DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR) + ? $params['dir'] + . ($params['dir'][strlen($params['dir']) - 1] === DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR) : FILES_PATH . 'generis' . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR; $this->levels = isset($params['levels']) ? $params['levels'] : self::DEFAULT_LEVELS; $this->humanReadable = isset($params['humanReadable']) ? $params['humanReadable'] : false; @@ -207,7 +273,12 @@ private function makeDirectory(string $path, int $mode) if (is_dir($path)) { \common_Logger::w(sprintf('Directory already exists. Path: \'%s\'', $path)); } elseif (is_file($path)) { - \common_Logger::w(sprintf('Directory was not created. File with the same name already exists. Path: \'%s\'', $path)); + \common_Logger::w( + sprintf( + 'Directory was not created. File with the same name already exists. Path: \'%s\'', + $path + ) + ); } else { \common_Logger::w(sprintf('Directory was not created. Path: \'%s\'', $path)); } @@ -389,7 +460,8 @@ protected function getPath($key) $path = $this->sanitizeReadableFileName($key); } else { $encoded = hash('md5', $key); - $path = implode(DIRECTORY_SEPARATOR, str_split(substr($encoded, 0, $this->levels))) . DIRECTORY_SEPARATOR . $encoded; + $path = implode(DIRECTORY_SEPARATOR, str_split(substr($encoded, 0, $this->levels))) + . DIRECTORY_SEPARATOR . $encoded; } return $this->directory . $path . '.php'; } diff --git a/common/persistence/class.SqlKvDriver.php b/common/persistence/class.SqlKvDriver.php index 3479d1e20..7baa8cb36 100755 --- a/common/persistence/class.SqlKvDriver.php +++ b/common/persistence/class.SqlKvDriver.php @@ -64,7 +64,9 @@ public function connect($id, array $params) } $this->sqlPersistenceId = $params[self::OPTION_PERSISTENCE_SQL]; - $this->sqlPersistence = common_persistence_SqlPersistence::getPersistence($params[self::OPTION_PERSISTENCE_SQL]); + $this->sqlPersistence = common_persistence_SqlPersistence::getPersistence( + $params[self::OPTION_PERSISTENCE_SQL] + ); $this->garbageCollection = isset($params['gc']) ? $params['gc'] : self::DEFAULT_GC_PROBABILITY; @@ -107,12 +109,20 @@ public function set($id, $value, $ttl = null, $nx = false) WHEN MATHED THEN UPDATE SET kv_value = :data WHERE kv_id = :id"; } else { $statement = 'UPDATE kv_store SET kv_value = :data , kv_time = :time WHERE kv_id = :id'; - $returnValue = $this->sqlPersistence->exec($statement, $params, ['data' => ParameterType::STRING, 'time' => ParameterType::INTEGER, 'id' => ParameterType::STRING]); + $returnValue = $this->sqlPersistence->exec( + $statement, + $params, + ['data' => ParameterType::STRING, 'time' => ParameterType::INTEGER, 'id' => ParameterType::STRING] + ); if (0 === $returnValue) { $returnValue = $this->sqlPersistence->insert( 'kv_store', ['kv_id' => $id, 'kv_time' => $expire, 'kv_value' => $encoded], - ['kv_id' => ParameterType::STRING, 'kv_time' => ParameterType::INTEGER, 'kv_value' => ParameterType::STRING] + [ + 'kv_id' => ParameterType::STRING, + 'kv_time' => ParameterType::INTEGER, + 'kv_value' => ParameterType::STRING + ] ); } } @@ -121,7 +131,9 @@ public function set($id, $value, $ttl = null, $nx = false) $this->gc(); } } catch (Exception $e) { - throw new common_Exception("Unable to write the key value storage table in the database " . $e->getMessage()); + throw new common_Exception( + "Unable to write the key value storage table in the database " . $e->getMessage() + ); } return (bool)$returnValue; } @@ -202,7 +214,8 @@ public function incr($id) $statement = 'UPDATE kv_store SET kv_value = kv_value::integer + 1 WHERE kv_id = :id'; break; case 'gcp-spanner': - $statement = 'UPDATE kv_store SET kv_value = CAST(CAST(kv_value as INT64) + 1 as string) WHERE kv_id = :id'; + $statement = 'UPDATE kv_store SET kv_value = CAST(CAST(kv_value as INT64) + 1 as string) WHERE ' + . 'kv_id = :id'; break; default: $statement = 'UPDATE kv_store SET kv_value = kv_value + 1 WHERE kv_id = :id'; @@ -223,7 +236,8 @@ public function decr($id) $statement = 'UPDATE kv_store SET kv_value = kv_value::integer - 1 WHERE kv_id = :id'; break; case 'gcp-spanner': - $statement = 'UPDATE kv_store SET kv_value = CAST(CAST(kv_value as INT64) - 1 as string) WHERE kv_id = :id'; + $statement = 'UPDATE kv_store SET kv_value = CAST(CAST(kv_value as INT64) - 1 as string) WHERE ' + . 'kv_id = :id'; break; default: $statement = 'UPDATE kv_store SET kv_value = kv_value - 1 WHERE kv_id = :id'; diff --git a/common/persistence/sql/SetupDb.php b/common/persistence/sql/SetupDb.php index 72d8d38df..262e68d79 100644 --- a/common/persistence/sql/SetupDb.php +++ b/common/persistence/sql/SetupDb.php @@ -53,7 +53,10 @@ private function verifyDatabase(\common_persistence_SqlPersistence $p, $dbName) { $schemaManager = $p->getSchemaManager()->getDbalSchemaManager(); if (!$this->dbExists($schemaManager, $dbName)) { - throw new \tao_install_utils_Exception('Unable to find the database, make sure that the db exists and that the db user has the rights to use it.'); + throw new \tao_install_utils_Exception( + 'Unable to find the database, make sure that the db exists and that the db user has the rights ' + . 'to use it.' + ); } } diff --git a/common/persistence/sql/class.Platform.php b/common/persistence/sql/class.Platform.php index aeb1068b1..d9581903c 100644 --- a/common/persistence/sql/class.Platform.php +++ b/common/persistence/sql/class.Platform.php @@ -338,7 +338,8 @@ public function rollBack() * Commits the current transaction. * * @return void - * @throws \Doctrine\DBAL\ConnectionException If the commit failed due to no active transaction or because the transaction was marked for rollback only. + * @throws \Doctrine\DBAL\ConnectionException If the commit failed due to no active transaction or because the + * transaction was marked for rollback only. * @throws DBALException * @throws common_persistence_sql_SerializationException In case of SerializationFailure (SQLSTATE 40001). */ diff --git a/common/persistence/sql/class.UpdateMultiple.php b/common/persistence/sql/class.UpdateMultiple.php index 3237ec0d6..ac72b908c 100644 --- a/common/persistence/sql/class.UpdateMultiple.php +++ b/common/persistence/sql/class.UpdateMultiple.php @@ -119,7 +119,8 @@ public function buildQuery($table, array $data) $conditionColumn = $condition['conditionColumn']; $conditionValue = $condition['conditionValue']; - $key = ':' . $index . '_' . $column . '_' . $indexCondition . '_' . $conditionColumn . '_conditionvalue'; + $key = ':' . $index . '_' . $column . '_' . $indexCondition . '_' . $conditionColumn + . '_conditionvalue'; $conditionsString[] = " $conditionColumn = $key "; $allColumns[$conditionColumn][] = $conditionValue; $params[$key] = $conditionValue; diff --git a/common/report/class.Report.php b/common/report/class.Report.php index ad6f07705..277ad26f6 100755 --- a/common/report/class.Report.php +++ b/common/report/class.Report.php @@ -97,7 +97,13 @@ public function __construct(string $type, string $message = '', $data = null, ar public static function __callStatic(string $name, array $arguments): self { if (strpos($name, 'create') !== 0) { - throw new BadMethodCallException(sprintf('Requested method `%s` is not found or is not allowed in class %s', $name, __CLASS__)); + throw new BadMethodCallException( + sprintf( + 'Requested method `%s` is not found or is not allowed in class %s', + $name, + __CLASS__ + ) + ); } $type = strtolower(str_replace('create', '', $name)); @@ -129,7 +135,13 @@ public function __call(string $name, array $arguments) return $this->handleContainsCalls($name, $arguments); } - throw new BadMethodCallException(sprintf('Requested method `%s` is not found or is not allowed in class %s', $name, __CLASS__)); + throw new BadMethodCallException( + sprintf( + 'Requested method `%s` is not found or is not allowed in class %s', + $name, + __CLASS__ + ) + ); } /** @@ -254,7 +266,9 @@ public function add($mixed): self } elseif ($element instanceof UserReadableException) { $this->children[] = new static(self::TYPE_ERROR, $element->getUserMessage()); } else { - throw new common_exception_Error('Tried to add ' . (is_object($element) ? get_class($element) : gettype($element)) . ' to the report'); + throw new common_exception_Error( + 'Tried to add ' . (is_object($element) ? get_class($element) : gettype($element)) . ' to the report' + ); } } diff --git a/common/session/php/class.KeyValueSessionHandler.php b/common/session/php/class.KeyValueSessionHandler.php index 020a74034..0fed1c430 100644 --- a/common/session/php/class.KeyValueSessionHandler.php +++ b/common/session/php/class.KeyValueSessionHandler.php @@ -40,7 +40,9 @@ class common_session_php_KeyValueSessionHandler extends ConfigurableService impl protected function getPersistence() { if (is_null($this->sessionPersistence)) { - $this->sessionPersistence = common_persistence_KeyValuePersistence::getPersistence($this->getOption(self::OPTION_PERSISTENCE)); + $this->sessionPersistence = common_persistence_KeyValuePersistence::getPersistence( + $this->getOption(self::OPTION_PERSISTENCE) + ); } return $this->sessionPersistence; diff --git a/common/uri/class.MicrotimeUriProvider.php b/common/uri/class.MicrotimeUriProvider.php index c2a20c579..6a6d02e2b 100644 --- a/common/uri/class.MicrotimeUriProvider.php +++ b/common/uri/class.MicrotimeUriProvider.php @@ -59,7 +59,9 @@ public function provide() do { list($usec, $sec) = explode(" ", microtime()); $uri = $modelUri . 'i' . (str_replace(".", "", $sec . "" . $usec)); - $sqlResult = $dbWrapper->query("SELECT COUNT(subject) AS num FROM statements WHERE subject = '" . $uri . "'"); + $sqlResult = $dbWrapper->query( + "SELECT COUNT(subject) AS num FROM statements WHERE subject = '" . $uri . "'" + ); if ($row = $sqlResult->fetch()) { $found = (int)$row['num']; diff --git a/common/user/auth/class.AuthFailedException.php b/common/user/auth/class.AuthFailedException.php index bcc3d2f4e..1fa4b9966 100755 --- a/common/user/auth/class.AuthFailedException.php +++ b/common/user/auth/class.AuthFailedException.php @@ -28,6 +28,7 @@ * @package generis */ -abstract class common_user_auth_AuthFailedException extends common_Exception implements common_exception_UserReadableException +abstract class common_user_auth_AuthFailedException extends common_Exception implements + common_exception_UserReadableException { } diff --git a/config/default/ontology.conf.php b/config/default/ontology.conf.php index 88a9a26be..598dd3e6e 100644 --- a/config/default/ontology.conf.php +++ b/config/default/ontology.conf.php @@ -11,6 +11,8 @@ core_kernel_persistence_smoothsql_SmoothModel::OPTION_WRITEABLE_MODELS => [ core_kernel_persistence_smoothsql_SmoothModel::DEFAULT_WRITABLE_MODEL, ], + // phpcs:disable Generic.Files.LineLength core_kernel_persistence_smoothsql_SmoothModel::OPTION_NEW_TRIPLE_MODEL => core_kernel_persistence_smoothsql_SmoothModel::DEFAULT_WRITABLE_MODEL, + // phpcs:enable Generic.Files.LineLength core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE => ComplexSearchService::SERVICE_ID, ]); diff --git a/helpers/class.ExtensionHelper.php b/helpers/class.ExtensionHelper.php index f89c95529..f9d7feefb 100755 --- a/helpers/class.ExtensionHelper.php +++ b/helpers/class.ExtensionHelper.php @@ -77,9 +77,14 @@ public static function sortByDependencies($extensions) if (count($unsorted) == $before) { $notfound = array_diff($missing, array_keys($unsorted)); if (!empty($notfound)) { - throw new common_exception_Error('Missing extensions ' . implode(',', $notfound) . ' for: ' . implode(',', array_keys($unsorted))); + throw new common_exception_Error( + 'Missing extensions ' . implode(',', $notfound) . ' for: ' + . implode(',', array_keys($unsorted)) + ); } else { - throw new common_exception_Error('Cyclic extension dependencies for: ' . implode(',', array_keys($unsorted))); + throw new common_exception_Error( + 'Cyclic extension dependencies for: ' . implode(',', array_keys($unsorted)) + ); } } } diff --git a/helpers/class.File.php b/helpers/class.File.php index fc9fead3e..ed1f27ff9 100644 --- a/helpers/class.File.php +++ b/helpers/class.File.php @@ -46,7 +46,72 @@ class helpers_File * matches [A-Za-z] | - | _ * @var array */ - private static $ALLOWED_CHARACTERS = ['A' => '','B' => '','C' => '','D' => '','E' => '','F' => '','G' => '','H' => '','I' => '','J' => '','K' => '','L' => '','M' => '','N' => '','O' => '','P' => '','Q' => '','R' => '','S' => '','T' => '','U' => '','V' => '','W' => '','X' => '','Y' => '','Z' => '','a' => '','b' => '','c' => '','d' => '','e' => '','f' => '','g' => '','h' => '','i' => '','j' => '','k' => '','l' => '','m' => '','n' => '','o' => '','p' => '','q' => '','r' => '','s' => '','t' => '','u' => '','v' => '','w' => '','x' => '','y' => '','z' => '',0 => '',1 => '',2 => '',3 => '',4 => '',5 => '',6 => '',7 => '',8 => '',9 => '','_' => '','-' => '']; + private static $ALLOWED_CHARACTERS = [ + 'A' => '', + 'B' => '', + 'C' => '', + 'D' => '', + 'E' => '', + 'F' => '', + 'G' => '', + 'H' => '', + 'I' => '', + 'J' => '', + 'K' => '', + 'L' => '', + 'M' => '', + 'N' => '', + 'O' => '', + 'P' => '', + 'Q' => '', + 'R' => '', + 'S' => '', + 'T' => '', + 'U' => '', + 'V' => '', + 'W' => '', + 'X' => '', + 'Y' => '', + 'Z' => '', + 'a' => '', + 'b' => '', + 'c' => '', + 'd' => '', + 'e' => '', + 'f' => '', + 'g' => '', + 'h' => '', + 'i' => '', + 'j' => '', + 'k' => '', + 'l' => '', + 'm' => '', + 'n' => '', + 'o' => '', + 'p' => '', + 'q' => '', + 'r' => '', + 's' => '', + 't' => '', + 'u' => '', + 'v' => '', + 'w' => '', + 'x' => '', + 'y' => '', + 'z' => '', + 0 => '', + 1 => '', + 2 => '', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => '', + '_' => '', + '-' => '', + ]; /** * Directory Mode @@ -147,7 +212,12 @@ public static function remove($path) $returnValue = unlink($path); } elseif (is_dir($path)) { /* - * //It seems to raise problemes on windows, depending on the php version the resource handler is not freed with DirectoryIterator preventing from further deletions // $iterator = new DirectoryIterator($path); foreach ($iterator as $fileinfo) { if (!$fileinfo->isDot()) { } } + * It seems to raise problemes on windows, depending on the php version the resource handler is not freed + * with DirectoryIterator preventing from further deletions + * $iterator = new DirectoryIterator($path); + * foreach ($iterator as $fileinfo) { + * if (!$fileinfo->isDot()) { } + * } */ $handle = opendir($path); if ($handle !== false) { @@ -163,7 +233,9 @@ public static function remove($path) $returnValue = rmdir($path); } else { - throw new common_exception_Error('"' . $path . '" cannot be removed since it\'s neither a file nor directory'); + throw new common_exception_Error( + '"' . $path . '" cannot be removed since it\'s neither a file nor directory' + ); } return (bool) $returnValue; @@ -312,12 +384,18 @@ public static function scandir($path, $options = []) } if ($fileinfo->isDir() && $recursive) { - $returnValue = array_merge($returnValue, self::scandir(realpath($fileinfo->getPathname()), $options)); + $returnValue = array_merge( + $returnValue, + self::scandir(realpath($fileinfo->getPathname()), $options) + ); } } } } else { - throw new common_Exception("An error occured : The function (" . __METHOD__ . ") of the class (" . __CLASS__ . ") is expecting a directory path as first parameter : " . $path); + throw new common_Exception( + "An error occured : The function (" . __METHOD__ . ") of the class (" . __CLASS__ + . ") is expecting a directory path as first parameter : " . $path + ); } return (array) $returnValue; diff --git a/helpers/class.InstallHelper.php b/helpers/class.InstallHelper.php index 94ee3f283..15e9feb0a 100644 --- a/helpers/class.InstallHelper.php +++ b/helpers/class.InstallHelper.php @@ -88,7 +88,8 @@ public static function installRecursively($extensionIDs, $installData = []) $missing = array_diff($missing, array_keys($toInstall)); foreach ($missing as $extID) { static::log('d', 'Extension ' . $extID . ' is required but missing, added to install list'); - $toInstall = [$extID => common_ext_ExtensionsManager::singleton()->getExtensionById($extID)] + $toInstall; + $toInstall = [$extID => common_ext_ExtensionsManager::singleton()->getExtensionById($extID)] + + $toInstall; $modified = true; } } diff --git a/helpers/class.RdfDiff.php b/helpers/class.RdfDiff.php index ca7617adb..67f89c7cf 100755 --- a/helpers/class.RdfDiff.php +++ b/helpers/class.RdfDiff.php @@ -74,7 +74,12 @@ protected function remove(core_kernel_classes_Triple $triple) protected function generateSerial(core_kernel_classes_Triple $triple) { - return md5(implode(' ', [$triple->subject, $triple->predicate, $triple->object, $triple->lg, $triple->modelid])); + return md5( + implode( + ' ', + [$triple->subject, $triple->predicate, $triple->object, $triple->lg, $triple->modelid] + ) + ); } public function getSummary() @@ -85,10 +90,12 @@ public function getSummary() public function dump() { foreach ($this->toAdd as $triple) { - echo '+ ' . str_pad($triple->subject, 80) . ' ' . str_pad($triple->predicate, 80) . ' ' . str_pad($triple->object, 80) . PHP_EOL; + echo '+ ' . str_pad($triple->subject, 80) . ' ' . str_pad($triple->predicate, 80) . ' ' + . str_pad($triple->object, 80) . PHP_EOL; } foreach ($this->toRemove as $triple) { - echo '- ' . str_pad($triple->subject, 80) . ' ' . str_pad($triple->predicate, 80) . ' ' . str_pad($triple->object, 80) . PHP_EOL; + echo '- ' . str_pad($triple->subject, 80) . ' ' . str_pad($triple->predicate, 80) . ' ' + . str_pad($triple->object, 80) . PHP_EOL; } } diff --git a/helpers/class.Report.php b/helpers/class.Report.php index 448ca28cc..5eb057402 100644 --- a/helpers/class.Report.php +++ b/helpers/class.Report.php @@ -40,8 +40,11 @@ class helpers_Report * @param integer $intend the intend of the message. * @return string The shell output of $report. */ - public static function renderToCommandLine(ReportInterface $report, $useColor = self::AUTOSENSE, $intend = 0): string - { + public static function renderToCommandLine( + ReportInterface $report, + $useColor = self::AUTOSENSE, + $intend = 0 + ): string { switch ($report->getType()) { case ReportInterface::TYPE_SUCCESS: $color = '0;32'; // green diff --git a/helpers/class.VersionedFile.php b/helpers/class.VersionedFile.php index 4c20e9c26..3f451838e 100644 --- a/helpers/class.VersionedFile.php +++ b/helpers/class.VersionedFile.php @@ -120,7 +120,12 @@ public static function cpWorkingCopy($source, $destination, $recursive = true, $ if (!$ignoreSystemFiles && $file[0] == '.') { continue; } else { - self::cpWorkingCopy($source . '/' . $file, $destination . '/' . $file, true, $ignoreSystemFiles); + self::cpWorkingCopy( + $source . '/' . $file, + $destination . '/' . $file, + true, + $ignoreSystemFiles + ); } } } diff --git a/scripts/tools/CleanUpOrphanFiles.php b/scripts/tools/CleanUpOrphanFiles.php index 370eb21a6..c14560afc 100644 --- a/scripts/tools/CleanUpOrphanFiles.php +++ b/scripts/tools/CleanUpOrphanFiles.php @@ -194,7 +194,12 @@ private function manageOrphan(core_kernel_classes_Resource $resource, FileSystem if ($isOrphan && !$file->exists()) { if ($this->verbose) { - $this->report->add(new Report(Report::TYPE_INFO, sprintf('URI %s : File %s', $resource->getUri(), $file->getPrefix()))); + $this->report->add( + new Report( + Report::TYPE_INFO, + sprintf('URI %s : File %s', $resource->getUri(), $file->getPrefix()) + ) + ); } $this->markForRemoval($resource); $this->affectedCount++; @@ -227,10 +232,20 @@ private function prepareReport() $this->report->add(new Report(Report::TYPE_SUCCESS, sprintf('%s redundant at RDS', $this->redundantCount))); $this->report->add(new Report(Report::TYPE_SUCCESS, sprintf('%s missing at FS', $this->affectedCount))); $this->report->add(new Report(Report::TYPE_SUCCESS, sprintf('%s removed at FS', $this->removedCount))); - $this->report->add(new Report(Report::TYPE_SUCCESS, sprintf('Peak memory %s Mb', memory_get_peak_usage() / 1024 / 1024))); + $this->report->add( + new Report( + Report::TYPE_SUCCESS, + sprintf('Peak memory %s Mb', memory_get_peak_usage() / 1024 / 1024) + ) + ); if ($this->errorsCount) { - $this->report->add(new Report(Report::TYPE_ERROR, sprintf('%s errors happened, check details above', $this->errorsCount))); + $this->report->add( + new Report( + Report::TYPE_ERROR, + sprintf('%s errors happened, check details above', $this->errorsCount) + ) + ); } } } diff --git a/scripts/tools/FileSerializerMigration/Migrate.php b/scripts/tools/FileSerializerMigration/Migrate.php index 000844f38..02ec7e567 100644 --- a/scripts/tools/FileSerializerMigration/Migrate.php +++ b/scripts/tools/FileSerializerMigration/Migrate.php @@ -92,7 +92,9 @@ protected function run() $this->report->add(Report::createSuccess('Completed file migration process.')); if (!$this->isWetRun()) { - $this->report->add(Report::createFailure('Use the --wet-run (-w) parameter to execute reference migration.')); + $this->report->add( + Report::createFailure('Use the --wet-run (-w) parameter to execute reference migration.') + ); } return $this->report; @@ -130,7 +132,8 @@ protected function provideOptions() 'flag' => true, 'prefix' => 'w', 'longPrefix' => 'wet-run', - 'description' => 'Add this flag to migrate the references, as opposed to just listing them (dry/wet run)' + 'description' => 'Add this flag to migrate the references, as opposed to just listing them ' + . '(dry/wet run)' ] ]; } diff --git a/scripts/tools/FileSerializerMigration/MigrationHelper.php b/scripts/tools/FileSerializerMigration/MigrationHelper.php index 9d1b371a3..2de29fbcc 100644 --- a/scripts/tools/FileSerializerMigration/MigrationHelper.php +++ b/scripts/tools/FileSerializerMigration/MigrationHelper.php @@ -134,8 +134,11 @@ public function migrateFiles() * @return void * @throws FileSerializerException */ - public function migrateResource(core_kernel_classes_Resource $fileResource, core_kernel_classes_Property $property, core_kernel_classes_Resource $subject) - { + public function migrateResource( + core_kernel_classes_Resource $fileResource, + core_kernel_classes_Property $property, + core_kernel_classes_Resource $subject + ) { /** @var Directory|File $unserializedFileResource */ $unserializedFileResource = $this->getResourceFileSerializer()->unserialize($fileResource); $migratedValue = $this->getUrlFileSerializer()->serialize($unserializedFileResource); diff --git a/scripts/update/Updater.php b/scripts/update/Updater.php index fd13ab5fd..772af36d2 100644 --- a/scripts/update/Updater.php +++ b/scripts/update/Updater.php @@ -130,13 +130,17 @@ public function update($initialVersion) 'search.query.criterion' => '\\oat\\search\\QueryCriterion', 'search.driver.postgres' => '\\oat\\search\\DbSql\\Driver\\PostgreSQL', 'search.driver.mysql' => '\\oat\\search\\DbSql\\Driver\\MySQL', + // phpcs:disable Generic.Files.LineLength 'search.driver.tao' => '\\oat\\generis\\model\\kernel\\persistence\\smoothsql\\search\\driver\\TaoSearchDriver', + // phpcs:enable Generic.Files.LineLength 'search.tao.serialyser' => '\\oat\\search\\DbSql\\TaoRdf\\UnionQuerySerialyser', 'search.factory.query' => '\\oat\\search\\factory\\QueryFactory', 'search.factory.builder' => '\\oat\\search\\factory\\QueryBuilderFactory', 'search.factory.criterion' => '\\oat\\search\\factory\\QueryCriterionFactory', + // phpcs:disable Generic.Files.LineLength 'search.tao.gateway' => '\\oat\\generis\\model\\kernel\\persistence\\smoothsql\\search\\GateWay', 'search.tao.result' => '\\oat\\generis\\model\\kernel\\persistence\\smoothsql\\search\\TaoResultSet', + // phpcs:enable Generic.Files.LineLength ], 'abstract_factories' => [ '\\oat\\search\\Command\\OperatorAbstractfactory',