From fefbcd21b0ff9e7ea04c5f0b9b1d12d215f20c5e Mon Sep 17 00:00:00 2001 From: FOSSBilling Bot <121974958+fossbilling-bot@users.noreply.github.com> Date: Sun, 30 Jul 2023 17:57:44 +0200 Subject: [PATCH] Apply PHP Code Styling & Quality Changes (#1498) * Apply PHP Code Styling & Quality Changes * Delete these * Update .gitignore * Fixes for PHPStan * Ignore spelling in the gitnore * Allow null for that type Honestly doing so makes ZERO sense, but it matches the current behavior. --------- Co-authored-by: FOSSBilling Bot Co-authored-by: Belle Aerni --- .gitignore | 3 + cspell.json | 3 +- phpstan-baseline.neon | 10 -- src/di.php | 69 ++++--------- src/install/session.php | 6 +- src/library/Api/Abstract.php | 2 +- src/library/Api/Handler.php | 16 ++- src/library/Box/App.php | 14 +-- src/library/Box/AppClient.php | 2 +- src/library/Box/Authorization.php | 4 +- src/library/Box/BeanHelper.php | 4 +- src/library/Box/Crypt.php | 4 +- src/library/Box/Database.php | 2 +- src/library/Box/Event.php | 20 +--- src/library/Box/EventDispatcher.php | 8 +- src/library/Box/EventManager.php | 4 +- src/library/Box/Log.php | 20 ++-- src/library/Box/LogDb.php | 12 +-- src/library/Box/Mod.php | 6 +- src/library/Box/Pagination.php | 2 +- src/library/Box/Paginator.php | 28 +----- src/library/Box/Password.php | 4 +- src/library/Box/Period.php | 97 +++++++------------ src/library/Box/Translate.php | 2 +- src/library/Box/TwigExtensions.php | 8 +- src/library/Box/Url.php | 2 +- src/library/Box/UrlHelper.php | 9 +- src/library/FOSSBilling/CentralAlerts.php | 10 +- src/library/FOSSBilling/ExtensionManager.php | 16 +-- src/library/FOSSBilling/Mail.php | 6 +- src/library/FOSSBilling/Monolog.php | 10 +- src/library/FOSSBilling/Request.php | 6 +- src/library/FOSSBilling/Requirements.php | 4 +- src/library/FOSSBilling/Session.php | 12 +-- src/library/FOSSBilling/Tools.php | 22 ++--- src/library/FOSSBilling/Update.php | 4 +- src/library/FOSSBilling/UpdatePatcher.php | 8 +- src/library/FOSSBilling/Validate.php | 4 +- src/library/FOSSBilling/Version.php | 2 +- src/library/FOSSBilling/i18n.php | 4 +- .../Model/ActivityClientHistoryTable.php | 2 +- src/library/Model/Admin.php | 10 +- src/library/Model/ApiRequestTable.php | 2 +- src/library/Model/Client.php | 6 +- src/library/Model/ClientOrder.php | 28 +++--- .../Model/ClientPasswordResetTable.php | 2 +- src/library/Model/Invoice.php | 8 +- src/library/Model/InvoiceItem.php | 20 ++-- src/library/Model/KbArticle.php | 4 +- src/library/Model/Product.php | 28 +++--- src/library/Model/ProductDomainTable.php | 4 +- src/library/Model/ProductPayment.php | 6 +- src/library/Model/ProductTable.php | 27 +++--- src/library/Model/Promo.php | 4 +- src/library/Model/SupportPTicket.php | 6 +- src/library/Model/SupportTicket.php | 16 +-- src/library/Model/Transaction.php | 8 +- src/library/Payment/Adapter/ClientBalance.php | 4 +- src/library/Payment/Adapter/Custom.php | 8 +- src/library/Payment/Adapter/Interkassa.php | 13 ++- src/library/Payment/Adapter/Onebip.php | 2 - src/library/Payment/Adapter/PayPalEmail.php | 10 +- src/library/Payment/Adapter/Stripe.php | 25 ++--- src/library/Payment/Adapter/TwoCheckout.php | 79 ++++----------- src/library/Payment/Adapter/WebMoney.php | 27 +++--- src/library/Payment/AdapterAbstract.php | 21 ++-- src/library/Payment/Invoice.php | 14 +-- src/library/Payment/Invoice/Item.php | 2 +- src/library/Payment/Transaction.php | 22 ++--- src/library/PdoSessionHandler.php | 6 +- src/library/Registrar/Adapter/Internetbs.php | 6 +- src/library/Registrar/Adapter/Namecheap.php | 3 +- .../Registrar/Adapter/Resellerclub.php | 17 ++-- src/library/Registrar/Domain.php | 28 ++---- src/library/Registrar/Domain/Contact.php | 12 +-- src/library/Registrar/Domain/Nameserver.php | 4 +- src/library/Server/Account.php | 16 +-- src/library/Server/Client.php | 12 +-- src/library/Server/Manager.php | 4 +- src/library/Server/Manager/Directadmin.php | 8 +- src/library/Server/Manager/Hestia.php | 2 +- src/library/Server/Manager/Ispconfig3.php | 17 +++- src/library/Server/Manager/Plesk.php | 20 ++-- src/library/Server/Manager/Virtualmin.php | 25 ++--- src/library/Server/Manager/Whm.php | 2 +- src/library/Server/Package.php | 8 +- src/modules/Activity/Controller/Admin.php | 2 +- src/modules/Activity/Service.php | 2 +- src/modules/Api/Controller/Client.php | 6 +- src/modules/Api/Service.php | 2 +- src/modules/Branding/Service.php | 2 +- src/modules/Cart/Api/Admin.php | 2 +- src/modules/Cart/Controller/Client.php | 2 +- src/modules/Cart/Service.php | 6 +- src/modules/Client/Controller/Admin.php | 2 +- src/modules/Client/Controller/Client.php | 2 +- src/modules/Client/Service.php | 2 +- src/modules/Client/ServiceBalance.php | 3 +- .../Cookieconsent/Controller/Admin.php | 2 +- src/modules/Cookieconsent/Service.php | 2 +- src/modules/Cron/Service.php | 2 +- src/modules/Currency/Controller/Admin.php | 2 +- src/modules/Currency/Service.php | 2 +- src/modules/Custompages/Controller/Admin.php | 2 +- src/modules/Custompages/Controller/Client.php | 2 +- src/modules/Custompages/Service.php | 2 +- src/modules/Dashboard/Controller/Client.php | 2 +- src/modules/Email/Controller/Admin.php | 2 +- src/modules/Email/Controller/Client.php | 2 +- src/modules/Email/Service.php | 4 +- src/modules/Embed/Controller/Admin.php | 2 +- src/modules/Embed/Controller/Client.php | 2 +- src/modules/Extension/Controller/Admin.php | 2 +- src/modules/Extension/Service.php | 2 +- src/modules/Formbuilder/Controller/Client.php | 2 +- src/modules/Formbuilder/Service.php | 8 +- src/modules/Hook/Service.php | 2 +- src/modules/Index/Controller/Admin.php | 2 +- src/modules/Invoice/Controller/Admin.php | 2 +- src/modules/Invoice/Controller/Client.php | 2 +- src/modules/Invoice/Service.php | 6 +- src/modules/Invoice/ServiceInvoiceItem.php | 2 +- src/modules/Invoice/ServicePayGateway.php | 4 +- src/modules/Invoice/ServiceSubscription.php | 2 +- src/modules/Invoice/ServiceTax.php | 2 +- src/modules/Invoice/ServiceTransaction.php | 4 +- src/modules/Kb/Controller/Admin.php | 2 +- src/modules/Kb/Controller/Client.php | 2 +- src/modules/Kb/Service.php | 2 +- src/modules/Massmailer/Controller/Admin.php | 2 +- src/modules/Massmailer/Service.php | 2 +- src/modules/News/Controller/Admin.php | 2 +- src/modules/News/Controller/Client.php | 2 +- src/modules/News/Service.php | 2 +- src/modules/Notification/Controller/Admin.php | 2 +- src/modules/Notification/Service.php | 2 +- src/modules/Order/Controller/Admin.php | 2 +- src/modules/Order/Controller/Client.php | 2 +- src/modules/Order/Service.php | 4 +- src/modules/Orderbutton/Controller/Client.php | 2 +- src/modules/Page/Service.php | 2 +- src/modules/Paidsupport/Service.php | 2 +- src/modules/Product/Api/Guest.php | 2 +- src/modules/Product/Controller/Admin.php | 2 +- src/modules/Product/Service.php | 10 +- src/modules/Profile/Service.php | 2 +- src/modules/Queue/Service.php | 4 +- src/modules/Redirect/Controller/Client.php | 24 ++--- src/modules/Redirect/Service.php | 2 +- src/modules/Seo/Engines/Google.php | 2 +- src/modules/Seo/Service.php | 4 +- src/modules/Serviceapikey/Service.php | 6 +- src/modules/Servicecustom/Service.php | 2 +- .../Servicedomain/Controller/Admin.php | 2 +- src/modules/Servicedomain/Service.php | 4 +- src/modules/Servicedomain/ServiceTld.php | 2 +- .../Servicedownloadable/Controller/Client.php | 2 +- src/modules/Servicedownloadable/Service.php | 2 +- .../Servicehosting/Controller/Admin.php | 2 +- src/modules/Servicehosting/Service.php | 2 +- src/modules/Servicelicense/Plugin/Simple.php | 4 +- src/modules/Servicelicense/Server.php | 6 +- src/modules/Servicelicense/Service.php | 3 +- src/modules/Servicemembership/Service.php | 2 +- src/modules/Spamchecker/Service.php | 2 +- src/modules/Staff/Controller/Admin.php | 7 +- src/modules/Staff/Service.php | 2 +- src/modules/Stats/Service.php | 2 +- src/modules/Support/Controller/Admin.php | 2 +- src/modules/Support/Controller/Client.php | 2 +- src/modules/Support/Service.php | 4 +- src/modules/System/Controller/Admin.php | 2 +- src/modules/System/Service.php | 6 +- src/modules/Theme/Controller/Admin.php | 2 +- src/modules/Theme/Service.php | 3 +- 175 files changed, 543 insertions(+), 788 deletions(-) diff --git a/.gitignore b/.gitignore index 3ba7d9338..d252677d2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ src/vendor/* build composer.phar report/* +*.log +DOCKER_ENV +docker_tag ### phpunit/phpunit ### .phpunit.result.cache diff --git a/cspell.json b/cspell.json index 76a69ac19..6a1584b77 100644 --- a/cspell.json +++ b/cspell.json @@ -383,6 +383,7 @@ "phpstan.neon", "*.config.js", "src/modules/Wysiwyg/src/ckeditor.js", - ".github/**" + ".github/**", + ".gitignore" ] } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2b74634cf..236b5f836 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,17 +15,7 @@ parameters: count: 1 path: src/library/Server/Manager/Ispconfig3.php - - - message: "#^Undefined variable\\: \\$section$#" - count: 1 - path: src/library/Server/Manager/Ispconfig3.php - - message: "#^Method Server_Manager_Plesk\\:\\:changeAccountDomain\\(\\) should return bool but return statement is missing\\.$#" count: 1 path: src/library/Server/Manager/Plesk.php - - - - message: "#^Undefined variable\\: \\$domainId$#" - count: 1 - path: src/library/Server/Manager/Plesk.php diff --git a/src/di.php b/src/di.php index d6bec25eb..f759344c6 100644 --- a/src/di.php +++ b/src/di.php @@ -200,9 +200,7 @@ $di['mod'] = $di->protect(function ($name) use ($di) { * * @return mixed the service of the associated module */ -$di['mod_service'] = $di->protect(function ($mod, $sub = '') use ($di) { - return $di['mod']($mod)->getService($sub); -}); +$di['mod_service'] = $di->protect(fn ($mod, $sub = '') => $di['mod']($mod)->getService($sub)); /* * @@ -210,9 +208,7 @@ $di['mod_service'] = $di->protect(function ($mod, $sub = '') use ($di) { * * @return mixed the configuration of the associated module */ -$di['mod_config'] = $di->protect(function ($name) use ($di) { - return $di['mod']($name)->getConfig(); -}); +$di['mod_config'] = $di->protect(fn ($name) => $di['mod']($name)->getConfig()); /* * @@ -266,10 +262,9 @@ $di['request'] = function () use ($di) { * * @return \Symfony\Component\Cache\Adapter\FilesystemAdapter */ -$di['cache'] = function () { +$di['cache'] = fn () => // Reference: https://symfony.com/doc/current/components/cache/adapters/filesystem_adapter.html - return new FilesystemAdapter('sf_cache', 24 * 60 * 60, PATH_CACHE); -}; + new FilesystemAdapter('sf_cache', 24 * 60 * 60, PATH_CACHE); /* * @@ -277,9 +272,7 @@ $di['cache'] = function () { * * @return \Box_Authorization */ -$di['auth'] = function () use ($di) { - return new Box_Authorization($di); -}; +$di['auth'] = fn () => new Box_Authorization($di); /* * Creates a new Twig environment that's configured for FOSSBilling. @@ -441,7 +434,7 @@ $di['loggedin_client'] = function () use ($di) { try { return $di['db']->getExistingModelById('Client', $client_id); - } catch (Exception $e) { + } catch (Exception) { // Either the account was deleted or the session is invalid. Either way, destroy it so they are forced to try and login again. $di['session']->destroy('client'); @@ -479,7 +472,7 @@ $di['loggedin_admin'] = function () use ($di) { try { return $di['db']->getExistingModelById('Admin', $admin['id']); - } catch (Exception $e) { + } catch (Exception) { // Either the account was deleted or the session is invalid. Either way, destroy it so they are forced to try and login again. $di['session']->destroy('admin'); @@ -545,9 +538,7 @@ $di['api'] = $di->protect(function ($role) use ($di) { * * @return \Api_Handler */ -$di['api_guest'] = function () use ($di) { - return $di['api']('guest'); -}; +$di['api_guest'] = fn () => $di['api']('guest'); /* * @@ -555,9 +546,7 @@ $di['api_guest'] = function () use ($di) { * * @return \Api_Handler */ -$di['api_client'] = function () use ($di) { - return $di['api']('client'); -}; +$di['api_client'] = fn () => $di['api']('client'); /* * @@ -565,9 +554,7 @@ $di['api_client'] = function () use ($di) { * * @return \Api_Handler */ -$di['api_admin'] = function () use ($di) { - return $di['api']('admin'); -}; +$di['api_admin'] = fn () => $di['api']('admin'); /* * @@ -575,9 +562,7 @@ $di['api_admin'] = function () use ($di) { * * @return \Api_Handler */ -$di['api_system'] = function () use ($di) { - return $di['api']('system'); -}; +$di['api_system'] = fn () => $di['api']('system'); $di['tools'] = function () use ($di) { $service = new \FOSSBilling\Tools(); @@ -656,27 +641,21 @@ $di['updater'] = function () use ($di) { * * @return Server_Package */ -$di['server_package'] = function () { - return new Server_Package(); -}; +$di['server_package'] = fn () => new Server_Package(); /* * @param void * * @return Server_Client */ -$di['server_client'] = function () { - return new Server_Client(); -}; +$di['server_client'] = fn () => new Server_Client(); /* * @param void * * @return Server_Account */ -$di['server_account'] = function () { - return new Server_Account(); -}; +$di['server_account'] = fn () => new Server_Account(); /* * Creates a new server manager object and returns it. @@ -714,9 +693,7 @@ $di['requirements'] = function () use ($di) { * * @return \Box_Period The new period object that was just created. */ -$di['period'] = $di->protect(function ($code) { - return new \Box_Period($code); -}); +$di['period'] = $di->protect(fn ($code) => new \Box_Period($code)); /* * Gets the current client area theme. @@ -787,18 +764,14 @@ $di['license_server'] = function () use ($di) { * * @return \GeoIp2\Database\Reader */ -$di['geoip'] = function () { - return new \GeoIp2\Database\Reader(PATH_LIBRARY . '/GeoLite2-Country.mmdb'); -}; +$di['geoip'] = fn () => new \GeoIp2\Database\Reader(PATH_LIBRARY . '/GeoLite2-Country.mmdb'); /* * @param void * * @return \Box_Password */ -$di['password'] = function () { - return new Box_Password(); -}; +$di['password'] = fn () => new Box_Password(); /* * Creates a new Box_Translate object and sets the specified text domain, locale, and other options. @@ -839,15 +812,11 @@ $di['table_export_csv'] = $di->protect(function (string $table, string $outputNa $beans = $di['db']->findAll($table); } - $rows = array_map(function ($bean) { - return $bean->export(); - }, $beans); + $rows = array_map(fn ($bean) => $bean->export(), $beans); // If we've been provided a list of headers, use that. Otherwise, pull the keys from the rows and use that for the CSV header if ($headers) { - $rows = array_map(function ($row) use ($headers) { - return array_intersect_key($row, array_flip($headers)); - }, $rows); + $rows = array_map(fn ($row) => array_intersect_key($row, array_flip($headers)), $rows); } else { $headers = array_keys(reset($rows)); } diff --git a/src/install/session.php b/src/install/session.php index 934baf4b5..33f35b6c7 100644 --- a/src/install/session.php +++ b/src/install/session.php @@ -37,8 +37,8 @@ class Session class Box_SessionFile { - const SESSION_STARTED = TRUE; - const SESSION_NOT_STARTED = FALSE; + public const SESSION_STARTED = TRUE; + public const SESSION_NOT_STARTED = FALSE; protected $sessionState = self::SESSION_NOT_STARTED; @@ -104,7 +104,7 @@ class Box_SessionFile public function __get($key) { - return isset($_SESSION[$key]) ? $_SESSION[$key] : NULL; + return $_SESSION[$key] ?? NULL; } public function __set($key, $value) diff --git a/src/library/Api/Abstract.php b/src/library/Api/Abstract.php index cf96bab68..15f454081 100644 --- a/src/library/Api/Abstract.php +++ b/src/library/Api/Abstract.php @@ -32,7 +32,7 @@ class Api_Abstract implements InjectionAwareInterface */ protected $identity = null; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/library/Api/Handler.php b/src/library/Api/Handler.php index 3c902b689..81f6cd70f 100644 --- a/src/library/Api/Handler.php +++ b/src/library/Api/Handler.php @@ -13,18 +13,16 @@ use \FOSSBilling\InjectionAwareInterface; final class Api_Handler implements InjectionAwareInterface { protected $type = NULL; - protected $identity = NULL; protected $ip = NULL; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; - private $_enable_cache = FALSE; - private $_cache = array(); - private $_acl_exception = FALSE; + private bool $_enable_cache = FALSE; + private array $_cache = array(); + private bool $_acl_exception = FALSE; - public function __construct($identity) + public function __construct(protected $identity) { - $this->identity = $identity; - $role = str_replace('model_', '', strtolower(get_class($identity))); + $role = str_replace('model_', '', strtolower($identity::class)); $this->type = $role; } @@ -40,7 +38,7 @@ final class Api_Handler implements InjectionAwareInterface public function __call($method, $arguments) { - if(strpos($method, '_') === FALSE) { + if(!str_contains($method, '_')) { throw new \Box_Exception("Method :method must contain underscore", array(':method'=>$method), 710); } diff --git a/src/library/Box/App.php b/src/library/Box/App.php index bfb17a174..b9ee928fe 100644 --- a/src/library/Box/App.php +++ b/src/library/Box/App.php @@ -17,7 +17,7 @@ class Box_App protected $after_filters = []; protected $shared = []; protected $options; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; protected $ext = 'html.twig'; protected $mod = 'index'; protected $url = '/'; @@ -51,7 +51,7 @@ class Box_App $mod = 'index'; } else { $requestUri = trim($requestUri, '/'); - if (false === strpos($requestUri, '/')) { + if (!str_contains($requestUri, '/')) { $mod = $requestUri; } else { [$mod] = explode('/', $requestUri); @@ -134,7 +134,7 @@ class Box_App protected function run_filter($arr_filter, $methodName) { if (isset($arr_filter[$methodName])) { - $counted = count($arr_filter[$methodName]); + $counted = is_countable($arr_filter[$methodName]) ? count($arr_filter[$methodName]) : 0; for ($i = 0; $i < $counted; ++$i) { $return = call_user_func([$this, $arr_filter[$methodName][$i]]); @@ -197,7 +197,7 @@ class Box_App if ($class instanceof InjectionAwareInterface) { $class->setDi($this->di); } - $reflection = new ReflectionMethod(get_class($class), $methodName); + $reflection = new ReflectionMethod($class::class, $methodName); $args = []; $args[] = $this; // first param always app instance @@ -219,7 +219,7 @@ class Box_App return $return; } - $reflection = new ReflectionMethod(get_class($this), $methodName); + $reflection = new ReflectionMethod(static::class, $methodName); $args = []; foreach ($reflection->getParameters() as $param) { @@ -298,13 +298,13 @@ class Box_App // Check if the visitor is in using of the allowed IPs/networks foreach ($allowedIPs as $network) { - if (false == strpos($network, '/')) { + if (!str_contains($network, '/')) { $network .= '/32'; } [$network, $netmask] = explode('/', $network, 2); $network_decimal = ip2long($network); $ip_decimal = ip2long($visitorIP); - $wildcard_decimal = pow(2, (32 - $netmask)) - 1; + $wildcard_decimal = 2 ** (32 - $netmask) - 1; $netmask_decimal = ~$wildcard_decimal; if (($ip_decimal & $netmask_decimal) == ($network_decimal & $netmask_decimal)) { return false; diff --git a/src/library/Box/AppClient.php b/src/library/Box/AppClient.php index 001ff3e00..ebf04f573 100644 --- a/src/library/Box/AppClient.php +++ b/src/library/Box/AppClient.php @@ -42,7 +42,7 @@ class Box_AppClient extends Box_App public function get_custom_page($page) { $ext = $this->ext; - if (false !== strpos($page, '.')) { + if (str_contains($page, '.')) { $ext = substr($page, strpos($page, '.') + 1); $page = substr($page, 0, strpos($page, '.')); } diff --git a/src/library/Box/Authorization.php b/src/library/Box/Authorization.php index ec06db0a4..baf964b85 100644 --- a/src/library/Box/Authorization.php +++ b/src/library/Box/Authorization.php @@ -10,12 +10,10 @@ class Box_Authorization { - private $di = null; private $session = null; - public function __construct(\Pimple\Container $di) + public function __construct(private \Pimple\Container $di) { - $this->di = $di; $this->session = $di['session']; } diff --git a/src/library/Box/BeanHelper.php b/src/library/Box/BeanHelper.php index 0d4edd9a7..9b36747f3 100644 --- a/src/library/Box/BeanHelper.php +++ b/src/library/Box/BeanHelper.php @@ -10,7 +10,7 @@ class Box_BeanHelper extends \RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -48,7 +48,7 @@ class Box_BeanHelper extends \RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper imple { $string[0] = strtoupper($string[0]); } - $func = function($c){ return strtoupper($c[1]); }; + $func = fn($c) => strtoupper($c[1]); return preg_replace_callback('/_([a-z])/', $func, $string); } } diff --git a/src/library/Box/Crypt.php b/src/library/Box/Crypt.php index 0cd3e9101..072b7f32b 100644 --- a/src/library/Box/Crypt.php +++ b/src/library/Box/Crypt.php @@ -10,9 +10,9 @@ class Box_Crypt implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; - const METHOD = 'aes-256-cbc'; + public const METHOD = 'aes-256-cbc'; public function __construct() { diff --git a/src/library/Box/Database.php b/src/library/Box/Database.php index c60b6d81a..418aaaa90 100644 --- a/src/library/Box/Database.php +++ b/src/library/Box/Database.php @@ -13,7 +13,7 @@ use \FOSSBilling\InjectionAwareInterface; class Box_Database implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; protected $orm = null; public function setDataMapper($orm) diff --git a/src/library/Box/Event.php b/src/library/Box/Event.php index ab85f9eab..3d1d292cb 100644 --- a/src/library/Box/Event.php +++ b/src/library/Box/Event.php @@ -10,14 +10,9 @@ class Box_Event implements ArrayAccess, \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; protected $value = null; protected $processed = false; - protected $subject = null; - protected $name = ''; - protected $parameters = null; - protected $api_guest = null; - protected $api_admin = null; /** * Constructs a new sfEvent. @@ -26,15 +21,8 @@ class Box_Event implements ArrayAccess, \FOSSBilling\InjectionAwareInterface * @param string $name The event name * @param array $parameters An array of parameters */ - public function __construct($subject, $name, $parameters = [], $api_admin = null, $api_guest = null) + public function __construct(protected mixed $subject, protected $name, protected $parameters = [], protected $api_admin = null, protected $api_guest = null) { - $this->subject = $subject; - $this->name = $name; - - $this->parameters = $parameters; - - $this->api_admin = $api_admin; - $this->api_guest = $api_guest; } public function setDi(\Pimple\Container $di): void @@ -82,7 +70,7 @@ class Box_Event implements ArrayAccess, \FOSSBilling\InjectionAwareInterface * * @param mixed $value The return value */ - public function setReturnValue($value) + public function setReturnValue(mixed $value) { $this->value = $value; } @@ -161,7 +149,7 @@ class Box_Event implements ArrayAccess, \FOSSBilling\InjectionAwareInterface * @param string $name The parameter name * @param mixed $value The parameter value */ - public function offsetSet(mixed $name, $value): void + public function offsetSet(mixed $name, mixed $value): void { $this->parameters[$name] = $value; } diff --git a/src/library/Box/EventDispatcher.php b/src/library/Box/EventDispatcher.php index b65139af6..87e490a4f 100644 --- a/src/library/Box/EventDispatcher.php +++ b/src/library/Box/EventDispatcher.php @@ -18,7 +18,7 @@ class Box_EventDispatcher * @param string $name An event name * @param mixed $listener A PHP callable */ - public function connect($name, $listener) + public function connect($name, mixed $listener) { if (!isset($this->listeners[$name])) { $this->listeners[$name] = []; @@ -35,7 +35,7 @@ class Box_EventDispatcher * * @return false|null false if listener does not exist, null otherwise */ - public function disconnect($name, $listener) + public function disconnect($name, mixed $listener) { if (!isset($this->listeners[$name])) { return false; @@ -109,7 +109,7 @@ class Box_EventDispatcher * * @return Box_Event The Box_Event instance */ - public function filter(Box_Event $event, $value) + public function filter(Box_Event $event, mixed $value) { foreach ($this->getListeners($event->getName()) as $listener) { $value = call_user_func_array($listener, [$event, $value]); @@ -133,7 +133,7 @@ class Box_EventDispatcher $this->listeners[$name] = []; } - return (bool) count($this->listeners[$name]); + return (bool) (is_countable($this->listeners[$name]) ? count($this->listeners[$name]) : 0); } /** diff --git a/src/library/Box/EventManager.php b/src/library/Box/EventManager.php index 6ddd907b3..d5f620640 100644 --- a/src/library/Box/EventManager.php +++ b/src/library/Box/EventManager.php @@ -10,7 +10,7 @@ class Box_EventManager implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -73,7 +73,7 @@ class Box_EventManager implements \FOSSBilling\InjectionAwareInterface $s = $this->di['mod_service']($mod); if (method_exists($s, $event)) { - $disp->connect($event, [get_class($s), $event]); + $disp->connect($event, [$s::class, $event]); } } catch (Exception $e) { error_log($e->getMessage()); diff --git a/src/library/Box/Log.php b/src/library/Box/Log.php index 9151cccb9..4b3db2d69 100644 --- a/src/library/Box/Log.php +++ b/src/library/Box/Log.php @@ -20,14 +20,14 @@ */ class Box_Log implements \FOSSBilling\InjectionAwareInterface { - const EMERG = 0; // Emergency: system is unusable - const ALERT = 1; // Alert: action must be taken immediately - const CRIT = 2; // Critical: critical conditions - const ERR = 3; // Error: error conditions - const WARN = 4; // Warning: warning conditions - const NOTICE = 5; // Notice: normal but significant condition - const INFO = 6; // Informational: informational messages - const DEBUG = 7; // Debug: debug messages + public const EMERG = 0; // Emergency: system is unusable + public const ALERT = 1; // Alert: action must be taken immediately + public const CRIT = 2; // Critical: critical conditions + public const ERR = 3; // Error: error conditions + public const WARN = 4; // Warning: warning conditions + public const NOTICE = 5; // Notice: normal but significant condition + public const INFO = 6; // Informational: informational messages + public const DEBUG = 7; // Debug: debug messages protected array $_priorities = [ self::EMERG => 'EMERG', @@ -40,7 +40,7 @@ class Box_Log implements \FOSSBilling\InjectionAwareInterface self::DEBUG => 'DEBUG', ]; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; protected $_min_priority = null; protected array $_writers = []; @@ -67,7 +67,7 @@ class Box_Log implements \FOSSBilling\InjectionAwareInterface { $priority = strtoupper($method); if (($priority = array_search($priority, $this->_priorities)) !== false) { - switch (count($params)) { + switch (is_countable($params) ? count($params) : 0) { case 0: throw new \Box_Exception('Missing log message'); case 1: diff --git a/src/library/Box/LogDb.php b/src/library/Box/LogDb.php index 8c758a7fc..51503f445 100644 --- a/src/library/Box/LogDb.php +++ b/src/library/Box/LogDb.php @@ -10,28 +10,18 @@ class Box_LogDb { - /** - * $service - module service class - * - * @var object $service - */ - protected $service = null; - /** * Class constructor * * @param object $service - module service class object */ - public function __construct($service) + public function __construct(protected $service) { - $this->service = $service; } /** * Write a message to the log. * - * @param array $event - * @param string $channel * * @return void */ diff --git a/src/library/Box/Mod.php b/src/library/Box/Mod.php index b544eefb6..ba480bfa2 100644 --- a/src/library/Box/Mod.php +++ b/src/library/Box/Mod.php @@ -10,11 +10,11 @@ class Box_Mod { - private $mod = null; + private ?string $mod = null; - private $di = null; + private ?\Pimple\Container $di = null; - private $core = array( + private array $core = array( 'api', 'activity', 'cart', diff --git a/src/library/Box/Pagination.php b/src/library/Box/Pagination.php index d387c9cc2..c090964a6 100644 --- a/src/library/Box/Pagination.php +++ b/src/library/Box/Pagination.php @@ -12,7 +12,7 @@ use \FOSSBilling\InjectionAwareInterface; class Box_Pagination implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; protected $per_page = 100; public function setDi(\Pimple\Container $di): void diff --git a/src/library/Box/Paginator.php b/src/library/Box/Paginator.php index f9bf0ffe3..322f32343 100644 --- a/src/library/Box/Paginator.php +++ b/src/library/Box/Paginator.php @@ -11,36 +11,16 @@ class Box_Paginator extends Paginator {} class Paginator { - /** - * @var int current displayed page - */ - protected $currentPage; - - /** - * @var int items limit (items per page) - */ - protected $limit; - /** * @var int total number of pages */ protected $numPages; - /** - * @var int items limit (items per page) - */ - protected $itemsCount; - /** * @var int offset */ protected $offset; - /** - * @var int pages to show at left and right of current page - */ - protected $midRange; - /** * @var array range */ @@ -57,14 +37,8 @@ class Paginator { * @param int $limit * @param int $midRange */ - public function __construct($itemsCount = 0, $currentPage = 1, $limit = 20, $midRange = 7) + public function __construct(protected $itemsCount = 0, protected $currentPage = 1, protected $limit = 20, protected $midRange = 7) { - //set total items count from controller - $this->itemsCount = $itemsCount; - $this->currentPage = $currentPage; - $this->limit = $limit; - $this->midRange= $midRange; - //Set defaults $this->setDefaults(); diff --git a/src/library/Box/Password.php b/src/library/Box/Password.php index 23888743b..f37b1c18f 100644 --- a/src/library/Box/Password.php +++ b/src/library/Box/Password.php @@ -10,8 +10,8 @@ class Box_Password { - private $algo = PASSWORD_DEFAULT; - private $options = array(); + private string $algo = PASSWORD_DEFAULT; + private array $options = array(); public function setAlgo ($algo) { diff --git a/src/library/Box/Period.php b/src/library/Box/Period.php index d11ab837f..6688a3b5a 100644 --- a/src/library/Box/Period.php +++ b/src/library/Box/Period.php @@ -10,18 +10,18 @@ class Box_Period { - const UNIT_DAY = 'D'; - const UNIT_WEEK = 'W'; - const UNIT_MONTH = 'M'; - const UNIT_YEAR = 'Y'; + public const UNIT_DAY = 'D'; + public const UNIT_WEEK = 'W'; + public const UNIT_MONTH = 'M'; + public const UNIT_YEAR = 'Y'; - const PERIOD_WEEK = '1W'; - const PERIOD_MONTH = '1M'; - const PERIOD_QUARTER = '3M'; - const PERIOD_BIANNUAL = '6M'; - const PERIOD_ANNUAL = '1Y'; - const PERIOD_BIENNIAL = '2Y'; - const PERIOD_TRIENNIAL = '3Y'; + public const PERIOD_WEEK = '1W'; + public const PERIOD_MONTH = '1M'; + public const PERIOD_QUARTER = '3M'; + public const PERIOD_BIANNUAL = '6M'; + public const PERIOD_ANNUAL = '1Y'; + public const PERIOD_BIENNIAL = '2Y'; + public const PERIOD_TRIENNIAL = '3Y'; /** * Predefined periods @@ -35,8 +35,8 @@ class Box_Period self::PERIOD_TRIENNIAL => 36, ); - private $unit; - private $qty; + private string $unit; + private int $qty; public function __construct($code) { @@ -44,7 +44,7 @@ class Box_Period throw new \Box_Exception("Invalid period code. Period definition must be 2 chars length"); } - list($qty, $unit) = str_split($code); + [$qty, $unit] = str_split($code); $units = $this->getUnits(); $qty = (int)$qty; @@ -119,22 +119,13 @@ class Box_Period $qty = $this->qty; $placeholders = [':number' => $qty]; - switch ($this->unit) { - case self::UNIT_DAY: - $shift = __pluralTrans('Every :number day', 'Every :number days', $qty, $placeholders); - break; - case self::UNIT_WEEK: - $shift = __pluralTrans('Every :number week', 'Every :number weeks', $qty, $placeholders); - break; - case self::UNIT_MONTH: - $shift = __pluralTrans('Every :number month', 'Every :number months', $qty, $placeholders); - break; - case self::UNIT_YEAR: - $shift = __pluralTrans('Every :number year', 'Every :number years', $qty, $placeholders); - break; - default: - throw new \Box_Exception('Unit not defined'); - } + $shift = match ($this->unit) { + self::UNIT_DAY => __pluralTrans('Every :number day', 'Every :number days', $qty, $placeholders), + self::UNIT_WEEK => __pluralTrans('Every :number week', 'Every :number weeks', $qty, $placeholders), + self::UNIT_MONTH => __pluralTrans('Every :number month', 'Every :number months', $qty, $placeholders), + self::UNIT_YEAR => __pluralTrans('Every :number year', 'Every :number years', $qty, $placeholders), + default => throw new \Box_Exception('Unit not defined'), + }; return $shift; } @@ -153,22 +144,13 @@ class Box_Period { $qty = 0; - switch ($this->unit) { - case self::UNIT_DAY: - $qty = $this->qty / 30; - break; - case self::UNIT_WEEK: - $qty = $this->qty / 4; - break; - case self::UNIT_MONTH: - $qty = $this->qty; - break; - case self::UNIT_YEAR: - $qty = $this->qty * 12; - break; - default: - throw new \Box_Exception('Unable to get the number of months for :unit',[':unit' => $this->unit]); - } + $qty = match ($this->unit) { + self::UNIT_DAY => $this->qty / 30, + self::UNIT_WEEK => $this->qty / 4, + self::UNIT_MONTH => $this->qty, + self::UNIT_YEAR => $this->qty * 12, + default => throw new \Box_Exception('Unable to get the number of months for :unit',[':unit' => $this->unit]), + }; return $qty; } @@ -179,22 +161,13 @@ class Box_Period $now = time(); } - switch ($this->unit) { - case self::UNIT_DAY: - $shift = 'days'; - break; - case self::UNIT_WEEK: - $shift = 'weeks'; - break; - case self::UNIT_MONTH: - $shift = 'months'; - break; - case self::UNIT_YEAR: - $shift = 'years'; - break; - default: - throw new \Box_Exception('Unit not defined'); - } + $shift = match ($this->unit) { + self::UNIT_DAY => 'days', + self::UNIT_WEEK => 'weeks', + self::UNIT_MONTH => 'months', + self::UNIT_YEAR => 'years', + default => throw new \Box_Exception('Unit not defined'), + }; return strtotime("+$this->qty $shift", $now); } } diff --git a/src/library/Box/Translate.php b/src/library/Box/Translate.php index 431f14d86..0eefc5a47 100644 --- a/src/library/Box/Translate.php +++ b/src/library/Box/Translate.php @@ -10,7 +10,7 @@ class Box_Translate implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; protected $domain = 'messages'; diff --git a/src/library/Box/TwigExtensions.php b/src/library/Box/TwigExtensions.php index fe7462c8d..a7c2d0de3 100644 --- a/src/library/Box/TwigExtensions.php +++ b/src/library/Box/TwigExtensions.php @@ -15,7 +15,7 @@ use League\CommonMark\GithubFlavoredMarkdownConverter; class Box_TwigExtensions extends AbstractExtension implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -98,7 +98,7 @@ class Box_TwigExtensions extends AbstractExtension implements InjectionAwareInte $record = $this->di['geoip']->country($value); return $record->country->name; - } catch (Exception $e) { + } catch (Exception) { return ''; } } @@ -249,7 +249,7 @@ class Box_TwigExtensions extends AbstractExtension implements InjectionAwareInte $cur_tm = time(); $dif = $cur_tm - strtotime($iso8601); $pds = [__trans('second'), __trans('minute'), __trans('hour'), __trans('day'), __trans('week'), __trans('month'), __trans('year'), __trans('decade')]; - $lngh = [1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600]; + $lngh = [1, 60, 3600, 86400, 604800, 2_630_880, 31_570_560, 315_705_600]; $no = 0; for ($v = sizeof($lngh) - 1; ($v >= 0) && (($no = $dif / $lngh[$v]) <= 1); --$v) { @@ -280,7 +280,7 @@ class Box_TwigExtensions extends AbstractExtension implements InjectionAwareInte $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); - $bytes /= pow(1024, $pow); + $bytes /= 1024 ** $pow; return round($bytes, $precision) . ' ' . $units[$pow]; } diff --git a/src/library/Box/Url.php b/src/library/Box/Url.php index e08d0045b..f1066de76 100644 --- a/src/library/Box/Url.php +++ b/src/library/Box/Url.php @@ -10,7 +10,7 @@ class Box_Url implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; protected $baseUri; public function setDi(\Pimple\Container $di): void diff --git a/src/library/Box/UrlHelper.php b/src/library/Box/UrlHelper.php index 10e45aa21..6a195af38 100644 --- a/src/library/Box/UrlHelper.php +++ b/src/library/Box/UrlHelper.php @@ -9,22 +9,17 @@ */ class Box_UrlHelper { - private $method; - private $conditions; - public $params = array(); public $match = false; /** * @param string $requestUri */ - public function __construct($httpMethod, $url, $conditions, $requestUri) { + public function __construct(private $method, $url, private $conditions, $requestUri) { $requestMethod = $_SERVER['REQUEST_METHOD']; - $this->method = $httpMethod; - $this->conditions = $conditions; - if (strtoupper($httpMethod) == $requestMethod) { + if (strtoupper($method) == $requestMethod) { $paramNames = array(); $paramValues = array(); diff --git a/src/library/FOSSBilling/CentralAlerts.php b/src/library/FOSSBilling/CentralAlerts.php index 0b80a6aab..b3d0f8416 100644 --- a/src/library/FOSSBilling/CentralAlerts.php +++ b/src/library/FOSSBilling/CentralAlerts.php @@ -18,7 +18,7 @@ use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; class CentralAlerts implements InjectionAwareInterface { - protected ?Container $di; + protected ?Container $di = null; private string $_url = 'https://fossbilling.org/api/central-alerts/'; @@ -69,16 +69,12 @@ class CentralAlerts implements InjectionAwareInterface $alerts = $this->getAlerts(); if (is_array($type) && !empty($type)) { - $alerts = array_filter($alerts, function($alert) use ($type) { - return in_array($alert['type'], $type); - }); + $alerts = array_filter($alerts, fn($alert) => in_array($alert['type'], $type)); } if ($version) { if ($this->di['config']['update_branch'] === 'preview') { - $alerts = array_filter($alerts, function($alert) { - return $alert['include_preview_branch']; - }); + $alerts = array_filter($alerts, fn($alert) => $alert['include_preview_branch']); } else { $alerts = array_filter($alerts, function($alert) use ($version) { $overThanTheMinimum = version_compare(strtolower($version), strtolower($alert['min_fossbilling_version']), '>='); diff --git a/src/library/FOSSBilling/ExtensionManager.php b/src/library/FOSSBilling/ExtensionManager.php index 4fe40785b..04dfded07 100644 --- a/src/library/FOSSBilling/ExtensionManager.php +++ b/src/library/FOSSBilling/ExtensionManager.php @@ -14,15 +14,15 @@ use Symfony\Component\HttpClient\HttpClient; class ExtensionManager implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; - const TYPE_MOD = 'mod'; - const TYPE_THEME = 'theme'; - const TYPE_PG = 'payment-gateway'; - const TYPE_SM = 'server-manager'; - const TYPE_DR = 'domain-registrar'; - const TYPE_HOOK = 'hook'; - const TYPE_TRANSLATION = 'translation'; + public const TYPE_MOD = 'mod'; + public const TYPE_THEME = 'theme'; + public const TYPE_PG = 'payment-gateway'; + public const TYPE_SM = 'server-manager'; + public const TYPE_DR = 'domain-registrar'; + public const TYPE_HOOK = 'hook'; + public const TYPE_TRANSLATION = 'translation'; private string $_url = 'https://extensions.fossbilling.org/api/'; diff --git a/src/library/FOSSBilling/Mail.php b/src/library/FOSSBilling/Mail.php index 2f379dea4..7f7902fd7 100644 --- a/src/library/FOSSBilling/Mail.php +++ b/src/library/FOSSBilling/Mail.php @@ -18,11 +18,11 @@ use Symfony\Component\Mime\Address; class Mail implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; private Email $email; - private $transport = null; - private $dsn = null; + private ?string $transport = null; + private ?string $dsn = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/library/FOSSBilling/Monolog.php b/src/library/FOSSBilling/Monolog.php index d34c3f066..d8aa75eee 100644 --- a/src/library/FOSSBilling/Monolog.php +++ b/src/library/FOSSBilling/Monolog.php @@ -16,7 +16,6 @@ use Monolog\Handler\StreamHandler; class Monolog implements InjectionAwareInterface { - protected ?\Pimple\Container $di; protected $logger = null; public string $dateFormat = "d-M-Y H:i:s e"; public string $outputFormat = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; @@ -40,9 +39,8 @@ class Monolog implements InjectionAwareInterface return $this->di; } - public function __construct(\Pimple\Container $di) + public function __construct(protected ?\Pimple\Container $di) { - $this->di = $di; $channels = $this->channels; foreach ($channels as $channel) { @@ -58,7 +56,6 @@ class Monolog implements InjectionAwareInterface } /** - * @param string $channel * @return \Monolog\Logger The logger for the specified channel. If the channel does not exist, the default logger (the 'application' channel) is returned. */ public function getChannel(string $channel = 'application'): Logger @@ -69,7 +66,6 @@ class Monolog implements InjectionAwareInterface /** * Convert numeric FOSSBilling priority to Monolog priority * - * @param int $priority * @return int */ public function parsePriority(int $priority): int @@ -89,10 +85,6 @@ class Monolog implements InjectionAwareInterface return $map[$priority] ?? Logger::DEBUG; } - /** - * @param array $event - * @param string $channel - */ public function write(array $event, string $channel = 'application'): void { $priority = $this->parsePriority($event['priority']); diff --git a/src/library/FOSSBilling/Request.php b/src/library/FOSSBilling/Request.php index a788c5334..72a604357 100644 --- a/src/library/FOSSBilling/Request.php +++ b/src/library/FOSSBilling/Request.php @@ -13,7 +13,7 @@ namespace FOSSBilling; class Request implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -40,8 +40,8 @@ class Request implements InjectionAwareInterface } if (is_string($address)) { - if (strpos($address, ',') !== false) { - list($address) = explode(',', $address); + if (str_contains($address, ',')) { + [$address] = explode(',', $address); } } return $address; diff --git a/src/library/FOSSBilling/Requirements.php b/src/library/FOSSBilling/Requirements.php index 9d0f46313..756860801 100644 --- a/src/library/FOSSBilling/Requirements.php +++ b/src/library/FOSSBilling/Requirements.php @@ -12,7 +12,7 @@ namespace FOSSBilling; class Requirements implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -189,8 +189,6 @@ class Requirements implements InjectionAwareInterface /** * Check permissions - * @param string $path - * @param string $perm * @return bool */ public function checkPerms(string $path, string $perm = '0777'): bool diff --git a/src/library/FOSSBilling/Session.php b/src/library/FOSSBilling/Session.php index c68dc0ca4..b08cb3134 100644 --- a/src/library/FOSSBilling/Session.php +++ b/src/library/FOSSBilling/Session.php @@ -13,11 +13,7 @@ namespace FOSSBilling; class Session implements \FOSSBilling\InjectionAwareInterface { - private ?\Pimple\Container $di; - private \PdoSessionHandler $handler; - private string $securityMode; - private int $cookieLifespan; - private bool $secure; + private ?\Pimple\Container $di = null; public function setDi(\Pimple\Container|null $di): void { @@ -29,12 +25,8 @@ class Session implements \FOSSBilling\InjectionAwareInterface return $this->di; } - public function __construct(\PdoSessionHandler $handler, string $securityMode = 'regular', int $cookieLifespan = 7200, bool $secure = true) + public function __construct(private \PdoSessionHandler $handler, private string $securityMode = 'regular', private int $cookieLifespan = 7200, private bool $secure = true) { - $this->handler = $handler; - $this->securityMode = $securityMode; - $this->cookieLifespan = $cookieLifespan; - $this->secure = $secure; } public function setupSession() diff --git a/src/library/FOSSBilling/Tools.php b/src/library/FOSSBilling/Tools.php index bcda9d1a5..c38f2eb43 100644 --- a/src/library/FOSSBilling/Tools.php +++ b/src/library/FOSSBilling/Tools.php @@ -12,7 +12,7 @@ namespace FOSSBilling; class Tools { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -142,16 +142,16 @@ class Tools $passOrder = array(); for ($i = 0; $i < $upper; $i++) { - $passOrder[] = $upper_letters[random_int(0, getrandmax()) % strlen($upper_letters)]; + $passOrder[] = $upper_letters[random_int(0, mt_getrandmax()) % strlen($upper_letters)]; } for ($i = 0; $i < $lower; $i++) { - $passOrder[] = $lower_letters[random_int(0, getrandmax()) % strlen($lower_letters)]; + $passOrder[] = $lower_letters[random_int(0, mt_getrandmax()) % strlen($lower_letters)]; } for ($i = 0; $i < $numeric; $i++) { - $passOrder[] = $numbers[random_int(0, getrandmax()) % strlen($numbers)]; + $passOrder[] = $numbers[random_int(0, mt_getrandmax()) % strlen($numbers)]; } for ($i = 0; $i < $other; $i++) { - $passOrder[] = $symbols[random_int(0, getrandmax()) % strlen($symbols)]; + $passOrder[] = $symbols[random_int(0, mt_getrandmax()) % strlen($symbols)]; } shuffle($passOrder); @@ -198,18 +198,14 @@ class Tools if ($capitalize_first_char) { $str[0] = strtoupper($str[0]); } - $func = function ($c) { - return strtoupper($c[1]); - }; + $func = fn($c) => strtoupper($c[1]); return preg_replace_callback('/-([a-z])/', $func, $str); } public function from_camel_case($str) { $str[0] = strtolower($str[0]); - $func = function ($c) { - return "-" . strtolower($c[1]); - }; + $func = fn($c) => "-" . strtolower($c[1]); return preg_replace_callback('/([A-Z])/', $func, $str); } @@ -229,7 +225,7 @@ class Tools $values = array(); foreach ($array as $id => $value) { - $values[$id] = isset($value[$key]) ? $value[$key] : ''; + $values[$id] = $value[$key] ?? ''; } if ($asc) { @@ -262,7 +258,7 @@ class Tools return array(); } - $slots = (count($ids)) ? implode(',', array_fill(0, count($ids), '?')) : ''; //same as RedBean genSlots() method + $slots = (is_countable($ids) ? count($ids) : 0) ? implode(',', array_fill(0, is_countable($ids) ? count($ids) : 0, '?')) : ''; //same as RedBean genSlots() method $rows = $this->di['db']->getAll('SELECT id, title FROM ' . $table . ' WHERE id in (' . $slots . ')', $ids); diff --git a/src/library/FOSSBilling/Update.php b/src/library/FOSSBilling/Update.php index 2618e395d..1063efe76 100644 --- a/src/library/FOSSBilling/Update.php +++ b/src/library/FOSSBilling/Update.php @@ -21,7 +21,7 @@ use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; class Update implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -40,7 +40,7 @@ class Update implements InjectionAwareInterface */ public function getUpdateBranch(): string { - return (isset($this->di['config']['update_branch'])) ? $this->di['config']['update_branch'] : 'release'; + return $this->di['config']['update_branch'] ?? 'release'; } /** diff --git a/src/library/FOSSBilling/UpdatePatcher.php b/src/library/FOSSBilling/UpdatePatcher.php index d268d1d61..c62ec74d1 100644 --- a/src/library/FOSSBilling/UpdatePatcher.php +++ b/src/library/FOSSBilling/UpdatePatcher.php @@ -17,7 +17,7 @@ use Symfony\Component\Filesystem\Filesystem; class UpdatePatcher implements InjectionAwareInterface { - private ?\Pimple\Container $di; + private ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -95,7 +95,7 @@ class UpdatePatcher implements InjectionAwareInterface // Write updated configuration file. try { $filesystem->dumpFile($configPath, $output); - } catch (IOException $e) { + } catch (IOException) { throw new \Box_Exception('Error when writing updated configuration file.'); } } @@ -294,8 +294,6 @@ class UpdatePatcher implements InjectionAwareInterface ]; ksort($patches, SORT_NATURAL); - return array_filter($patches, function ($key) use ($patchLevel) { - return $key > $patchLevel; - }, ARRAY_FILTER_USE_KEY); + return array_filter($patches, fn($key) => $key > $patchLevel, ARRAY_FILTER_USE_KEY); } } diff --git a/src/library/FOSSBilling/Validate.php b/src/library/FOSSBilling/Validate.php index be28f886a..e7de3dcb0 100644 --- a/src/library/FOSSBilling/Validate.php +++ b/src/library/FOSSBilling/Validate.php @@ -12,7 +12,7 @@ namespace FOSSBilling; class Validate { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -30,7 +30,7 @@ class Validate public function isSldValid(string $sld) : bool { // allow punnycode - if(substr($sld, 0, 4) == 'xn--') { + if(str_starts_with($sld, 'xn--')) { return true; } diff --git a/src/library/FOSSBilling/Version.php b/src/library/FOSSBilling/Version.php index 2a9e73e3d..88b553fa7 100644 --- a/src/library/FOSSBilling/Version.php +++ b/src/library/FOSSBilling/Version.php @@ -12,7 +12,7 @@ namespace FOSSBilling; final class Version { - const VERSION = '0.0.1'; + public const VERSION = '0.0.1'; /** * Compare the specified FOSSBilling version string $version diff --git a/src/library/FOSSBilling/i18n.php b/src/library/FOSSBilling/i18n.php index 278eb39e1..f3e0cba25 100644 --- a/src/library/FOSSBilling/i18n.php +++ b/src/library/FOSSBilling/i18n.php @@ -66,13 +66,13 @@ class i18n } foreach (self::getLocales() as $locale) { if (str_starts_with($locale, substr($detectedLocale, 0, 2))) { - setcookie("BBLANG", $locale, strtotime("+1 month"), "/"); + setcookie("BBLANG", $locale, ['expires' => strtotime("+1 month"), 'path' => "/"]); return $locale; } } } - setcookie("BBLANG", $matchingLocale, strtotime("+1 month"), "/"); + setcookie("BBLANG", $matchingLocale, ['expires' => strtotime("+1 month"), 'path' => "/"]); return $matchingLocale; } diff --git a/src/library/Model/ActivityClientHistoryTable.php b/src/library/Model/ActivityClientHistoryTable.php index 455a0c875..9b1dbe8e0 100644 --- a/src/library/Model/ActivityClientHistoryTable.php +++ b/src/library/Model/ActivityClientHistoryTable.php @@ -10,7 +10,7 @@ class Model_ActivityClientHistoryTable implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/library/Model/Admin.php b/src/library/Model/Admin.php index 7a5b98a59..62ceb072a 100644 --- a/src/library/Model/Admin.php +++ b/src/library/Model/Admin.php @@ -10,12 +10,12 @@ class Model_Admin extends \RedBeanPHP\SimpleModel { - const ROLE_ADMIN = 'admin'; - const ROLE_STAFF = 'staff'; - const ROLE_CRON = 'cron'; + public const ROLE_ADMIN = 'admin'; + public const ROLE_STAFF = 'staff'; + public const ROLE_CRON = 'cron'; - const STATUS_ACTIVE = 'active'; - const STATUS_INACTIVE = 'inactive'; + public const STATUS_ACTIVE = 'active'; + public const STATUS_INACTIVE = 'inactive'; public function getFullName() { diff --git a/src/library/Model/ApiRequestTable.php b/src/library/Model/ApiRequestTable.php index 8045039a0..3f8b8c47c 100644 --- a/src/library/Model/ApiRequestTable.php +++ b/src/library/Model/ApiRequestTable.php @@ -10,7 +10,7 @@ class Model_ApiRequestTable implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/library/Model/Client.php b/src/library/Model/Client.php index adbc4b1b9..93b88ad19 100644 --- a/src/library/Model/Client.php +++ b/src/library/Model/Client.php @@ -10,9 +10,9 @@ class Model_Client extends \RedBeanPHP\SimpleModel { - const ACTIVE = 'active'; - const SUSPENDED = 'suspended'; - const CANCELED = 'canceled'; + public const ACTIVE = 'active'; + public const SUSPENDED = 'suspended'; + public const CANCELED = 'canceled'; public function getFullName() { diff --git a/src/library/Model/ClientOrder.php b/src/library/Model/ClientOrder.php index 5645894ba..915bf069a 100644 --- a/src/library/Model/ClientOrder.php +++ b/src/library/Model/ClientOrder.php @@ -10,19 +10,19 @@ class Model_ClientOrder extends \RedBeanPHP\SimpleModel { - const STATUS_PENDING_SETUP = "pending_setup"; - const STATUS_FAILED_SETUP = "failed_setup"; - const STATUS_FAILED_RENEW = "failed_renew"; - const STATUS_ACTIVE = "active"; - const STATUS_CANCELED = "canceled"; - const STATUS_SUSPENDED = "suspended"; + public const STATUS_PENDING_SETUP = "pending_setup"; + public const STATUS_FAILED_SETUP = "failed_setup"; + public const STATUS_FAILED_RENEW = "failed_renew"; + public const STATUS_ACTIVE = "active"; + public const STATUS_CANCELED = "canceled"; + public const STATUS_SUSPENDED = "suspended"; - const ACTION_CREATE = 'create'; - const ACTION_ACTIVATE = 'activate'; - const ACTION_RENEW = 'renew'; - const ACTION_SUSPEND = 'suspend'; - const ACTION_UNSUSPEND = 'unsuspend'; - const ACTION_CANCEL = 'cancel'; - const ACTION_UNCANCEL = 'uncancel'; - const ACTION_DELETE = 'delete'; + public const ACTION_CREATE = 'create'; + public const ACTION_ACTIVATE = 'activate'; + public const ACTION_RENEW = 'renew'; + public const ACTION_SUSPEND = 'suspend'; + public const ACTION_UNSUSPEND = 'unsuspend'; + public const ACTION_CANCEL = 'cancel'; + public const ACTION_UNCANCEL = 'uncancel'; + public const ACTION_DELETE = 'delete'; } diff --git a/src/library/Model/ClientPasswordResetTable.php b/src/library/Model/ClientPasswordResetTable.php index 968b0677a..bf3ffb6b9 100644 --- a/src/library/Model/ClientPasswordResetTable.php +++ b/src/library/Model/ClientPasswordResetTable.php @@ -10,7 +10,7 @@ class Model_ClientPasswordResetTable implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/library/Model/Invoice.php b/src/library/Model/Invoice.php index d707bf6d0..b358d77b6 100644 --- a/src/library/Model/Invoice.php +++ b/src/library/Model/Invoice.php @@ -10,8 +10,8 @@ class Model_Invoice extends \RedBeanPHP\SimpleModel { - const STATUS_PAID = 'paid'; - const STATUS_UNPAID = 'unpaid'; - const STATUS_REFUNDED = 'refunded'; - const STATUS_CANCELED = 'canceled'; + public const STATUS_PAID = 'paid'; + public const STATUS_UNPAID = 'unpaid'; + public const STATUS_REFUNDED = 'refunded'; + public const STATUS_CANCELED = 'canceled'; } diff --git a/src/library/Model/InvoiceItem.php b/src/library/Model/InvoiceItem.php index c5f6ab567..56573e152 100644 --- a/src/library/Model/InvoiceItem.php +++ b/src/library/Model/InvoiceItem.php @@ -10,16 +10,16 @@ class Model_InvoiceItem extends \RedBeanPHP\SimpleModel { - const TYPE_DEPOSIT = 'deposit'; // this type of item can not be charged with credits - const TYPE_CUSTOM = 'custom'; - const TYPE_ORDER = 'order'; - const TYPE_HOOK_CALL= 'hook_call'; + public const TYPE_DEPOSIT = 'deposit'; // this type of item can not be charged with credits + public const TYPE_CUSTOM = 'custom'; + public const TYPE_ORDER = 'order'; + public const TYPE_HOOK_CALL= 'hook_call'; - const TASK_VOID = 'void'; - const TASK_ACTIVATE = 'activate'; - const TASK_RENEW = 'renew'; + public const TASK_VOID = 'void'; + public const TASK_ACTIVATE = 'activate'; + public const TASK_RENEW = 'renew'; - const STATUS_PENDING_PAYMENT = 'pending_payment'; - const STATUS_PENDING_SETUP = 'pending_setup'; - const STATUS_EXECUTED = 'executed'; + public const STATUS_PENDING_PAYMENT = 'pending_payment'; + public const STATUS_PENDING_SETUP = 'pending_setup'; + public const STATUS_EXECUTED = 'executed'; } diff --git a/src/library/Model/KbArticle.php b/src/library/Model/KbArticle.php index 4da0c5da1..ae0e00ec3 100644 --- a/src/library/Model/KbArticle.php +++ b/src/library/Model/KbArticle.php @@ -10,6 +10,6 @@ class Model_KbArticle extends \RedBeanPHP\SimpleModel { - const ACTIVE = 'active'; - const DRAFT = 'draft'; + public const ACTIVE = 'active'; + public const DRAFT = 'draft'; } diff --git a/src/library/Model/Product.php b/src/library/Model/Product.php index aac341bcc..6f82efe77 100644 --- a/src/library/Model/Product.php +++ b/src/library/Model/Product.php @@ -10,23 +10,23 @@ class Model_Product extends \RedBeanPHP\SimpleModel implements \FOSSBilling\InjectionAwareInterface { - const STATUS_ENABLED = 'enabled'; - const STATUS_DISABLED = 'disabled'; + public const STATUS_ENABLED = 'enabled'; + public const STATUS_DISABLED = 'disabled'; - const CUSTOM = 'custom'; - const LICENSE = 'license'; - const ADDON = 'addon'; - const DOMAIN = 'domain'; - const DOWNLOADABLE = 'downloadable'; - const HOSTING = 'hosting'; - const MEMBERSHIP = 'membership'; - const VPS = 'vps'; + public const CUSTOM = 'custom'; + public const LICENSE = 'license'; + public const ADDON = 'addon'; + public const DOMAIN = 'domain'; + public const DOWNLOADABLE = 'downloadable'; + public const HOSTING = 'hosting'; + public const MEMBERSHIP = 'membership'; + public const VPS = 'vps'; - const SETUP_AFTER_ORDER = 'after_order'; - const SETUP_AFTER_PAYMENT = 'after_payment'; - const SETUP_MANUAL = 'manual'; + public const SETUP_AFTER_ORDER = 'after_order'; + public const SETUP_AFTER_PAYMENT = 'after_payment'; + public const SETUP_MANUAL = 'manual'; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/library/Model/ProductDomainTable.php b/src/library/Model/ProductDomainTable.php index 9c06d8f66..513c1f413 100644 --- a/src/library/Model/ProductDomainTable.php +++ b/src/library/Model/ProductDomainTable.php @@ -97,7 +97,7 @@ class Model_ProductDomainTable extends Model_ProductTable $addon_qty = $addon_sys_period->getQty(); $free_domain_periods = $addon['config']['free_domain_periods']; - if (count($free_domain_periods) > 0) { + if ((is_countable($free_domain_periods) ? count($free_domain_periods) : 0) > 0) { // if hosting and domain periods are equal, return domain quantity (year) if ($addon_period == $period) { @@ -106,7 +106,7 @@ class Model_ProductDomainTable extends Model_ProductTable } } - if (strpos($addon_period, 'Y') !== false) { + if (str_contains($addon_period, 'Y')) { if (min($ref_item_qty, $addon_qty) == 1) { return 1; diff --git a/src/library/Model/ProductPayment.php b/src/library/Model/ProductPayment.php index de604fe65..590ba655c 100644 --- a/src/library/Model/ProductPayment.php +++ b/src/library/Model/ProductPayment.php @@ -10,7 +10,7 @@ class Model_ProductPayment extends \RedBeanPHP\SimpleModel { - const FREE = 'free'; - const ONCE = 'once'; - const RECURRENT = 'recurrent'; + public const FREE = 'free'; + public const ONCE = 'once'; + public const RECURRENT = 'recurrent'; } diff --git a/src/library/Model/ProductTable.php b/src/library/Model/ProductTable.php index 585913242..ddefdc90f 100644 --- a/src/library/Model/ProductTable.php +++ b/src/library/Model/ProductTable.php @@ -10,20 +10,20 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface { - const CUSTOM = 'custom'; - const LICENSE = 'license'; - const ADDON = 'addon'; - const DOMAIN = 'domain'; - const DOWNLOADABLE = 'downloadable'; - const HOSTING = 'hosting'; - const MEMBERSHIP = 'membership'; - const VPS = 'vps'; + public const CUSTOM = 'custom'; + public const LICENSE = 'license'; + public const ADDON = 'addon'; + public const DOMAIN = 'domain'; + public const DOWNLOADABLE = 'downloadable'; + public const HOSTING = 'hosting'; + public const MEMBERSHIP = 'membership'; + public const VPS = 'vps'; - const SETUP_AFTER_ORDER = 'after_order'; - const SETUP_AFTER_PAYMENT = 'after_payment'; - const SETUP_MANUAL = 'manual'; + public const SETUP_AFTER_ORDER = 'after_order'; + public const SETUP_AFTER_PAYMENT = 'after_payment'; + public const SETUP_MANUAL = 'manual'; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -41,7 +41,6 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface } /** - * @param Box_Period $period * @return string */ private function _getPeriodKey(Box_Period $period) @@ -71,7 +70,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface return $service->toProductPaymentApiArray($productPayment); } - throw new \Box_Exception('Product pricing could not be determined. ' . get_class($this)); + throw new \Box_Exception('Product pricing could not be determined. ' . static::class); } /** diff --git a/src/library/Model/Promo.php b/src/library/Model/Promo.php index dbb05a798..d32e00825 100644 --- a/src/library/Model/Promo.php +++ b/src/library/Model/Promo.php @@ -10,6 +10,6 @@ class Model_Promo extends \RedBeanPHP\SimpleModel { - const PERCENTAGE = 'percentage'; - const ABSOLUTE = 'absolute'; + public const PERCENTAGE = 'percentage'; + public const ABSOLUTE = 'absolute'; } diff --git a/src/library/Model/SupportPTicket.php b/src/library/Model/SupportPTicket.php index 88ebf53c5..fa915acc7 100644 --- a/src/library/Model/SupportPTicket.php +++ b/src/library/Model/SupportPTicket.php @@ -10,7 +10,7 @@ class Model_SupportPTicket extends \RedBeanPHP\SimpleModel { - const OPENED = 'open'; - const ONHOLD = 'on_hold'; - const CLOSED = 'closed'; + public const OPENED = 'open'; + public const ONHOLD = 'on_hold'; + public const CLOSED = 'closed'; } diff --git a/src/library/Model/SupportTicket.php b/src/library/Model/SupportTicket.php index 931711e67..8c2d9df55 100644 --- a/src/library/Model/SupportTicket.php +++ b/src/library/Model/SupportTicket.php @@ -10,15 +10,15 @@ class Model_SupportTicket extends \RedBeanPHP\SimpleModel { - const OPENED = 'open'; - const ONHOLD = 'on_hold'; - const CLOSED = 'closed'; + public const OPENED = 'open'; + public const ONHOLD = 'on_hold'; + public const CLOSED = 'closed'; - const REL_TYPE_ORDER = 'order'; + public const REL_TYPE_ORDER = 'order'; - const REL_STATUS_PENDING = 'pending'; - const REL_STATUS_COMPLETE = 'complete'; + public const REL_STATUS_PENDING = 'pending'; + public const REL_STATUS_COMPLETE = 'complete'; - const REL_TASK_CANCEL = 'cancel'; - const REL_TASK_UPGRADE = 'upgrade'; + public const REL_TASK_CANCEL = 'cancel'; + public const REL_TASK_UPGRADE = 'upgrade'; } diff --git a/src/library/Model/Transaction.php b/src/library/Model/Transaction.php index 863d7192b..f93b3309f 100644 --- a/src/library/Model/Transaction.php +++ b/src/library/Model/Transaction.php @@ -10,8 +10,8 @@ class Model_Transaction extends \RedBeanPHP\SimpleModel { - const STATUS_RECEIVED = 'received'; - const STATUS_APPROVED = 'approved'; - const STATUS_PROCESSED = 'processed'; - const STATUS_ERROR = 'error'; + public const STATUS_RECEIVED = 'received'; + public const STATUS_APPROVED = 'approved'; + public const STATUS_PROCESSED = 'processed'; + public const STATUS_ERROR = 'error'; } diff --git a/src/library/Payment/Adapter/ClientBalance.php b/src/library/Payment/Adapter/ClientBalance.php index ee70ca3ac..5b2859207 100644 --- a/src/library/Payment/Adapter/ClientBalance.php +++ b/src/library/Payment/Adapter/ClientBalance.php @@ -10,7 +10,7 @@ class Payment_Adapter_ClientBalance implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -85,7 +85,7 @@ class Payment_Adapter_ClientBalance implements \FOSSBilling\InjectionAwareInterf $tx = $this->di['db']->load('Transaction', $id); - $invoice_id = isset($data['get']['bb_invoice_id']) ? $data['get']['bb_invoice_id'] : 0; + $invoice_id = $data['get']['bb_invoice_id'] ?? 0; $invoiceModel = $this->di['db']->load('Invoice', $invoice_id); $invoiceService = $this->di['mod_service']('Invoice'); diff --git a/src/library/Payment/Adapter/Custom.php b/src/library/Payment/Adapter/Custom.php index 88a7a41e1..1085c0f30 100644 --- a/src/library/Payment/Adapter/Custom.php +++ b/src/library/Payment/Adapter/Custom.php @@ -10,12 +10,10 @@ class Payment_Adapter_Custom { - private $config = array(); - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; - public function __construct($config) + public function __construct(private $config) { - $this->config = $config; } public function setDi(\Pimple\Container $di): void @@ -68,7 +66,7 @@ class Payment_Adapter_Custom $vars = array( '_client_id' => $invoice['client']['id'], 'invoice' => $invoice, - '_tpl' => $subscription ? (isset($this->config['recurrent']) ? $this->config['recurrent'] : '"Custom" payment adapter is not fully configured.') : (isset($this->config['single']) ? $this->config['single'] : '"Custom" payment adapter is not fully configured.'), + '_tpl' => $subscription ? ($this->config['recurrent'] ?? '"Custom" payment adapter is not fully configured.') : ($this->config['single'] ?? '"Custom" payment adapter is not fully configured.'), ); $systemService = $this->di['mod_service']('System'); return $systemService->renderString($vars['_tpl'], true, $vars); diff --git a/src/library/Payment/Adapter/Interkassa.php b/src/library/Payment/Adapter/Interkassa.php index 076756d25..9f4f5fd8a 100644 --- a/src/library/Payment/Adapter/Interkassa.php +++ b/src/library/Payment/Adapter/Interkassa.php @@ -10,7 +10,7 @@ class Payment_Adapter_Interkassa extends Payment_AdapterAbstract implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -87,12 +87,11 @@ class Payment_Adapter_Interkassa extends Payment_AdapterAbstract implements \FOS } /** - * Init single payment call to webservice - * Invoice id is passed via notify_url + * Init single payment call to webservice + * Invoice id is passed via notify_url * - * @param Payment_Invoice $invoice - * @return array - */ + * @return array + */ public function singlePayment(Payment_Invoice $invoice) { return array( @@ -251,7 +250,7 @@ class Payment_Adapter_Interkassa extends Payment_AdapterAbstract implements \FOS ); $rows = $this->di['db']->getAll($sql, $bindings); - if (count($rows) > 1){ + if ((is_countable($rows) ? count($rows) : 0) > 1){ return true; } diff --git a/src/library/Payment/Adapter/Onebip.php b/src/library/Payment/Adapter/Onebip.php index a4bdebc45..e0fd0b2b1 100644 --- a/src/library/Payment/Adapter/Onebip.php +++ b/src/library/Payment/Adapter/Onebip.php @@ -65,7 +65,6 @@ class Payment_Adapter_Onebip extends Payment_AdapterAbstract * Init call to webservice or return form params * * @see http://www.onebip.com/website/docs/Onebip_API.pdf - * @param Payment_Invoice $invoice */ public function singlePayment(Payment_Invoice $invoice) { @@ -106,7 +105,6 @@ class Payment_Adapter_Onebip extends Payment_AdapterAbstract /** * Perform recurent payment - * @param Payment_Invoice $invoice */ public function recurrentPayment(Payment_Invoice $invoice) { diff --git a/src/library/Payment/Adapter/PayPalEmail.php b/src/library/Payment/Adapter/PayPalEmail.php index 5b29b95bf..2124a9849 100644 --- a/src/library/Payment/Adapter/PayPalEmail.php +++ b/src/library/Payment/Adapter/PayPalEmail.php @@ -12,9 +12,7 @@ use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface; class Payment_Adapter_PayPalEmail extends Payment_AdapterAbstract implements \FOSSBilling\InjectionAwareInterface { - private $config = array(); - - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -26,10 +24,8 @@ class Payment_Adapter_PayPalEmail extends Payment_AdapterAbstract implements \FO return $this->di; } - public function __construct($config) + public function __construct(private $config) { - $this->config = $config; - if(!isset($this->config['email'])) { throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'PayPal', ':missing' => 'PayPal Email address']); } @@ -288,7 +284,7 @@ class Payment_Adapter_PayPalEmail extends Payment_AdapterAbstract implements \FO ); $rows = $this->di['db']->getAll($sql, $bindings); - if (count($rows) > 1){ + if ((is_countable($rows) ? count($rows) : 0) > 1){ return true; } diff --git a/src/library/Payment/Adapter/Stripe.php b/src/library/Payment/Adapter/Stripe.php index 14222f0c5..8ef982635 100644 --- a/src/library/Payment/Adapter/Stripe.php +++ b/src/library/Payment/Adapter/Stripe.php @@ -10,11 +10,9 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface { - private $config = array(); + protected ?\Pimple\Container $di = null; - protected ?\Pimple\Container $di; - - private $stripe; + private \Stripe\StripeClient $stripe; public function setDi(\Pimple\Container $di): void { @@ -26,10 +24,8 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface return $this->di; } - public function __construct($config) + public function __construct(private $config) { - $this->config = $config; - if (!isset($this->config['api_key'])) { throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'API key']); } @@ -103,7 +99,7 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface ':title' => $invoiceItems[0]['title'] ]; $title = __trans('Payment for invoice :serie:id [:title]', $params); - if (count($invoiceItems) > 1) { + if ((is_countable($invoiceItems) ? count($invoiceItems) : 0) > 1) { $title = __trans('Payment for invoice :serie:id', $params); } return $title; @@ -140,10 +136,6 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface [] ); - if (!isset($charge)) { - throw new \Exception("Failed to get the charge item from Stripe."); - } - $tx->txn_status = $charge->status; $tx->txn_id = $charge->id; $tx->amount = $charge->amount / 100; @@ -170,13 +162,8 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface $invoiceService->doBatchPayWithCredits(array('client_id' => $client->id)); } - } catch (\Stripe\Exception\CardException $e) { - $this->logError($e, $tx); - } catch (\Stripe\Exception\InvalidRequestException $e) { - $this->logError($e, $tx); - } catch (\Stripe\Exception\AuthenticationException $e) { - $this->logError($e, $tx); - } catch (\Stripe\Exception\ApiConnectionException $e) { + } catch (\Stripe\Exception\CardException|\Stripe\Exception\InvalidRequestException|\Stripe\Exception\AuthenticationException|\Stripe\Exception\ApiConnectionException|\Stripe\Exception\ApiErrorException $e) { + throw new Box_Exception("There was an error when processing the transaction"); $this->logError($e, $tx); } diff --git a/src/library/Payment/Adapter/TwoCheckout.php b/src/library/Payment/Adapter/TwoCheckout.php index b7aabadfa..e7946fd78 100644 --- a/src/library/Payment/Adapter/TwoCheckout.php +++ b/src/library/Payment/Adapter/TwoCheckout.php @@ -10,9 +10,9 @@ class Payment_Adapter_TwoCheckout implements \FOSSBilling\InjectionAwareInterface { - private $config = array(); + private array $config = array(); - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -184,48 +184,18 @@ class Payment_Adapter_TwoCheckout implements \FOSSBilling\InjectionAwareInterfac $recurrence = '1M'; if(isset($ipn['li_0_recurrence'])) { - switch ($ipn['li_0_recurrence']) { - case '3 Year': - $recurrence = '3Y'; - break; - - case '2 Year': - $recurrence = '2Y'; - break; - - case '1 Year': - $recurrence = '1Y'; - break; - - case '6 Month': - $recurrence = '6M'; - break; - - case '3 Month': - $recurrence = '3M'; - break; - - case '2 Month': - $recurrence = '2M'; - break; - - case '3 Week': - $recurrence = '3W'; - break; - - case '2 Week': - $recurrence = '2W'; - break; - - case '1 Week': - $recurrence = '1W'; - break; - - case '1 Month': - default: - $recurrence = '1M'; - break; - } + $recurrence = match ($ipn['li_0_recurrence']) { + '3 Year' => '3Y', + '2 Year' => '2Y', + '1 Year' => '1Y', + '6 Month' => '6M', + '3 Month' => '3M', + '2 Month' => '2M', + '3 Week' => '3W', + '2 Week' => '2W', + '1 Week' => '1W', + default => '1M', + }; } $sd = array( @@ -306,20 +276,11 @@ class Payment_Adapter_TwoCheckout implements \FOSSBilling\InjectionAwareInterfac $data['sid'] = $this->config['vendor_nr']; $data['mode'] = '2CO'; - switch ($subs['unit']) { - case 'W': - $unit = 'Week'; - break; - - case 'Y': - $unit = 'Year'; - break; - - case 'M': - default: - $unit = 'Month'; - break; - } + $unit = match ($subs['unit']) { + 'W' => 'Week', + 'Y' => 'Year', + default => 'Month', + }; foreach($invoice['lines'] as $i => $item) { $data['li_' . $i . '_type'] = 'product'; @@ -384,7 +345,7 @@ class Payment_Adapter_TwoCheckout implements \FOSSBilling\InjectionAwareInterfac ); $rows = $this->di['db']->getAll($sql, $bindings); - if (count($rows) > 1){ + if ((is_countable($rows) ? count($rows) : 0) > 1){ return true; } diff --git a/src/library/Payment/Adapter/WebMoney.php b/src/library/Payment/Adapter/WebMoney.php index 1bda3b897..fcec05a48 100644 --- a/src/library/Payment/Adapter/WebMoney.php +++ b/src/library/Payment/Adapter/WebMoney.php @@ -10,7 +10,7 @@ class Payment_Adapter_WebMoney implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -22,24 +22,21 @@ class Payment_Adapter_WebMoney implements \FOSSBilling\InjectionAwareInterface return $this->di; } - private $config = array(); - public $testMode = false; - const USD = 'Z'; - const RUB = 'R'; - const EUR = 'E'; - const UAH = 'U'; - const BYR = 'B'; + public const USD = 'Z'; + public const RUB = 'R'; + public const EUR = 'E'; + public const UAH = 'U'; + public const BYR = 'B'; - const REQUEST_TYPE_PREREQUEST = 'prerequest'; - const REQUEST_TYPE_NOTIFICATION = 'notification'; - const REQUEST_TYPE_CONFIRMATION = 'confirm'; + public const REQUEST_TYPE_PREREQUEST = 'prerequest'; + public const REQUEST_TYPE_NOTIFICATION = 'notification'; + public const REQUEST_TYPE_CONFIRMATION = 'confirm'; - public function __construct($config) + public function __construct(private $config) { - $this->config = $config; - $this->testMode = (isset($config['test_mode']) && $config['test_mode']) ? true : false; + $this->testMode = (isset($config['test_mode']) && $config['test_mode']) ? true : false; if(!$this->config['purse']) { throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'WebMoney', ':missing' => 'Purse']); @@ -330,7 +327,7 @@ class Payment_Adapter_WebMoney implements \FOSSBilling\InjectionAwareInterface ); $rows = $this->di['db']->getAll($sql, $bindings); - if (count($rows) > 1){ + if ((is_countable($rows) ? count($rows) : 0) > 1){ return true; } diff --git a/src/library/Payment/AdapterAbstract.php b/src/library/Payment/AdapterAbstract.php index 4a2407362..0ff7fd10a 100644 --- a/src/library/Payment/AdapterAbstract.php +++ b/src/library/Payment/AdapterAbstract.php @@ -10,16 +10,9 @@ abstract class Payment_AdapterAbstract { - const TYPE_HTML = 'html'; - const TYPE_FORM = 'form'; - const TYPE_API = 'api'; - - /** - * Adapter settings - * - * @var array - */ - protected $_config = array(); + public const TYPE_HTML = 'html'; + public const TYPE_FORM = 'form'; + public const TYPE_API = 'api'; /** * Response text for notify_url @@ -46,14 +39,12 @@ abstract class Payment_AdapterAbstract /** * Constructs a new Payment_Adapter object * - * @param array $config The configuration for the payment adapter as configured within the admin panel + * @param array $_config The configuration for the payment adapter as configured within the admin panel * * @throws Payment_Exception */ - public function __construct($config) + public function __construct(protected $_config) { - $this->_config = $config; - /** * Redirect client after successful payment, usually to invoice */ @@ -173,7 +164,7 @@ abstract class Payment_AdapterAbstract */ public function getParam($param) { - return isset($this->_config[$param]) ? $this->_config[$param] : NULL; + return $this->_config[$param] ?? NULL; } /** diff --git a/src/library/Payment/Invoice.php b/src/library/Payment/Invoice.php index 23148f61c..a4fd527cf 100644 --- a/src/library/Payment/Invoice.php +++ b/src/library/Payment/Invoice.php @@ -12,11 +12,11 @@ class Payment_Invoice { private $id = NULL; // FOSSBilling Invoice Id private $number = NULL; // Invoice number for accounting - private $currency = 'USD'; - private $items = array(); - private $subscription = NULL; - private $buyer = NULL; - private $title = 'Payment for invoice'; + private string $currency = 'USD'; + private array $items = array(); + private ?\Payment_Invoice_Subscription $subscription = NULL; + private ?\Payment_Invoice_Buyer $buyer = NULL; + private string $title = 'Payment for invoice'; /** * Set the invoice ID. @@ -25,7 +25,7 @@ class Payment_Invoice * * @return $this The current object, for method chaining. */ - public function setId($param) + public function setId(mixed $param) { $this->id = $param; return $this; @@ -48,7 +48,7 @@ class Payment_Invoice * * @return $this The current object, for method chaining. */ - public function setNumber($param) + public function setNumber(mixed $param) { $this->number = $param; return $this; diff --git a/src/library/Payment/Invoice/Item.php b/src/library/Payment/Invoice/Item.php index f8f399efb..028841c2f 100644 --- a/src/library/Payment/Invoice/Item.php +++ b/src/library/Payment/Invoice/Item.php @@ -13,7 +13,7 @@ class Payment_Invoice_Item private $id; private $title; private $description; - private $qty = 1; + private int $qty = 1; private $price; private $tax; diff --git a/src/library/Payment/Transaction.php b/src/library/Payment/Transaction.php index 6f586bec7..3d0a3dba6 100644 --- a/src/library/Payment/Transaction.php +++ b/src/library/Payment/Transaction.php @@ -10,19 +10,19 @@ class Payment_Transaction { - const STATUS_UNKNOWN = 'unknown'; - const STATUS_PENDING = 'pending'; - const STATUS_COMPLETE = 'complete'; + public const STATUS_UNKNOWN = 'unknown'; + public const STATUS_PENDING = 'pending'; + public const STATUS_COMPLETE = 'complete'; - const TXTYPE_PAYMENT = 'payment'; - const TXTYPE_REFUND = 'refund'; - const TXTYPE_SUBSCR_CREATE = 'subscription_create'; - const TXTYPE_SUBSCR_CANCEL = 'subscription_cancel'; - const TXTYPE_UNKNOWN = 'unknown'; + public const TXTYPE_PAYMENT = 'payment'; + public const TXTYPE_REFUND = 'refund'; + public const TXTYPE_SUBSCR_CREATE = 'subscription_create'; + public const TXTYPE_SUBSCR_CANCEL = 'subscription_cancel'; + public const TXTYPE_UNKNOWN = 'unknown'; private $id = NULL; - private $type = self::TXTYPE_UNKNOWN; - private $status = self::STATUS_UNKNOWN; + private string $type = self::TXTYPE_UNKNOWN; + private string $status = self::STATUS_UNKNOWN; private $currency = NULL; private $amount = NULL; private $subscription_id = NULL; @@ -34,7 +34,7 @@ class Payment_Transaction * * @return $this The current object, for method chaining. */ - public function setId($param) + public function setId(mixed $param) { $this->id = $param; return $this; diff --git a/src/library/PdoSessionHandler.php b/src/library/PdoSessionHandler.php index 105c28214..6a4a7083f 100644 --- a/src/library/PdoSessionHandler.php +++ b/src/library/PdoSessionHandler.php @@ -21,12 +21,12 @@ class PdoSessionHandler /** * @var \PDO PDO instance. */ - private $pdo; + private \PDO $pdo; /** * @var array Database options. */ - private $dbOptions; + private array $dbOptions; /** * Constructor. @@ -53,7 +53,7 @@ class PdoSessionHandler throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.'); } if (\PDO::ERRMODE_EXCEPTION !== $pdo->getAttribute(\PDO::ATTR_ERRMODE)) { - throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); + throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', self::class)); } $this->pdo = $pdo; diff --git a/src/library/Registrar/Adapter/Internetbs.php b/src/library/Registrar/Adapter/Internetbs.php index 840410498..b1d5baef0 100644 --- a/src/library/Registrar/Adapter/Internetbs.php +++ b/src/library/Registrar/Adapter/Internetbs.php @@ -219,7 +219,7 @@ class Registrar_Adapter_Internetbs extends Registrar_AdapterAbstract if ($domain->getTld() == '.fr' || $domain->getTld() == '.re') { - $tm = random_int(100000000, 999999999); + $tm = random_int(100_000_000, 999_999_999); $params['registrant_dotFRContactEntityType'] = 'OTHER'; $params['admin_dotFRContactEntityType'] = 'OTHER'; $params['registrant_dotFRContactEntityName'] = $c->getName(); @@ -361,7 +361,7 @@ class Registrar_Adapter_Internetbs extends Registrar_AdapterAbstract foreach ($lines as $line) { - list($varName, $value) = explode("=", $line); + [$varName, $value] = explode("=", $line); $result[strtolower(trim($varName))] = trim($value); } @@ -394,7 +394,6 @@ class Registrar_Adapter_Internetbs extends Registrar_AdapterAbstract /** * Creates domain object from received data array. - * @param Registrar_Domain $domain * @return Registrar_Domain */ private function _createDomainObj($result, Registrar_Domain $domain) @@ -462,7 +461,6 @@ class Registrar_Adapter_Internetbs extends Registrar_AdapterAbstract /** * Checks whether privacy is enabled. - * @param Registrar_Domain $domain * @return bool */ private function _isPrivacyEnabled(Registrar_Domain $domain) diff --git a/src/library/Registrar/Adapter/Namecheap.php b/src/library/Registrar/Adapter/Namecheap.php index 6cc19b760..9abb5f228 100644 --- a/src/library/Registrar/Adapter/Namecheap.php +++ b/src/library/Registrar/Adapter/Namecheap.php @@ -14,7 +14,7 @@ class Registrar_Adapter_Namecheap extends Registrar_AdapterAbstract public function isKeyValueNotEmpty($array, $key) { - $value = isset($array[$key]) ? $array[$key] : ''; + $value = $array[$key] ?? ''; if (strlen(trim($value)) == 0) { return false; } @@ -216,7 +216,6 @@ class Registrar_Adapter_Namecheap extends Registrar_AdapterAbstract } /** - * @param array $params * @return array */ public function includeAuthorizationParams(array $params) diff --git a/src/library/Registrar/Adapter/Resellerclub.php b/src/library/Registrar/Adapter/Resellerclub.php index d928012ca..d04c1c12c 100644 --- a/src/library/Registrar/Adapter/Resellerclub.php +++ b/src/library/Registrar/Adapter/Resellerclub.php @@ -24,7 +24,7 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract public function isKeyValueNotEmpty($array, $key) { - $value = isset ($array[$key]) ? $array[$key] : ''; + $value = $array[$key] ?? ''; if (strlen(trim($value)) == 0){ return false; } @@ -304,7 +304,7 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract $ns[] = $domain->getNs4(); } - list($reg_contact_id, $admin_contact_id, $tech_contact_id, $billing_contact_id) = $this->_getAllContacts($tld, $customer_id, $domain->getContactRegistrar()); + [$reg_contact_id, $admin_contact_id, $tech_contact_id, $billing_contact_id] = $this->_getAllContacts($tld, $customer_id, $domain->getContactRegistrar()); $params = array( 'domain-name' => $domain->getName(), @@ -428,7 +428,7 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract try { $result = $this->_makeRequest('customers/details', $params); - } catch(Registrar_Exception $e) { + } catch(Registrar_Exception) { $this->_createCustomer($domain); $result = $this->_makeRequest('customers/details', $params); } @@ -624,7 +624,7 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract 'options' => 'All', ); $data = $this->_makeRequest('domains/details', $params); - } catch(Exception $e) { + } catch(Exception) { return false; } @@ -649,7 +649,6 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract } /** - * @param array $params * @return array */ public function includeAuthorizationParams(array $params) @@ -850,7 +849,7 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract } - if ($tld == '.co' || substr($tld, -3) == '.co'){ + if ($tld == '.co' || str_ends_with($tld, '.co')){ $contact['type'] = 'CoContact'; } @@ -934,9 +933,9 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract } // by default special contact is also admin, tech and billing contact, but not always - $admin_contact_id = isset($special_contact_id) ? $special_contact_id : $reg_contact_id; - $tech_contact_id = isset($special_contact_id) ? $special_contact_id : $reg_contact_id; - $billing_contact_id = isset($special_contact_id) ? $special_contact_id : $reg_contact_id; + $admin_contact_id = $special_contact_id ?? $reg_contact_id; + $tech_contact_id = $special_contact_id ?? $reg_contact_id; + $billing_contact_id = $special_contact_id ?? $reg_contact_id; // override some parameters if(in_array($tld, array('.uk', '.co.uk', '.org.uk', '.nz', '.ru', '.com.ru', '.org.ru', '.net.ru', '.eu'))) { diff --git a/src/library/Registrar/Domain.php b/src/library/Registrar/Domain.php index d181a1a53..eef72e2f3 100644 --- a/src/library/Registrar/Domain.php +++ b/src/library/Registrar/Domain.php @@ -8,40 +8,28 @@ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0 */ -class Registrar_Domain +class Registrar_Domain implements \Stringable { private $_tld = null; private $_sld = null; private $_registered_at = null; private $_expires_at = null; - private $_period = null; + private ?int $_period = null; private $_epp = null; - private $_privacy = null; + private ?bool $_privacy = null; private $_locked = null; private $_ns1 = null; private $_ns2 = null; private $_ns3 = null; private $_ns4 = null; - /** - * @var Registrar_Domain_Contact - */ - private $_contact_registrar = null; + private ?\Registrar_Domain_Contact $_contact_registrar = null; - /** - * @var Registrar_Domain_Contact - */ - private $_contact_admin = null; + private ?\Registrar_Domain_Contact $_contact_admin = null; - /** - * @var Registrar_Domain_Contact - */ - private $_contact_tech = null; + private ?\Registrar_Domain_Contact $_contact_tech = null; - /** - * @var Registrar_Domain_Contact - */ - private $_contact_billing = null; + private ?\Registrar_Domain_Contact $_contact_billing = null; public function setRegistrationPeriod($years) { @@ -227,7 +215,7 @@ class Registrar_Domain return $this->_locked; } - public function __toString() { + public function __toString(): string { $c = ''; $c .= sprintf("Name: %s", $this->getName()).PHP_EOL; $c .= sprintf("TLD: %s", $this->getTld()).PHP_EOL; diff --git a/src/library/Registrar/Domain/Contact.php b/src/library/Registrar/Domain/Contact.php index 6975460fc..e6b3b249a 100644 --- a/src/library/Registrar/Domain/Contact.php +++ b/src/library/Registrar/Domain/Contact.php @@ -8,7 +8,7 @@ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0 */ -class Registrar_Domain_Contact +class Registrar_Domain_Contact implements \Stringable { private $id; private $name; @@ -24,7 +24,7 @@ class Registrar_Domain_Contact private $fax; private $fax_cc; private $company; - private $company_number = ''; + private string $company_number = ''; private $address_1; private $address_2; private $address_3; @@ -33,8 +33,8 @@ class Registrar_Domain_Contact private $document_type; private $document_nr; private $job_title; - private $birthday = ''; - private $idn_language_code = ''; + private string $birthday = ''; + private string $idn_language_code = ''; /** * @return string @@ -124,7 +124,7 @@ class Registrar_Domain_Contact $bits = explode(' ', $this->name); - return isset($bits[0]) ? $bits[0] : ''; + return $bits[0] ?? ''; } public function setLastName($param) @@ -350,7 +350,7 @@ class Registrar_Domain_Contact return implode(' ', $data); } - public function __toString() + public function __toString(): string { $c = ''; $c .= sprintf("Id: %s", $this->getId()).PHP_EOL; diff --git a/src/library/Registrar/Domain/Nameserver.php b/src/library/Registrar/Domain/Nameserver.php index a43e9073c..b4d93846e 100644 --- a/src/library/Registrar/Domain/Nameserver.php +++ b/src/library/Registrar/Domain/Nameserver.php @@ -8,7 +8,7 @@ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0 */ -class Registrar_Domain_Nameserver +class Registrar_Domain_Nameserver implements \Stringable { private $host = null; private $ip = null; @@ -35,7 +35,7 @@ class Registrar_Domain_Nameserver return $this->ip; } - public function __toString() { + public function __toString(): string { $c = ''; $c .= sprintf("Host: %s", $this->getHost()).PHP_EOL; $c .= sprintf("Ip: %s", $this->getIp()).PHP_EOL; diff --git a/src/library/Server/Account.php b/src/library/Server/Account.php index b78a5cf08..aa158f927 100644 --- a/src/library/Server/Account.php +++ b/src/library/Server/Account.php @@ -15,17 +15,11 @@ class Server_Account private $domain = NULL; private $ip = NULL; - /** - * @var Server_Package - */ - private $package = NULL; + private ?\Server_Package $package = NULL; - /** - * @var Server_Client - */ - private $client = NULL; - private $reseller = NULL; - private $suspended = NULL; + private ?\Server_Client $client = NULL; + private ?bool $reseller = NULL; + private ?bool $suspended = NULL; private $ns_1 = NULL; private $ns_2 = NULL; private $ns_3 = NULL; @@ -77,7 +71,6 @@ class Server_Account } /** - * @param Server_Client $param * @return $this */ public function setClient(Server_Client $param) @@ -95,7 +88,6 @@ class Server_Account } /** - * @param Server_Package $param * @return $this */ public function setPackage(Server_Package $param) diff --git a/src/library/Server/Client.php b/src/library/Server/Client.php index 559f19f18..3e787e852 100644 --- a/src/library/Server/Client.php +++ b/src/library/Server/Client.php @@ -12,14 +12,14 @@ class Server_Client { private $id = NULL; private $email = NULL; - private $full_name = 'FOSSBilling Client'; - private $company = 'FOSSBilling'; - private $www = 'www.fossbilling.org'; + private string $full_name = 'FOSSBilling Client'; + private string $company = 'FOSSBilling'; + private string $www = 'www.fossbilling.org'; private $address_1 = NULL; private $address_2 = NULL; private $street = NULL; - private $state = 'n/a'; - private $country = 'US'; + private string $state = 'n/a'; + private string $country = 'US'; private $city = NULL; private $zip = NULL; private $telephone = NULL; @@ -34,7 +34,7 @@ class Server_Client // Get only the stack frames we need (PHP 5.4 only). $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); } - error_log(sprintf("Calling %s inaccessible method %s from %s::%d", get_class($this), $name, $backtrace[1]['file'], $backtrace[1]['line'])); + error_log(sprintf("Calling %s inaccessible method %s from %s::%d", static::class, $name, $backtrace[1]['file'], $backtrace[1]['line'])); return ''; } diff --git a/src/library/Server/Manager.php b/src/library/Server/Manager.php index e373651b5..ec4c2171d 100644 --- a/src/library/Server/Manager.php +++ b/src/library/Server/Manager.php @@ -10,7 +10,7 @@ abstract class Server_Manager { - private $_log = null; + private ?\Box_Log $_log = null; protected $_config = array( 'ip' => NULL, @@ -92,7 +92,7 @@ abstract class Server_Manager * @param mixed $domain_name The domain name used to generate the username. * @return string The generated username. */ - public function generateUsername($domain_name) + public function generateUsername(mixed $domain_name) { $username = preg_replace('/[^A-Za-z0-9]/', '', $domain_name); $username = substr($username, 0, 7); diff --git a/src/library/Server/Manager/Directadmin.php b/src/library/Server/Manager/Directadmin.php index f273e37c9..33ccb465b 100644 --- a/src/library/Server/Manager/Directadmin.php +++ b/src/library/Server/Manager/Directadmin.php @@ -69,7 +69,7 @@ class Server_Manager_Directadmin extends Server_Manager $username = preg_replace('/[^A-Za-z0-9]/', '', $domain_name); // Username must start with a-z. - $username = is_numeric(substr($username, 0, 1)) ? substr_replace($username, chr(rand(97,122)), 0, 1) : $username; + $username = is_numeric(substr($username, 0, 1)) ? substr_replace($username, chr(random_int(97,122)), 0, 1) : $username; // Username must be at most 10 characters long, and sufficiently random to avoid collisons. $username = substr($username, 0, 7); @@ -192,11 +192,11 @@ class Server_Manager_Directadmin extends Server_Manager } } - if(strpos(implode('', $results), 'Unable to assign the Reseller ANY ips') !== false) { + if(str_contains(implode('', $results), 'Unable to assign the Reseller ANY ips')) { throw new Server_Exception('Unable to assign the Reseller ANY ips. Make sure to have free, un-assigned ips.'); } - if(strpos(implode('', $results), 'Error Creating User') !== false) { + if(str_contains(implode('', $results), 'Error Creating User')) { throw new Server_Exception('Error creating user'); } @@ -384,7 +384,7 @@ class Server_Manager_Directadmin extends Server_Manager private function getIps() { $results = $this->_request('CMD_API_SHOW_RESELLER_IPS'); - return isset($results['list']) ? $results['list'] : array(); + return $results['list'] ?? array(); } /** diff --git a/src/library/Server/Manager/Hestia.php b/src/library/Server/Manager/Hestia.php index 3798a83da..efa19e29c 100644 --- a/src/library/Server/Manager/Hestia.php +++ b/src/library/Server/Manager/Hestia.php @@ -100,7 +100,7 @@ class Server_Manager_Hestia extends Server_Manager ]); $result = $response->getContent(); - if (false !== strpos($result, 'Error')) { + if (str_contains($result, 'Error')) { throw new Server_Exception('Failed to connect to the :type: server. Please verify your credentials and configuration', [':type:' => 'HestiaCP']); } elseif (0 !== intval($result)) { error_log("HestiaCP returned error code $result for the " . $params['cmd'] . "command"); diff --git a/src/library/Server/Manager/Ispconfig3.php b/src/library/Server/Manager/Ispconfig3.php index 4745af556..094e7bec4 100644 --- a/src/library/Server/Manager/Ispconfig3.php +++ b/src/library/Server/Manager/Ispconfig3.php @@ -11,7 +11,7 @@ class Server_Manager_Ispconfig3 extends Server_Manager { private $_session = null; - private $_c = null; + private ?\SoapClient $_c = null; public function init() { @@ -83,7 +83,7 @@ class Server_Manager_Ispconfig3 extends Server_Manager $this->createSite($a); $this->dnsCreateZone($a); } catch (Exception $e) { - if (strpos(strtolower($e->getMessage()), strtolower('domain_error_unique')) === false) { + if (!str_contains(strtolower($e->getMessage()), strtolower('domain_error_unique'))) { throw new Server_Exception($e->getMessage()); } else { return true; @@ -116,6 +116,7 @@ class Server_Manager_Ispconfig3 extends Server_Manager public function cancelAccount(Server_Account $a) { + $pa = []; $ci = $this->getClient($a); $params = array( @@ -202,6 +203,7 @@ class Server_Manager_Ispconfig3 extends Server_Manager private function createSite(Server_Account &$a) { + $site_params = []; if($this->isSiteCreated($a)) { return true; } @@ -243,6 +245,10 @@ class Server_Manager_Ispconfig3 extends Server_Manager private function dnsCreateZone(Server_Account &$a) { + $dns_domain_params = []; + $pa = []; + $dns_a_params = []; + $mail_domain_params = []; $client = $a->getClient(); @@ -443,7 +449,8 @@ class Server_Manager_Ispconfig3 extends Server_Manager private function getClient(Server_Account $a) { - $params['username'] = $a->getUsername(); + $params = []; + $params['username'] = $a->getUsername(); $result = $this->_request('client_get_by_username',$params); return $result; } @@ -464,6 +471,7 @@ class Server_Manager_Ispconfig3 extends Server_Manager private function getClientSites(Server_Account $a) { + $site_params = []; $user_info = $this->getClient($a); $site_params['sys_userid'] = $user_info['userid']; $site_params['groups'] = $user_info['groups']; @@ -488,6 +496,8 @@ class Server_Manager_Ispconfig3 extends Server_Manager private function getSiteInfo(Server_Account $a) { + $server_params = []; + $section = null; $server_params['server_id'] = $this->getServerId(); $server_params['section'] = $section; return $this->_request('server_get',$server_params); @@ -495,6 +505,7 @@ class Server_Manager_Ispconfig3 extends Server_Manager private function getServerInfo($section = 'web') { + $server_params = []; $server_params['server_id'] = $this->getServerId(); $server_params['section'] = $section; return $this->_request('server_get',$server_params); diff --git a/src/library/Server/Manager/Plesk.php b/src/library/Server/Manager/Plesk.php index 35bce04e2..62a87885c 100644 --- a/src/library/Server/Manager/Plesk.php +++ b/src/library/Server/Manager/Plesk.php @@ -12,7 +12,7 @@ use PleskX\Api\Client; class Server_Manager_Plesk extends Server_Manager { - private $_client; + private ?\PleskX\Api\Client $_client = null; public function init() { $this->_config['port'] = empty($this->_config['port']) ? 8443 : $this->_config['port']; @@ -73,7 +73,7 @@ class Server_Manager_Plesk extends Server_Manager // throw new Server_Exception('Out of free IP adresses'); } */ - if (count($ips['exclusive']) > 0) { + if ((is_countable($ips['exclusive']) ? count($ips['exclusive']) : 0) > 0) { $ips['exclusive'] = array_values($ips['exclusive']); $rand = array_rand($ips['exclusive']); $a->setIp($ips['exclusive'][$rand]['ip']); @@ -165,7 +165,8 @@ class Server_Manager_Plesk extends Server_Manager public function changeAccountPackage(Server_Account $a, Server_Package $p) { - $id = $this->_modifyClient($a); + $domainId = null; + $id = $this->_modifyClient($a); $client = $a->getClient(); if (!$id) { throw new Server_Exception('Can\'t modify client'); @@ -372,19 +373,19 @@ class Server_Manager_Plesk extends Server_Manager 'limit' => array( array( 'name' => 'max_db', - 'value' => $p->getMaxSql() ? $p->getMaxSql() : 0, + 'value' => $p->getMaxSql() ?: 0, ), array( 'name' => 'max_maillists', - 'value' => $p->getMaxEmailLists() ? $p->getMaxEmailLists() : 0, + 'value' => $p->getMaxEmailLists() ?: 0, ), array( 'name' => 'max_maillists', - 'value' => $p->getMaxEmailLists() ? $p->getMaxEmailLists() : 0, + 'value' => $p->getMaxEmailLists() ?: 0, ), array( 'name' => 'max_box', - 'value' => $p->getMaxPop() ? $p->getMaxPop() : 0, + 'value' => $p->getMaxPop() ?: 0, ), array( 'name' => 'max_traffic', @@ -396,11 +397,11 @@ class Server_Manager_Plesk extends Server_Manager ), array( 'name' => 'max_subdom', - 'value' => $p->getMaxSubdomains() ? $p->getMaxSubdomains() : 0, + 'value' => $p->getMaxSubdomains() ?: 0, ), array( 'name' => 'max_subftp_users', - 'value' => $p->getMaxFtp() ? $p->getMaxFtp() : 0, + 'value' => $p->getMaxFtp() ?: 0, ), ), ), @@ -468,7 +469,6 @@ class Server_Manager_Plesk extends Server_Manager /** * Creates a new client account - * @param Server_Account $a * @throws Server_Exception * @return integer client's Plesk id */ diff --git a/src/library/Server/Manager/Virtualmin.php b/src/library/Server/Manager/Virtualmin.php index 4e6767981..442c545b0 100644 --- a/src/library/Server/Manager/Virtualmin.php +++ b/src/library/Server/Manager/Virtualmin.php @@ -71,7 +71,7 @@ class Server_Manager_Virtualmin extends Server_Manager } } } catch (Exception $e) { - if (strpos(strtolower($e->getMessage()), strtolower('You are already hosting this domain')) === false) { + if (!str_contains(strtolower($e->getMessage()), strtolower('You are already hosting this domain'))) { throw new Server_Exception($e->getMessage()); } else { return true; @@ -230,7 +230,7 @@ class Server_Manager_Virtualmin extends Server_Manager $html = new DOMDocument(); try { $html->loadHTML($result); - } catch (Exception $e) { + } catch (Exception) { return $result; } @@ -258,7 +258,6 @@ class Server_Manager_Virtualmin extends Server_Manager /** * * Creates reseller - * @param Server_Account $a * @throws Server_Exception * @return boolean */ @@ -331,7 +330,7 @@ class Server_Manager_Virtualmin extends Server_Manager private function _checkCommand($command) { $commands = $this->_getCommands(); - if (strpos($commands, $command) === false) { + if (!str_contains($commands, $command)) { return false; } else { return true; @@ -341,7 +340,6 @@ class Server_Manager_Virtualmin extends Server_Manager /** * * Creates user's account - * @param Server_Account $a * @throws Server_Exception * @returns boolean */ @@ -395,12 +393,11 @@ class Server_Manager_Virtualmin extends Server_Manager } /** - * - * Suspends user's account - * @param Server_Account $a - * @throws Server_Exception - * @return boolean - */ + * + * Suspends user's account + * @throws Server_Exception + * @return boolean + */ private function _suspendUser(Server_Account $a) { $params = array( @@ -420,7 +417,6 @@ class Server_Manager_Virtualmin extends Server_Manager /** * * Unsuspends user's account - * @param Server_Account $a * @throws Server_Exception * @return booblean */ @@ -443,7 +439,6 @@ class Server_Manager_Virtualmin extends Server_Manager /** * * Changes user's password - * @param Server_Account $a * @throws Server_Exception * @return boolean */ @@ -467,7 +462,6 @@ class Server_Manager_Virtualmin extends Server_Manager /** * * Cancels user's account - * @param Server_Account $a * @throws Server_Exception * @return boolean */ @@ -490,7 +484,6 @@ class Server_Manager_Virtualmin extends Server_Manager /** * * Modifies domain - * @param Server_Account $a * @throws Server_Exception * @return boolean */ @@ -520,7 +513,6 @@ class Server_Manager_Virtualmin extends Server_Manager /** * * Enables features for user - * @param Server_Account $a * @throws Server_Exception * @return boolean */ @@ -548,7 +540,6 @@ class Server_Manager_Virtualmin extends Server_Manager /** * * Disable not needed features for user - * @param Server_Account $a * @throws Server_Exception * @return boolean */ diff --git a/src/library/Server/Manager/Whm.php b/src/library/Server/Manager/Whm.php index 6d8571c05..e0940a540 100644 --- a/src/library/Server/Manager/Whm.php +++ b/src/library/Server/Manager/Whm.php @@ -267,11 +267,11 @@ class Server_Manager_Whm extends Server_Manager /** * Check if Package exists - * @param Server_Package $package * @return bool */ private function _checkPackageExists(Server_Package $package, $create = false) { + $var_hash = []; $name = $this->_getPackageName($package); $json = $this->_request('listpkgs'); diff --git a/src/library/Server/Package.php b/src/library/Server/Package.php index 75793d134..6f89530a8 100644 --- a/src/library/Server/Package.php +++ b/src/library/Server/Package.php @@ -10,7 +10,7 @@ class Server_Package { - private $name = 'FOSSBilling'; + private ?string $name = 'FOSSBilling'; private $quota = NULL; private $bandwidth = NULL; @@ -21,7 +21,7 @@ class Server_Package private $maxsql = NULL; private $maxpop = NULL; - private $custom = array(); + private array $custom = array(); public function __call($name, $arguments) { @@ -32,7 +32,7 @@ class Server_Package // Get only the stack frames we need (PHP 5.4 only). $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); } - error_log(sprintf("Calling %s inaccessible method %s from %s::%d", get_class($this), $name, $backtrace[1]['file'], $backtrace[1]['line'])); + error_log(sprintf("Calling %s inaccessible method %s from %s::%d", static::class, $name, $backtrace[1]['file'], $backtrace[1]['line'])); return ''; } @@ -53,7 +53,7 @@ class Server_Package */ public function getCustomValue($param) { - return isset($this->custom[$param]) ? $this->custom[$param] : NULL; + return $this->custom[$param] ?? NULL; } public function setName($param) diff --git a/src/modules/Activity/Controller/Admin.php b/src/modules/Activity/Controller/Admin.php index 472046cc0..b40359cd0 100644 --- a/src/modules/Activity/Controller/Admin.php +++ b/src/modules/Activity/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Activity\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Activity/Service.php b/src/modules/Activity/Service.php index 4f90447ae..ddb9067a6 100644 --- a/src/modules/Activity/Service.php +++ b/src/modules/Activity/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Api/Controller/Client.php b/src/modules/Api/Controller/Client.php index 1dabc38d4..44e1bc4df 100644 --- a/src/modules/Api/Controller/Client.php +++ b/src/modules/Api/Controller/Client.php @@ -18,9 +18,9 @@ use FOSSBilling\InjectionAwareInterface; class Client implements InjectionAwareInterface { - private $_requests_left; + private int|float|null $_requests_left = null; private $_api_config; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -271,7 +271,7 @@ class Client implements InjectionAwareInterface header('X-RateLimit-Remaining: ' . $this->_requests_left); if ($e !== null) { error_log($e->getMessage() . ' ' . $e->getCode()); - $code = $e->getCode() ? $e->getCode() : 9999; + $code = $e->getCode() ?: 9999; $result = ['result' => null, 'error' => ['message' => $e->getMessage(), 'code' => $code]]; $authFailed = [201, 202, 206, 204, 205, 203, 403, 1004, 1002]; diff --git a/src/modules/Api/Service.php b/src/modules/Api/Service.php index 9bdfa0a0a..47d01dcb1 100644 --- a/src/modules/Api/Service.php +++ b/src/modules/Api/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Api; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Branding/Service.php b/src/modules/Branding/Service.php index db6c5a697..d7f1d35b2 100644 --- a/src/modules/Branding/Service.php +++ b/src/modules/Branding/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Branding; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Cart/Api/Admin.php b/src/modules/Cart/Api/Admin.php index ad3b4a8f7..24a1ae42e 100644 --- a/src/modules/Cart/Api/Admin.php +++ b/src/modules/Cart/Api/Admin.php @@ -71,7 +71,7 @@ class Admin extends \Api_Abstract $this->di['db']->exec('DELETE FROM `cart_product` WHERE cart_id = :id', [':id' => $id]); $this->di['db']->exec('DELETE FROM `cart` WHERE id = :id', [':id' => $id]); } - $this->di['logger']->info('Removed %s expired shopping carts', count($list)); + $this->di['logger']->info('Removed %s expired shopping carts', is_countable($list) ? count($list) : 0); } return true; diff --git a/src/modules/Cart/Controller/Client.php b/src/modules/Cart/Controller/Client.php index 6d845d56d..86cb82ea8 100644 --- a/src/modules/Cart/Controller/Client.php +++ b/src/modules/Cart/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Cart\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Cart/Service.php b/src/modules/Cart/Service.php index 747842ae1..b1dd64361 100644 --- a/src/modules/Cart/Service.php +++ b/src/modules/Cart/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -292,7 +292,7 @@ class Service implements InjectionAwareInterface { $cartProducts = $this->di['db']->find('CartProduct', 'cart_id = :cart_id', [':cart_id' => $cart->id]); - return count($cartProducts) == 0; + return (is_countable($cartProducts) ? count($cartProducts) : 0) == 0; } public function rm(\Model_Cart $cart) @@ -481,7 +481,7 @@ class Service implements InjectionAwareInterface { $cart = $this->getSessionCart(); $ca = $this->toApiArray($cart); - if (count($ca['items']) == 0) { + if ((is_countable($ca['items']) ? count($ca['items']) : 0) == 0) { throw new \Box_Exception('Can not checkout an empty cart'); } diff --git a/src/modules/Client/Controller/Admin.php b/src/modules/Client/Controller/Admin.php index 486b4cd58..dea8b5bda 100644 --- a/src/modules/Client/Controller/Admin.php +++ b/src/modules/Client/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Client\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Client/Controller/Client.php b/src/modules/Client/Controller/Client.php index 667364fcc..950b706dd 100644 --- a/src/modules/Client/Controller/Client.php +++ b/src/modules/Client/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Client\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Client/Service.php b/src/modules/Client/Service.php index 9834c6d53..724205d89 100644 --- a/src/modules/Client/Service.php +++ b/src/modules/Client/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Client/ServiceBalance.php b/src/modules/Client/ServiceBalance.php index 5bbc6255e..d7553981c 100644 --- a/src/modules/Client/ServiceBalance.php +++ b/src/modules/Client/ServiceBalance.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class ServiceBalance implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -114,7 +114,6 @@ class ServiceBalance implements InjectionAwareInterface /** * @param float $amount * @param string $description - * @param array $data * * @return \Model_ClientBalance * diff --git a/src/modules/Cookieconsent/Controller/Admin.php b/src/modules/Cookieconsent/Controller/Admin.php index ddf62acfa..0a2b0a2cd 100644 --- a/src/modules/Cookieconsent/Controller/Admin.php +++ b/src/modules/Cookieconsent/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Cookieconsent\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Cookieconsent/Service.php b/src/modules/Cookieconsent/Service.php index 162e5acca..a4ae56319 100644 --- a/src/modules/Cookieconsent/Service.php +++ b/src/modules/Cookieconsent/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Cron/Service.php b/src/modules/Cron/Service.php index 09b6c0e51..14feef0b5 100644 --- a/src/modules/Cron/Service.php +++ b/src/modules/Cron/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Cron; class Service { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Currency/Controller/Admin.php b/src/modules/Currency/Controller/Admin.php index 7b6f49190..14b51c947 100644 --- a/src/modules/Currency/Controller/Admin.php +++ b/src/modules/Currency/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Currency\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Currency/Service.php b/src/modules/Currency/Service.php index 81ba833fe..9ba58afc9 100644 --- a/src/modules/Currency/Service.php +++ b/src/modules/Currency/Service.php @@ -15,7 +15,7 @@ use Symfony\Component\HttpClient\HttpClient; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Custompages/Controller/Admin.php b/src/modules/Custompages/Controller/Admin.php index c37638f56..1531d3509 100644 --- a/src/modules/Custompages/Controller/Admin.php +++ b/src/modules/Custompages/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Custompages\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Custompages/Controller/Client.php b/src/modules/Custompages/Controller/Client.php index 0f8f03ae2..58799ccb2 100644 --- a/src/modules/Custompages/Controller/Client.php +++ b/src/modules/Custompages/Controller/Client.php @@ -17,7 +17,7 @@ namespace Box\Mod\Custompages\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Custompages/Service.php b/src/modules/Custompages/Service.php index a3d2f2412..cece39269 100644 --- a/src/modules/Custompages/Service.php +++ b/src/modules/Custompages/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Custompages; class Service { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Dashboard/Controller/Client.php b/src/modules/Dashboard/Controller/Client.php index e7c46b53f..0cb661172 100644 --- a/src/modules/Dashboard/Controller/Client.php +++ b/src/modules/Dashboard/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Dashboard\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Email/Controller/Admin.php b/src/modules/Email/Controller/Admin.php index 2fe6e393f..468a959c4 100644 --- a/src/modules/Email/Controller/Admin.php +++ b/src/modules/Email/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Email\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Email/Controller/Client.php b/src/modules/Email/Controller/Client.php index 110a10a08..2d02f2389 100644 --- a/src/modules/Email/Controller/Client.php +++ b/src/modules/Email/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Email\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Email/Service.php b/src/modules/Email/Service.php index f866e2d04..7b75a2bb9 100644 --- a/src/modules/Email/Service.php +++ b/src/modules/Email/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Email; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -619,7 +619,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface ++$queue->tries; $queue->updated_at = date('Y-m-d H:i:s'); $this->di['db']->store($queue); - $maxTries = (isset($settings['cancel_after'])) ? $settings['cancel_after'] : 5; + $maxTries = $settings['cancel_after'] ?? 5; if ($queue->tries > $maxTries) { $this->di['db']->trash($queue); } diff --git a/src/modules/Embed/Controller/Admin.php b/src/modules/Embed/Controller/Admin.php index 2c9a93cdd..b79879c3e 100644 --- a/src/modules/Embed/Controller/Admin.php +++ b/src/modules/Embed/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Embed\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Embed/Controller/Client.php b/src/modules/Embed/Controller/Client.php index 55690049e..80fb3a237 100644 --- a/src/modules/Embed/Controller/Client.php +++ b/src/modules/Embed/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Embed\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Extension/Controller/Admin.php b/src/modules/Extension/Controller/Admin.php index 011a4f69a..83a85910e 100644 --- a/src/modules/Extension/Controller/Admin.php +++ b/src/modules/Extension/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Extension\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Extension/Service.php b/src/modules/Extension/Service.php index 3c28b5dc5..eaaf3b248 100644 --- a/src/modules/Extension/Service.php +++ b/src/modules/Extension/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Formbuilder/Controller/Client.php b/src/modules/Formbuilder/Controller/Client.php index bedb683ed..b6ce89b2c 100644 --- a/src/modules/Formbuilder/Controller/Client.php +++ b/src/modules/Formbuilder/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Formbuilder\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Formbuilder/Service.php b/src/modules/Formbuilder/Service.php index b371b6938..9df4628c0 100644 --- a/src/modules/Formbuilder/Service.php +++ b/src/modules/Formbuilder/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -46,7 +46,7 @@ class Service implements InjectionAwareInterface { $unique = array_unique($data); - return count($data) === count($unique); + return (is_countable($data) ? count($data) : 0) === count($unique); } public function addNewForm($data) @@ -133,7 +133,7 @@ class Service implements InjectionAwareInterface $text = strtolower($text); // remove unwanted characters - $text = preg_replace('~[^-\w]+~', '', $text); + $text = preg_replace('~[^\-\w]+~', '', $text); if (is_numeric(substr($text, 0, 1))) { throw new \Box_Exception('Field name can not start with number.', null, 1649); @@ -178,7 +178,7 @@ class Service implements InjectionAwareInterface $field['options'] = json_encode($field['options'], JSON_FORCE_OBJECT); } if ($field['type'] == 'textarea') { - if (count($field['textarea_size']) != count(array_filter($field['textarea_size'], 'is_numeric'))) { + if ((is_countable($field['textarea_size']) ? count($field['textarea_size']) : 0) != count((array) array_filter($field['textarea_size'], 'is_numeric'))) { throw new \Box_Exception('Textarea size options must be integer values', null, 3510); } $field['options'] = array_combine($field['textarea_option'], $field['textarea_size']); diff --git a/src/modules/Hook/Service.php b/src/modules/Hook/Service.php index d2af09db1..0069e2320 100644 --- a/src/modules/Hook/Service.php +++ b/src/modules/Hook/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Index/Controller/Admin.php b/src/modules/Index/Controller/Admin.php index 6369cb2f9..9cdb9f62d 100644 --- a/src/modules/Index/Controller/Admin.php +++ b/src/modules/Index/Controller/Admin.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Admin implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Invoice/Controller/Admin.php b/src/modules/Invoice/Controller/Admin.php index cc3e60718..1e5e2ac4f 100644 --- a/src/modules/Invoice/Controller/Admin.php +++ b/src/modules/Invoice/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Invoice\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Invoice/Controller/Client.php b/src/modules/Invoice/Controller/Client.php index c86091376..3c4f4ce54 100644 --- a/src/modules/Invoice/Controller/Client.php +++ b/src/modules/Invoice/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Invoice\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Invoice/Service.php b/src/modules/Invoice/Service.php index 0817df0e8..4087db6ad 100644 --- a/src/modules/Invoice/Service.php +++ b/src/modules/Invoice/Service.php @@ -16,7 +16,7 @@ use Twig\Loader\FilesystemLoader; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -954,7 +954,7 @@ class Service implements InjectionAwareInterface $orderService = $this->di['mod_service']('Order'); $orders = $orderService->getSoonExpiringActiveOrders(); - if (count($orders) == 0) { + if ((is_countable($orders) ? count($orders) : 0) == 0) { return true; } @@ -1332,7 +1332,7 @@ class Service implements InjectionAwareInterface ->setTax($item['tax']) ->setQuantity($item['quantity']); $items[] = $pi; - if (is_null($first_title) && count($proforma['lines']) == 1) { + if (is_null($first_title) && (is_countable($proforma['lines']) ? count($proforma['lines']) : 0) == 1) { $first_title = $item['title']; } } diff --git a/src/modules/Invoice/ServiceInvoiceItem.php b/src/modules/Invoice/ServiceInvoiceItem.php index 4243c749c..5316e4d1e 100644 --- a/src/modules/Invoice/ServiceInvoiceItem.php +++ b/src/modules/Invoice/ServiceInvoiceItem.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class ServiceInvoiceItem implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Invoice/ServicePayGateway.php b/src/modules/Invoice/ServicePayGateway.php index 6ab2b2089..32d833122 100644 --- a/src/modules/Invoice/ServicePayGateway.php +++ b/src/modules/Invoice/ServicePayGateway.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class ServicePayGateway implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -332,7 +332,7 @@ class ServicePayGateway implements InjectionAwareInterface { $config = $this->getAdapterConfig($model); - return (isset($config['description'])) ? $config['description'] : null; + return $config['description'] ?? null; } /** diff --git a/src/modules/Invoice/ServiceSubscription.php b/src/modules/Invoice/ServiceSubscription.php index b4c23489e..36ba8fd3f 100644 --- a/src/modules/Invoice/ServiceSubscription.php +++ b/src/modules/Invoice/ServiceSubscription.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class ServiceSubscription implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Invoice/ServiceTax.php b/src/modules/Invoice/ServiceTax.php index 4c3ef3f08..fc03f22b6 100644 --- a/src/modules/Invoice/ServiceTax.php +++ b/src/modules/Invoice/ServiceTax.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class ServiceTax implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Invoice/ServiceTransaction.php b/src/modules/Invoice/ServiceTransaction.php index 41f50cfef..c1790ecd8 100644 --- a/src/modules/Invoice/ServiceTransaction.php +++ b/src/modules/Invoice/ServiceTransaction.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class ServiceTransaction implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -102,7 +102,7 @@ class ServiceTransaction implements InjectionAwareInterface $transaction->status = 'received'; $transaction->ip = $this->di['request']->getClientAddress(); $transaction->ipn = json_encode($ipn); - $transaction->note = (isset($data['note'])) ? $data['note'] : null; + $transaction->note = $data['note'] ?? null; $transaction->created_at = date('Y-m-d H:i:s'); $transaction->updated_at = date('Y-m-d H:i:s'); $newId = $this->di['db']->store($transaction); diff --git a/src/modules/Kb/Controller/Admin.php b/src/modules/Kb/Controller/Admin.php index 40315366c..d577711af 100644 --- a/src/modules/Kb/Controller/Admin.php +++ b/src/modules/Kb/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Kb\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Kb/Controller/Client.php b/src/modules/Kb/Controller/Client.php index 260dbe4f9..ade394238 100644 --- a/src/modules/Kb/Controller/Client.php +++ b/src/modules/Kb/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Kb\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Kb/Service.php b/src/modules/Kb/Service.php index f8a5723fb..4e4ec3816 100644 --- a/src/modules/Kb/Service.php +++ b/src/modules/Kb/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Kb; class Service { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Massmailer/Controller/Admin.php b/src/modules/Massmailer/Controller/Admin.php index 3c2c1c3d1..63c28d0e6 100644 --- a/src/modules/Massmailer/Controller/Admin.php +++ b/src/modules/Massmailer/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Massmailer\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Massmailer/Service.php b/src/modules/Massmailer/Service.php index 12595e63a..879c0131a 100644 --- a/src/modules/Massmailer/Service.php +++ b/src/modules/Massmailer/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Massmailer; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/News/Controller/Admin.php b/src/modules/News/Controller/Admin.php index 0581bfe1a..66562aa18 100644 --- a/src/modules/News/Controller/Admin.php +++ b/src/modules/News/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\News\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/News/Controller/Client.php b/src/modules/News/Controller/Client.php index e2dd2058a..5baba2dcb 100644 --- a/src/modules/News/Controller/Client.php +++ b/src/modules/News/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\News\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/News/Service.php b/src/modules/News/Service.php index ceb8699cc..9c18ee9e2 100644 --- a/src/modules/News/Service.php +++ b/src/modules/News/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\News; class Service { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Notification/Controller/Admin.php b/src/modules/Notification/Controller/Admin.php index 986a442dd..b0fc4d4f6 100644 --- a/src/modules/Notification/Controller/Admin.php +++ b/src/modules/Notification/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Notification\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Notification/Service.php b/src/modules/Notification/Service.php index a60e63fb1..bc5a3c0b8 100644 --- a/src/modules/Notification/Service.php +++ b/src/modules/Notification/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Order/Controller/Admin.php b/src/modules/Order/Controller/Admin.php index 307d78ab2..492641b74 100644 --- a/src/modules/Order/Controller/Admin.php +++ b/src/modules/Order/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Order\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Order/Controller/Client.php b/src/modules/Order/Controller/Client.php index b40fe9905..599c96036 100644 --- a/src/modules/Order/Controller/Client.php +++ b/src/modules/Order/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Order\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Order/Service.php b/src/modules/Order/Service.php index 847dba991..4272f59ed 100644 --- a/src/modules/Order/Service.php +++ b/src/modules/Order/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -571,7 +571,7 @@ class Service implements InjectionAwareInterface if (isset($data['price'])) { $order->price = $data['price']; } else { - $repo = $product->getTable($product->type); + $repo = $product->getTable(); $rate = $currencyService->getRateByCode($currency->code); $order->price = $repo->getProductPrice($product, $config) * $rate; } diff --git a/src/modules/Orderbutton/Controller/Client.php b/src/modules/Orderbutton/Controller/Client.php index b7f7155b0..36c1a8d09 100644 --- a/src/modules/Orderbutton/Controller/Client.php +++ b/src/modules/Orderbutton/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Orderbutton\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Page/Service.php b/src/modules/Page/Service.php index c2cef3011..a4641f446 100644 --- a/src/modules/Page/Service.php +++ b/src/modules/Page/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Paidsupport/Service.php b/src/modules/Paidsupport/Service.php index 53b989429..d6dd0cbd7 100644 --- a/src/modules/Paidsupport/Service.php +++ b/src/modules/Paidsupport/Service.php @@ -21,7 +21,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Product/Api/Guest.php b/src/modules/Product/Api/Guest.php index 50f0e798e..fb659879a 100644 --- a/src/modules/Product/Api/Guest.php +++ b/src/modules/Product/Api/Guest.php @@ -129,7 +129,7 @@ class Guest extends \Api_Abstract $type = $data['type'] ?? 'hosting'; $products = $this->di['db']->find('Product', 'type = :type', [':type' => $type]); - if (count($products) <= 0) { + if ((is_countable($products) ? count($products) : 0) <= 0) { return []; } diff --git a/src/modules/Product/Controller/Admin.php b/src/modules/Product/Controller/Admin.php index ac03a7b08..8d1afb04f 100644 --- a/src/modules/Product/Controller/Admin.php +++ b/src/modules/Product/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Product\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Product/Service.php b/src/modules/Product/Service.php index 31859c6f3..03650f834 100644 --- a/src/modules/Product/Service.php +++ b/src/modules/Product/Service.php @@ -27,7 +27,7 @@ class Service implements InjectionAwareInterface public const SETUP_AFTER_PAYMENT = 'after_payment'; public const SETUP_MANUAL = 'manual'; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -384,11 +384,11 @@ class Service implements InjectionAwareInterface $model = $this->di['db']->dispense('Product'); $model->product_payment_id = $paymentId; $model->product_category_id = null; - $model->status = (isset($status)) ? $status : \Model_Product::STATUS_DISABLED; + $model->status = $status ?? \Model_Product::STATUS_DISABLED; $model->title = $title; $model->slug = $this->di['tools']->slug($title); $model->type = self::CUSTOM; - $model->setup = (isset($setup)) ? $setup : self::SETUP_AFTER_PAYMENT; + $model->setup = $setup ?? self::SETUP_AFTER_PAYMENT; $model->is_addon = 1; $model->icon_url = $iconUrl; @@ -642,7 +642,7 @@ class Service implements InjectionAwareInterface return []; } - $slots = (count($ids)) ? implode(',', array_fill(0, count($ids), '?')) : ''; // same as RedBean genSlots() method + $slots = (is_countable($ids) ? count($ids) : 0) ? implode(',', array_fill(0, is_countable($ids) ? count($ids) : 0, '?')) : ''; // same as RedBean genSlots() method $rows = $this->di['db']->getAll('SELECT id, title FROM product WHERE id in (' . $slots . ')', $ids); @@ -795,7 +795,7 @@ class Service implements InjectionAwareInterface return []; } - $slots = (count($ids)) ? implode(',', array_fill(0, count($ids), '?')) : ''; // same as RedBean genSlots() method + $slots = (is_countable($ids) ? count($ids) : 0) ? implode(',', array_fill(0, is_countable($ids) ? count($ids) : 0, '?')) : ''; // same as RedBean genSlots() method array_unshift($ids, (int) $model->id); // adding product ID as first param in array return $this->di['db']->find('Product', 'type = "custom" and is_addon= 1 and id != ? and id IN (' . $slots . ')', $ids); diff --git a/src/modules/Profile/Service.php b/src/modules/Profile/Service.php index 7a3c1aa12..869effcf2 100644 --- a/src/modules/Profile/Service.php +++ b/src/modules/Profile/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Queue/Service.php b/src/modules/Queue/Service.php index aa3bb3b3f..884a49856 100644 --- a/src/modules/Queue/Service.php +++ b/src/modules/Queue/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Queue; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -124,7 +124,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $sql = 'SELECT COUNT(id) FROM queue_message WHERE queue_id = :id GROUP BY queue_id'; $count = $this->di['db']->getCell($sql, ['id' => $row['id']]); - $row['messages_count'] = ($count) ? $count : 0; + $row['messages_count'] = $count ?: 0; return $row; } diff --git a/src/modules/Redirect/Controller/Client.php b/src/modules/Redirect/Controller/Client.php index 882fff645..f188f0c97 100644 --- a/src/modules/Redirect/Controller/Client.php +++ b/src/modules/Redirect/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Redirect\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -26,17 +26,17 @@ class Client implements \FOSSBilling\InjectionAwareInterface public function register(\Box_App &$app) { - $app->get('/me', 'get_profile', [], '\Box\Mod\Client\Controller\Client'); - $app->get('/balance', 'get_balance', [], '\Box\Mod\Client\Controller\Client'); - $app->get('/reset-password-confirm/:hash', 'get_reset_password_confirm', ['hash' => '[a-z0-9]+'], '\Box\Mod\Client\Controller\Client'); - $app->get('/emails', 'get_emails', [], '\Box\Mod\Email\Controller\Client'); - $app->get('/banklink/:hash/:id', 'get_banklink', ['id' => '[0-9]+', 'hash' => '[a-z0-9]+'], '\Box\Mod\Invoice\Controller\Client'); - $app->get('/blog', 'get_news', [], '\Box\Mod\News\Controller\Client'); - $app->get('/blog/:slug', 'get_news_item', ['slug' => '[a-z0-9-]+'], '\Box\Mod\News\Controller\Client'); - $app->get('/service', 'get_orders', [], '\Box\Mod\Order\Controller\Client'); - $app->get('/service/manage/:id', 'get_order', ['id' => '[0-9]+'], '\Box\Mod\Order\Controller\Client'); - $app->get('/contact-us', 'get_contact_us', [], '\Box\Mod\Support\Controller\Client'); - $app->get('/contact-us/conversation/:hash', 'get_contact_us_conversation', ['hash' => '[a-z0-9]+'], '\Box\Mod\Support\Controller\Client'); + $app->get('/me', 'get_profile', [], '\\' . \Box\Mod\Client\Controller\Client::class); + $app->get('/balance', 'get_balance', [], '\\' . \Box\Mod\Client\Controller\Client::class); + $app->get('/reset-password-confirm/:hash', 'get_reset_password_confirm', ['hash' => '[a-z0-9]+'], '\\' . \Box\Mod\Client\Controller\Client::class); + $app->get('/emails', 'get_emails', [], '\\' . \Box\Mod\Email\Controller\Client::class); + $app->get('/banklink/:hash/:id', 'get_banklink', ['id' => '[0-9]+', 'hash' => '[a-z0-9]+'], '\\' . \Box\Mod\Invoice\Controller\Client::class); + $app->get('/blog', 'get_news', [], '\\' . \Box\Mod\News\Controller\Client::class); + $app->get('/blog/:slug', 'get_news_item', ['slug' => '[a-z0-9-]+'], '\\' . \Box\Mod\News\Controller\Client::class); + $app->get('/service', 'get_orders', [], '\\' . \Box\Mod\Order\Controller\Client::class); + $app->get('/service/manage/:id', 'get_order', ['id' => '[0-9]+'], '\\' . \Box\Mod\Order\Controller\Client::class); + $app->get('/contact-us', 'get_contact_us', [], '\\' . \Box\Mod\Support\Controller\Client::class); + $app->get('/contact-us/conversation/:hash', 'get_contact_us_conversation', ['hash' => '[a-z0-9]+'], '\\' . \Box\Mod\Support\Controller\Client::class); $service = $this->di['mod_service']('redirect'); $redirects = $service->getRedirects(); diff --git a/src/modules/Redirect/Service.php b/src/modules/Redirect/Service.php index 4e64100dc..21afecb56 100644 --- a/src/modules/Redirect/Service.php +++ b/src/modules/Redirect/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Redirect; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Seo/Engines/Google.php b/src/modules/Seo/Engines/Google.php index 710a47b0f..b26d726c6 100644 --- a/src/modules/Seo/Engines/Google.php +++ b/src/modules/Seo/Engines/Google.php @@ -18,7 +18,7 @@ use Symfony\Component\HttpClient\HttpClient; class Google implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Seo/Service.php b/src/modules/Seo/Service.php index 1aeb6cdac..218451093 100644 --- a/src/modules/Seo/Service.php +++ b/src/modules/Seo/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -103,7 +103,7 @@ class Service implements InjectionAwareInterface $files = scandir($dir); foreach ($files as $file) { - if (substr($file, -4) == '.php') { + if (str_ends_with($file, '.php')) { $engine = substr($file, 0, -4); $class = 'Box\\Mod\\Seo\\Engines\\' . $engine; $engines[$engine] = new $class(); diff --git a/src/modules/Serviceapikey/Service.php b/src/modules/Serviceapikey/Service.php index 7a2b853a7..4bcfbff75 100644 --- a/src/modules/Serviceapikey/Service.php +++ b/src/modules/Serviceapikey/Service.php @@ -22,7 +22,7 @@ use RedBeanPHP\OODBBean; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -115,7 +115,6 @@ class Service implements InjectionAwareInterface /** * Checks if an API key is valid or not. * - * @param array $data * - 'key' What API key to check */ public function isValid(array $data): bool @@ -135,7 +134,6 @@ class Service implements InjectionAwareInterface /** * Checks if an API key is valid or not and returns that + any configured custom parameters. * - * @param array $data * - 'key' What API key to check */ public function getInfo(array $data): array @@ -329,7 +327,7 @@ class Service implements InjectionAwareInterface $result = ''; foreach ($characters as $character) { - if (mt_rand(0, 1) <= 0.5) { + if (random_int(0, 1) <= 0.5) { $character = strtoupper($character); } diff --git a/src/modules/Servicecustom/Service.php b/src/modules/Servicecustom/Service.php index 3200e3479..79d53c7a1 100644 --- a/src/modules/Servicecustom/Service.php +++ b/src/modules/Servicecustom/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Servicecustom; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Servicedomain/Controller/Admin.php b/src/modules/Servicedomain/Controller/Admin.php index 64c6a27f9..2afacb080 100644 --- a/src/modules/Servicedomain/Controller/Admin.php +++ b/src/modules/Servicedomain/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Servicedomain\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Servicedomain/Service.php b/src/modules/Servicedomain/Service.php index d9bc3e3f5..cd2eaeaf2 100644 --- a/src/modules/Servicedomain/Service.php +++ b/src/modules/Servicedomain/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Servicedomain; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -1023,7 +1023,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface public function registrarRm(\Model_TldRegistrar $model) { $domains = $this->di['db']->find('ServiceDomain', 'tld_registrar_id = :registrar_id', [':registrar_id' => $model->id]); - if (count($domains) > 0) { + if ((is_countable($domains) ? count($domains) : 0) > 0) { throw new \Box_Exception('Can not remove registrar which has domains'); } diff --git a/src/modules/Servicedomain/ServiceTld.php b/src/modules/Servicedomain/ServiceTld.php index 2f8ee964d..1e3cd4d4f 100644 --- a/src/modules/Servicedomain/ServiceTld.php +++ b/src/modules/Servicedomain/ServiceTld.php @@ -12,7 +12,7 @@ namespace Box\Mod\Servicedomain; class ServiceTld implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Servicedownloadable/Controller/Client.php b/src/modules/Servicedownloadable/Controller/Client.php index d971e0603..4ea2d3e3f 100644 --- a/src/modules/Servicedownloadable/Controller/Client.php +++ b/src/modules/Servicedownloadable/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Servicedownloadable\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Servicedownloadable/Service.php b/src/modules/Servicedownloadable/Service.php index 06b83f0e8..ed7523543 100644 --- a/src/modules/Servicedownloadable/Service.php +++ b/src/modules/Servicedownloadable/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Servicehosting/Controller/Admin.php b/src/modules/Servicehosting/Controller/Admin.php index 072a8a228..1492482ee 100644 --- a/src/modules/Servicehosting/Controller/Admin.php +++ b/src/modules/Servicehosting/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Servicehosting\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Servicehosting/Service.php b/src/modules/Servicehosting/Service.php index 55878d1c3..1f56ed51c 100644 --- a/src/modules/Servicehosting/Service.php +++ b/src/modules/Servicehosting/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Servicelicense/Plugin/Simple.php b/src/modules/Servicelicense/Plugin/Simple.php index 2e309f23d..c13b47022 100644 --- a/src/modules/Servicelicense/Plugin/Simple.php +++ b/src/modules/Servicelicense/Plugin/Simple.php @@ -12,7 +12,7 @@ namespace Box\Mod\Servicelicense\Plugin; class Simple { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -37,7 +37,7 @@ class Simple $length = $config['length'] ?? 25; $prefix = $config['prefix'] ?? null; - $character_array = array_merge(range('A', 'Z'), range(1, 9)); + $character_array = [...range('A', 'Z'), ...range(1, 9)]; $size = count($character_array) - 1; $string = ''; for ($i = 1; $i < $length; ++$i) { diff --git a/src/modules/Servicelicense/Server.php b/src/modules/Servicelicense/Server.php index ebe2d7318..f7107fa73 100644 --- a/src/modules/Servicelicense/Server.php +++ b/src/modules/Servicelicense/Server.php @@ -12,14 +12,14 @@ namespace Box\Mod\Servicelicense; class Server implements \FOSSBilling\InjectionAwareInterface { - private $_result = [ + private array $_result = [ 'licensed_to' => null, 'created_at' => null, 'expires_at' => null, 'valid' => false, ]; - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -69,7 +69,7 @@ class Server implements \FOSSBilling\InjectionAwareInterface public function process($data) { if (!is_array($data)) { - $data = (json_decode($data, true)) ? json_decode($data, true) : []; + $data = json_decode($data, true) ?: []; } if (empty($data)) { diff --git a/src/modules/Servicelicense/Service.php b/src/modules/Servicelicense/Service.php index f87475818..10740ce39 100644 --- a/src/modules/Servicelicense/Service.php +++ b/src/modules/Servicelicense/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -429,6 +429,7 @@ class Service implements InjectionAwareInterface */ public function checkLicenseDetails(array $data) { + $result = []; $log = $this->di['logger']->setChannel('license'); if ($this->di['config']['debug']) { $log->debug(print_r($data, 1)); diff --git a/src/modules/Servicemembership/Service.php b/src/modules/Servicemembership/Service.php index b4ea9768a..bfb6ea111 100644 --- a/src/modules/Servicemembership/Service.php +++ b/src/modules/Servicemembership/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Servicemembership; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Spamchecker/Service.php b/src/modules/Spamchecker/Service.php index 6d5db8f04..2613e7340 100644 --- a/src/modules/Spamchecker/Service.php +++ b/src/modules/Spamchecker/Service.php @@ -15,7 +15,7 @@ use Symfony\Component\HttpClient\HttpClient; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Staff/Controller/Admin.php b/src/modules/Staff/Controller/Admin.php index 085ee322a..cec68bf9f 100644 --- a/src/modules/Staff/Controller/Admin.php +++ b/src/modules/Staff/Controller/Admin.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Admin implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -49,8 +49,8 @@ class Admin implements InjectionAwareInterface $app->get('/staff/profile', 'get_profile', [], static::class); $app->get('/staff/logins', 'get_history', [], static::class); // staff password reset - $app->get('/staff/passwordreset', 'get_passwordreset', [], get_class($this)); - $app->get('/staff/email/:hash', 'get_updatepassword', ['hash' => '[a-zA-Z0-9]+'], get_class($this)); + $app->get('/staff/passwordreset', 'get_passwordreset', [], static::class); + $app->get('/staff/email/:hash', 'get_updatepassword', ['hash' => '[a-zA-Z0-9]+'], static::class); } public function get_login(\Box_App $app) @@ -110,6 +110,7 @@ class Admin implements InjectionAwareInterface public function get_updatepassword(\Box_App $app, $hash) { + $data = []; $this->di['events_manager']->fire(['event' => 'onBeforePasswordResetStaff']); $mod = $this->di['mod']('staff'); $config = $mod->getConfig(); diff --git a/src/modules/Staff/Service.php b/src/modules/Staff/Service.php index a2cecacbf..3b2b00c18 100644 --- a/src/modules/Staff/Service.php +++ b/src/modules/Staff/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Stats/Service.php b/src/modules/Stats/Service.php index 86252c501..af12049f3 100644 --- a/src/modules/Stats/Service.php +++ b/src/modules/Stats/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Support/Controller/Admin.php b/src/modules/Support/Controller/Admin.php index f087b7eaf..fb76cb44d 100644 --- a/src/modules/Support/Controller/Admin.php +++ b/src/modules/Support/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Support\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Support/Controller/Client.php b/src/modules/Support/Controller/Client.php index 51cff8826..97b36b4c0 100644 --- a/src/modules/Support/Controller/Client.php +++ b/src/modules/Support/Controller/Client.php @@ -12,7 +12,7 @@ namespace Box\Mod\Support\Controller; class Client implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Support/Service.php b/src/modules/Support/Service.php index 5dbd95fb5..7d6a1d129 100644 --- a/src/modules/Support/Service.php +++ b/src/modules/Support/Service.php @@ -12,7 +12,7 @@ namespace Box\Mod\Support; class Service implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -647,7 +647,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface $id = $model->id; $tickets = $this->di['db']->find('SupportTicket', 'support_helpdesk_id = :support_helpdesk_id', [':support_helpdesk_id' => $model->id]); - if (count($tickets) > 0) { + if ((is_countable($tickets) ? count($tickets) : 0) > 0) { throw new \Box_Exception('Can not remove helpdesk which has tickets'); } $this->di['db']->trash($model); diff --git a/src/modules/System/Controller/Admin.php b/src/modules/System/Controller/Admin.php index 51fd23f4a..76132358a 100644 --- a/src/modules/System/Controller/Admin.php +++ b/src/modules/System/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\System\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/System/Service.php b/src/modules/System/Service.php index ca8d6a686..cc4c52b30 100644 --- a/src/modules/System/Service.php +++ b/src/modules/System/Service.php @@ -15,7 +15,7 @@ use Symfony\Component\HttpClient\HttpClient; class Service { - protected ?Container $di; + protected ?Container $di = null; public function setDi(Container $di): void { @@ -144,7 +144,7 @@ class Service if ($logoUrlDark !== null && !str_contains($logoUrlDark, 'http')) { $logoUrlDark = $baseUrl . $logoUrlDark; } - $logoUrlDark = ($logoUrlDark === null) ? $logoUrl : $logoUrlDark; + $logoUrlDark ??= $logoUrl; $faviconUrl = $results['company_favicon'] ?? null; if ($faviconUrl !== null && !str_contains($faviconUrl, 'http')) { @@ -965,7 +965,7 @@ class Service if (isset($config['countries'])) { preg_match_all('#([A-Z]{2})=(.+)#', $config['countries'], $matches); if (isset($matches[1]) && !empty($matches[1]) && isset($matches[2]) && !empty($matches[2])) { - if (count($matches[1]) == count($matches[2])) { + if ((is_countable($matches[1]) ? count($matches[1]) : 0) == (is_countable($matches[2]) ? count($matches[2]) : 0)) { $countries = array_combine($matches[1], $matches[2]); } } diff --git a/src/modules/Theme/Controller/Admin.php b/src/modules/Theme/Controller/Admin.php index 3450422e9..8f1d65db9 100644 --- a/src/modules/Theme/Controller/Admin.php +++ b/src/modules/Theme/Controller/Admin.php @@ -12,7 +12,7 @@ namespace Box\Mod\Theme\Controller; class Admin implements \FOSSBilling\InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { diff --git a/src/modules/Theme/Service.php b/src/modules/Theme/Service.php index 3b7675111..837d664f9 100644 --- a/src/modules/Theme/Service.php +++ b/src/modules/Theme/Service.php @@ -14,7 +14,7 @@ use FOSSBilling\InjectionAwareInterface; class Service implements InjectionAwareInterface { - protected ?\Pimple\Container $di; + protected ?\Pimple\Container $di = null; public function setDi(\Pimple\Container $di): void { @@ -389,6 +389,7 @@ class Service implements InjectionAwareInterface public function getEncoreInfo(): array { + $encoreInfo = []; $entrypoint = 'entrypoints'; $manifest = 'manifest'; $encoreInfo['is_encore_theme'] = true;