diff --git a/cspell.json b/cspell.json index 49baaafd1..25d96d3d1 100644 --- a/cspell.json +++ b/cspell.json @@ -334,7 +334,9 @@ "datatable", "FileCacheExcption", "Autoloader", - "autoloader" + "autoloader", + "qwertyuiopasdfghjklzxccvbnm", + "QWERTYUIOPASDFGHJKLZXCVBNM" ], "ignorePaths": [ "tests/**", diff --git a/data/class-header.txt b/data/class-header.txt index 9e4293c10..e310ec52a 100755 --- a/data/class-header.txt +++ b/data/class-header.txt @@ -9,6 +9,5 @@ * Copyright BoxBilling, Inc 2011-2021 * * This source file is subject to the Apache-2.0 License that is bundled - * with this source code in the file LICENSE + * with this source code in the file LICENSE. */ - diff --git a/src/di.php b/src/di.php index 00aeba5c3..5cbe5266c 100644 --- a/src/di.php +++ b/src/di.php @@ -1,8 +1,4 @@ -addWriter($writer2); } else { - $monolog = new FOSSBilling_Monolog($di); + $monolog = new \FOSSBilling\Monolog($di); $log->addWriter($monolog); } @@ -248,10 +244,10 @@ $di['session'] = function () use ($di) { * * @param void * - * @return \Box_Request + * @return \FOSSBilling\Request */ $di['request'] = function () use ($di) { - $service = new Box_Request(); + $service = new \FOSSBilling\Request(); $service->setDi($di); return $service; @@ -294,7 +290,7 @@ $di['twig'] = $di->factory(function () use ($di) { // Get internationalisation settings from config, or use sensible defaults for // missing required settings. - $locale = \FOSSBilling_i18n::getActiveLocale(); + $locale = \FOSSBilling\i18n::getActiveLocale(); $timezone = $config['i18n']['timezone'] ?? 'UTC'; $date_format = !empty($config['i18n']['date_format']) ? strtoupper($config['i18n']['date_format']) : 'MEDIUM'; $time_format = !empty($config['i18n']['time_format']) ? strtoupper($config['i18n']['time_format']) : 'SHORT'; @@ -506,27 +502,21 @@ $di['api_system'] = function () use ($di) { return $di['api']('system'); }; -/* - * - * @param void - * - * @return \Box_Tools - */ -$di['tools'] = $di->factory(function () use ($di) { - $service = new Box_Tools(); +$di['tools'] = function () use ($di) { + $service = new \FOSSBilling\Tools(); $service->setDi($di); return $service; -}); +}; /* * * @param void * - * @return \Box_Validate + * @return \FOSSBilling\Validate */ $di['validator'] = function () use ($di) { - $validator = new Box_Validate(); + $validator = new \FOSSBilling\Validate(); $validator->setDi($di); return $validator; @@ -536,10 +526,10 @@ $di['validator'] = function () use ($di) { * * @param void * - * @return \FOSSBilling_CentralAlerts + * @return \FOSSBilling\CentralAlerts */ $di['central_alerts'] = function () use ($di) { - $centralalerts = new \FOSSBilling_CentralAlerts(); + $centralalerts = new \FOSSBilling\CentralAlerts(); $centralalerts->setDi($di); return $centralalerts; @@ -549,10 +539,23 @@ $di['central_alerts'] = function () use ($di) { * * @param void * - * @return \FOSSBilling_ExtensionManager + * @return \FOSSBilling\CentralAlerts + */ +$di['central_alerts'] = function () use ($di) { + $centralalerts = new \FOSSBilling\CentralAlerts(); + $centralalerts->setDi($di); + + return $centralalerts; +}; + +/* + * + * @param void + * + * @return \FOSSBilling\ExtensionManager */ $di['extension_manager'] = function () use ($di) { - $extension = new \FOSSBilling_ExtensionManager(); + $extension = new \FOSSBilling\ExtensionManager(); $extension->setDi($di); return $extension; @@ -618,10 +621,10 @@ $di['server_manager'] = $di->protect(function($manager, $config) use ($di) { /* * @param void * - * @return FOSSBilling_Requirements + * @return \FOSSBilling\Requirements */ $di['requirements'] = function () use ($di) { - $r = new FOSSBilling_Requirements(); + $r = new \FOSSBilling\Requirements(); $r->setDi($di); return $r; @@ -682,7 +685,7 @@ $di['cart'] = function () use ($di) { * @return \Box_Table The new table object that was just created. */ $di['table'] = $di->protect(function ($name) use ($di) { - $tools = new Box_Tools(); + $tools = new \FOSSBilling\Tools(); $tools->setDi($di); $table = $tools->getTable($name); $table->setDi($di); @@ -734,7 +737,7 @@ $di['translate'] = $di->protect(function ($textDomain = '') use ($di) { $tr->setDomain($textDomain); } - $locale = \FOSSBilling_i18n::getActiveLocale(); + $locale = \FOSSBilling\i18n::getActiveLocale(); $tr->setDi($di); $tr->setLocale($locale); diff --git a/src/foss-update.php b/src/foss-update.php index d7733b743..78c6dcd3a 100644 --- a/src/foss-update.php +++ b/src/foss-update.php @@ -18,7 +18,7 @@ const DIR_SEP = DIRECTORY_SEPARATOR; /** * Patch to remove the old FileCache class that was replaced with Symfony's Cache component - * + * * @see https://github.com/FOSSBilling/FOSSBilling/pull/1184 */ class FOSSPatch_33 extends FOSSPatchAbstract @@ -33,8 +33,8 @@ class FOSSPatch_33 extends FOSSPatchAbstract } /** - * Patch to remove the old phpmailer package, some leftover admin_default files, and old Box_ classes we've removed or replaced - * + * Patch to remove the old phpmailer package, some leftover admin_default files, and old Box_ classes we've removed or replaced + * * @see https://github.com/FOSSBilling/FOSSBilling/pull/1091 and https://github.com/FOSSBilling/FOSSBilling/pull/1063 */ class FOSSPatch_32 extends FOSSPatchAbstract @@ -65,7 +65,7 @@ class FOSSPatch_32 extends FOSSPatchAbstract /** * Patch to remove the old htaccess.txt file, any old config.php backup - * + * * @see https://github.com/FOSSBilling/FOSSBilling/pull/1075 */ class FOSSPatch_31 extends FOSSPatchAbstract @@ -82,7 +82,7 @@ class FOSSPatch_31 extends FOSSPatchAbstract /** * Patch to remove the old guzzlehttp package, as we no longer use it. Also serves as an example for how to perform file action. - * + * * @see https://github.com/FOSSBilling/FOSSBilling/pull/987 */ class FOSSPatch_30 extends FOSSPatchAbstract @@ -98,8 +98,8 @@ class FOSSPatch_30 extends FOSSPatchAbstract /** * Patch to update email templates to use format_date/format_datetime filters - * instead of removed bb_date/bb_datetime filters. - * + * instead of removed bb_date/bb_datetime filters. + * * @see https://github.com/FOSSBilling/FOSSBilling/pull/948 */ class FOSSPatch_29 extends FOSSPatchAbstract @@ -368,8 +368,8 @@ natsort($patches); } ?> -

Update completed. You are using FOSSBilling

+

Update completed. You are using FOSSBilling

- \ No newline at end of file + diff --git a/src/install/install.php b/src/install/install.php index 48c1adcd0..5e23f4215 100644 --- a/src/install/install.php +++ b/src/install/install.php @@ -99,7 +99,7 @@ set_include_path(implode(PATH_SEPARATOR, [ require PATH_VENDOR . DIRECTORY_SEPARATOR . 'autoload.php'; require PATH_LIBRARY . DIRECTORY_SEPARATOR . 'Autoload.php'; -$loader = new \FOSSBillingAutoloader(); +$loader = new \FOSSBilling\Autoloader(); $loader->addPrefix('', PATH_LIBRARY, 'psr0'); $loader->addPrefix('Box\\Mod\\', PATH_MODS, 'psr4'); $loader->checkClassMap(); @@ -214,7 +214,7 @@ final class Box_Installer default: $this->session->set('agree', true); - $se = new FOSSBilling_Requirements(); + $se = new \FOSSBilling\Requirements(); $options = $se->getOptions(); $vars = [ 'tos' => $this->getLicense(), @@ -223,7 +223,7 @@ final class Box_Installer 'files' => $se->files(), 'os' => PHP_OS, 'os_ok' => true, - 'fossbilling_ver' => FOSSBilling_Version::VERSION, + 'fossbilling_ver' => \FOSSBilling\Version::VERSION, 'fossbilling_ver_ok' => $se->isFOSSBillingVersionOk(), 'php_ver' => $options['php']['version'], 'php_ver_req' => $options['php']['min_version'], @@ -276,7 +276,7 @@ final class Box_Installer $twig = new Twig\Environment($loader, $options); // $twig->addExtension(new Twig_Extension_Optimizer()); $twig->addGlobal('request', $_REQUEST); - $twig->addGlobal('version', FOSSBilling_Version::VERSION); + $twig->addGlobal('version', \FOSSBilling\Version::VERSION); return $twig->render($name, $vars); } @@ -442,9 +442,9 @@ final class Box_Installer private function _getConfigOutput($ns): string { - $version = new FOSSBilling_Requirements(); + $version = new \FOSSBilling\Requirements(); $reg = '^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$^'; - $updateBranch = (preg_match($reg, FOSSBilling_Version::VERSION, $matches) !== 0) ? "release" : "preview"; + $updateBranch = (preg_match($reg, \FOSSBilling\Version::VERSION, $matches) !== 0) ? "release" : "preview"; // TODO: Why not just take the defaults from the config-sample.php file and modify accordingly? Also this method doesn't preserve the comments in the example config. $data = [ diff --git a/src/library/Api/Abstract.php b/src/library/Api/Abstract.php index 21338497e..0b293f6cb 100644 --- a/src/library/Api/Abstract.php +++ b/src/library/Api/Abstract.php @@ -12,7 +12,7 @@ * with this source code in the file LICENSE */ -use Box\InjectionAwareInterface; +use \FOSSBilling\InjectionAwareInterface; class Api_Abstract implements InjectionAwareInterface { @@ -120,4 +120,4 @@ class Api_Abstract implements InjectionAwareInterface { return $this->ip; } -} \ No newline at end of file +} diff --git a/src/library/Api/Handler.php b/src/library/Api/Handler.php index 7da5c3302..4423eeb48 100644 --- a/src/library/Api/Handler.php +++ b/src/library/Api/Handler.php @@ -13,7 +13,7 @@ */ -use Box\InjectionAwareInterface; +use \FOSSBilling\InjectionAwareInterface; final class Api_Handler implements InjectionAwareInterface { diff --git a/src/library/Autoload.php b/src/library/Autoload.php index 42b912220..9c70d172d 100644 --- a/src/library/Autoload.php +++ b/src/library/Autoload.php @@ -1,6 +1,20 @@ -psr0 as $path) { $generator->scanPaths($path); @@ -40,7 +54,7 @@ class FOSSBillingAutoloader $this->classMap = include self::$classMapPath; } - /** + /** * Registers the autoloader. * @return void * */ @@ -53,7 +67,7 @@ class FOSSBillingAutoloader * @param string $prefix Class prefix. Use an empty prefix to allow this prefix to work with any path. Paths must already have directory separators normalized for the current system. * @param string $path Base path associated with the class prefix * @param string $type The type of PSR autoloader the prefix is associated with. EX: psr4 - * @return void + * @return void */ public function addPrefix(string $prefix, string $path, string $type): void { @@ -76,7 +90,7 @@ class FOSSBillingAutoloader /** * @param string $class Classname to load. If found, file will be included and execution will be completed. - * @return void + * @return void */ public function autoload(string $class): void { @@ -147,7 +161,7 @@ class FOSSBillingAutoloader /** * Saves the current classMap array to the cache folder for later access. - * @return void + * @return void */ private function saveMap(): void { diff --git a/src/library/Box/App.php b/src/library/Box/App.php index baa1f6cd2..11c14ad29 100644 --- a/src/library/Box/App.php +++ b/src/library/Box/App.php @@ -13,7 +13,7 @@ * with this source code in the file LICENSE */ -use Box\InjectionAwareInterface; +use \FOSSBilling\InjectionAwareInterface; class Box_App { diff --git a/src/library/Box/BeanHelper.php b/src/library/Box/BeanHelper.php index e9b226f51..65f87bd4c 100644 --- a/src/library/Box/BeanHelper.php +++ b/src/library/Box/BeanHelper.php @@ -12,7 +12,7 @@ * with this source code in the file LICENSE */ -class Box_BeanHelper extends \RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper implements \Box\InjectionAwareInterface +class Box_BeanHelper extends \RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper implements \FOSSBilling\InjectionAwareInterface { protected ?\Pimple\Container $di; @@ -37,7 +37,7 @@ class Box_BeanHelper extends \RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper imple } $model = new $modelName(); - if($model instanceof \Box\InjectionAwareInterface) { + if($model instanceof \FOSSBilling\InjectionAwareInterface) { $model->setDi( $this->di ); } diff --git a/src/library/Box/Crypt.php b/src/library/Box/Crypt.php index 5bad241f9..21374c212 100644 --- a/src/library/Box/Crypt.php +++ b/src/library/Box/Crypt.php @@ -13,7 +13,7 @@ */ -class Box_Crypt implements \Box\InjectionAwareInterface +class Box_Crypt implements \FOSSBilling\InjectionAwareInterface { protected ?\Pimple\Container $di; @@ -87,4 +87,4 @@ class Box_Crypt implements \Box\InjectionAwareInterface } return pack('H*', hash('md5', $pass)); } -} \ No newline at end of file +} diff --git a/src/library/Box/Database.php b/src/library/Box/Database.php index 98f483ab9..da616ee4e 100644 --- a/src/library/Box/Database.php +++ b/src/library/Box/Database.php @@ -14,7 +14,7 @@ */ -use Box\InjectionAwareInterface; +use \FOSSBilling\InjectionAwareInterface; class Box_Database implements InjectionAwareInterface { @@ -49,7 +49,7 @@ class Box_Database implements InjectionAwareInterface public function store($modelOrBean) { - if ($modelOrBean instanceof \FOSSBilling_Model) { + if ($modelOrBean instanceof \RedBeanPHP\SimpleModel) { $bean = $modelOrBean->unbox(); } else { $bean = $modelOrBean; @@ -150,7 +150,7 @@ class Box_Database implements InjectionAwareInterface public function trash($modelOrBean) { - if ($modelOrBean instanceof \FOSSBilling_Model) { + if ($modelOrBean instanceof \RedBeanPHP\SimpleModel) { $bean = $modelOrBean->unbox(); } else { $bean = $modelOrBean; @@ -170,7 +170,7 @@ class Box_Database implements InjectionAwareInterface public function toArray($modelOrBean) { - if ($modelOrBean instanceof \FOSSBilling_Model) { + if ($modelOrBean instanceof \RedBeanPHP\SimpleModel) { $bean = $modelOrBean->unbox(); } else { $bean = $modelOrBean; @@ -182,7 +182,7 @@ class Box_Database implements InjectionAwareInterface * @param string $modelName * @param int $id * @param string $message - * @return \FOSSBilling_Model + * @return \RedBeanPHP\SimpleModel * @throws \Box_Exception */ public function getExistingModelById($modelName, $id, $message = "Model :name not found in the database") diff --git a/src/library/Box/Event.php b/src/library/Box/Event.php index ab3a4d220..d22d2aee0 100644 --- a/src/library/Box/Event.php +++ b/src/library/Box/Event.php @@ -13,7 +13,7 @@ * with this source code in the file LICENSE */ -class Box_Event implements ArrayAccess, \Box\InjectionAwareInterface +class Box_Event implements ArrayAccess, \FOSSBilling\InjectionAwareInterface { protected ?\Pimple\Container $di; protected $value = null; diff --git a/src/library/Box/EventManager.php b/src/library/Box/EventManager.php index c07a4ddce..417e42426 100644 --- a/src/library/Box/EventManager.php +++ b/src/library/Box/EventManager.php @@ -12,7 +12,7 @@ * with this source code in the file LICENSE */ -class Box_EventManager implements \Box\InjectionAwareInterface +class Box_EventManager implements \FOSSBilling\InjectionAwareInterface { protected ?\Pimple\Container $di; diff --git a/src/library/Box/Log.php b/src/library/Box/Log.php index 6be8e218f..142766b11 100644 --- a/src/library/Box/Log.php +++ b/src/library/Box/Log.php @@ -22,7 +22,7 @@ * @method void info(string $message) * @method void debug(string $message) */ -class Box_Log implements \Box\InjectionAwareInterface +class Box_Log implements \FOSSBilling\InjectionAwareInterface { const EMERG = 0; // Emergency: system is unusable const ALERT = 1; // Alert: action must be taken immediately @@ -46,7 +46,7 @@ class Box_Log implements \Box\InjectionAwareInterface protected ?\Pimple\Container $di; protected $_min_priority = null; - + protected array $_writers = []; protected array $_extras = []; protected string $_channel = 'application'; diff --git a/src/library/Box/Pagination.php b/src/library/Box/Pagination.php index 2c3f99320..e92e3ec9f 100644 --- a/src/library/Box/Pagination.php +++ b/src/library/Box/Pagination.php @@ -13,7 +13,7 @@ */ -use Box\InjectionAwareInterface; +use \FOSSBilling\InjectionAwareInterface; class Box_Pagination implements InjectionAwareInterface { diff --git a/src/library/Box/Translate.php b/src/library/Box/Translate.php index 995cbc7ac..9edc11cbd 100644 --- a/src/library/Box/Translate.php +++ b/src/library/Box/Translate.php @@ -14,7 +14,7 @@ */ -class Box_Translate implements \Box\InjectionAwareInterface +class Box_Translate implements \FOSSBilling\InjectionAwareInterface { protected ?\Pimple\Container $di; diff --git a/src/library/Box/TwigExtensions.php b/src/library/Box/TwigExtensions.php index 04495225a..6297f142c 100644 --- a/src/library/Box/TwigExtensions.php +++ b/src/library/Box/TwigExtensions.php @@ -13,7 +13,7 @@ * with this source code in the file LICENSE */ -use Box\InjectionAwareInterface; +use \FOSSBilling\InjectionAwareInterface; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; use League\CommonMark\GithubFlavoredMarkdownConverter; @@ -207,12 +207,12 @@ class Box_TwigExtensions extends AbstractExtension implements InjectionAwareInte public function twig_script_tag($path) { - return sprintf('', $path, FOSSBilling_Version::VERSION); + return sprintf('', $path, \FOSSBilling\Version::VERSION); } public function twig_stylesheet_tag($path, $media = 'screen') { - return sprintf('', $path, FOSSBilling_Version::VERSION, $media); + return sprintf('', $path, \FOSSBilling\Version::VERSION, $media); } public function twig_gravatar_filter($email, $size = 20) diff --git a/src/library/Box/Update.php b/src/library/Box/Update.php index 5572fbe6a..767fbb718 100644 --- a/src/library/Box/Update.php +++ b/src/library/Box/Update.php @@ -99,12 +99,12 @@ class Box_Update public function getLatestVersion(): string { if ($this->getUpdateBranch() === "preview") { - return FOSSBilling_Version::VERSION; + return \FOSSBilling\Version::VERSION; } $response = $this->_getLatestVersionInfo(); if (!isset($response['tag_name'])) { - return FOSSBilling_Version::VERSION; + return \FOSSBilling\Version::VERSION; } return $response['tag_name']; } @@ -130,7 +130,7 @@ class Box_Update public function getCanUpdate(): bool { $version = $this->getLatestVersion(); - $result = FOSSBilling_Version::compareVersion($version); + $result = \FOSSBilling\Version::compareVersion($version); $result = ($this->isPreviewVersion() && $this->getUpdateBranch() === "release") ? 1 : $result; return ($result > 0); } diff --git a/src/library/Box/Url.php b/src/library/Box/Url.php index 90475a122..6bed5d03a 100644 --- a/src/library/Box/Url.php +++ b/src/library/Box/Url.php @@ -14,7 +14,7 @@ */ -class Box_Url implements Box\InjectionAwareInterface +class Box_Url implements \FOSSBilling\InjectionAwareInterface { protected ?\Pimple\Container $di; protected $baseUri; diff --git a/src/library/FOSSBilling/CentralAlerts.php b/src/library/FOSSBilling/CentralAlerts.php index a30f6e773..e497b320a 100644 --- a/src/library/FOSSBilling/CentralAlerts.php +++ b/src/library/FOSSBilling/CentralAlerts.php @@ -1,5 +1,4 @@ -di = $di; @@ -68,7 +66,7 @@ class FOSSBilling_CentralAlerts implements InjectionAwareInterface * @return array The filtered alerts * @throws \Box_Exception */ - public function filterAlerts(array $type = [], string $version = FOSSBilling_Version::VERSION): array + public function filterAlerts(array $type = [], string $version = \FOSSBilling\Version::VERSION): array { $alerts = $this->getAlerts(); @@ -87,7 +85,7 @@ class FOSSBilling_CentralAlerts implements InjectionAwareInterface $alerts = array_filter($alerts, function($alert) use ($version) { $overThanTheMinimum = version_compare(strtolower($version), strtolower($alert['min_fossbilling_version']), '>='); $lessThanTheMaximum = version_compare(strtolower($version), strtolower($alert['max_fossbilling_version']), '<='); - + return $overThanTheMinimum && $lessThanTheMaximum; }); } @@ -98,10 +96,10 @@ class FOSSBilling_CentralAlerts implements InjectionAwareInterface /** * Make a request to the FOSSBilling Central Alerts System API - * + * * @param string $endpoint The API endpoint to call (e.g. list) * @param array $params The array of parameters to pass to the API endpoint - * + * * @return array The API response * @throws \Box_Exception */ @@ -113,7 +111,7 @@ class FOSSBilling_CentralAlerts implements InjectionAwareInterface $response = $client->request('GET', $url, [ 'timeout' => 5, 'query' => array_merge($params, [ - 'fossbilling_version' => FOSSBilling_Version::VERSION, + 'fossbilling_version' => \FOSSBilling\Version::VERSION, ]), ]); diff --git a/src/library/Error/ErrorPage.php b/src/library/FOSSBilling/ErrorPage.php similarity index 95% rename from src/library/Error/ErrorPage.php rename to src/library/FOSSBilling/ErrorPage.php index 788615348..4bd96d97d 100644 --- a/src/library/Error/ErrorPage.php +++ b/src/library/FOSSBilling/ErrorPage.php @@ -1,6 +1,20 @@ -' . __trans("Show original message") . ' ' . $error['link']['label'] . ' - +