mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-09 05:24:58 +09:00
Introduce PHPStan
This commit is contained in:
1 parent
d27c1f9ae5
commit
1bb7dc2fd0
13 files changed
+116
-29
No files matched your search
@@ -1,4 +1,4 @@
|
||||
name: PHP Composer
|
||||
name: PHP Composer & PHPStan
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -69,3 +69,7 @@ jobs:
|
||||
- name: Run test suite for library
|
||||
run: |
|
||||
php ./src/vendor/bin/phpunit ./tests/library/
|
||||
|
||||
- name: Run PHPStan analysis
|
||||
uses: php-actions/phpstan@v3
|
||||
configuration: phpstan.neon
|
||||
@@ -0,0 +1,71 @@
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
-
|
||||
message: "#^Caught class Stripe\\\\Error\\\\ApiConnection not found\\.$#"
|
||||
count: 1
|
||||
path: src/library/Payment/Adapter/Stripe.php
|
||||
|
||||
-
|
||||
message: "#^Caught class Stripe\\\\Error\\\\Authentication not found\\.$#"
|
||||
count: 1
|
||||
path: src/library/Payment/Adapter/Stripe.php
|
||||
|
||||
-
|
||||
message: "#^Caught class Stripe\\\\Error\\\\Card not found\\.$#"
|
||||
count: 1
|
||||
path: src/library/Payment/Adapter/Stripe.php
|
||||
|
||||
-
|
||||
message: "#^Caught class Stripe\\\\Error\\\\InvalidRequest not found\\.$#"
|
||||
count: 1
|
||||
path: src/library/Payment/Adapter/Stripe.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Payment_AdapterAbstract\\:\\:init\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: src/library/Payment/AdapterAbstract.php
|
||||
|
||||
-
|
||||
message: "#^Method Registrar_Adapter_Internetbs\\:\\:_process\\(\\) should return array but return statement is missing\\.$#"
|
||||
count: 1
|
||||
path: src/library/Registrar/Adapter/Internetbs.php
|
||||
|
||||
-
|
||||
message: "#^Method Registrar_Adapter_Internetbs\\:\\:getDomainDetails\\(\\) should return Registrar_Domain but return statement is missing\\.$#"
|
||||
count: 1
|
||||
path: src/library/Registrar/Adapter/Internetbs.php
|
||||
|
||||
-
|
||||
message: "#^Undefined variable\\: \\$client_id$#"
|
||||
count: 1
|
||||
path: src/library/Server/Manager/Ispconfig3.php
|
||||
|
||||
-
|
||||
message: "#^Undefined variable\\: \\$section$#"
|
||||
count: 1
|
||||
path: src/library/Server/Manager/Ispconfig3.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property Server_Manager_Plesk\\:\\:\\$_client\\.$#"
|
||||
count: 23
|
||||
path: src/library/Server/Manager/Plesk.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: "#^Method Server_Manager_Plesk\\:\\:testConnection\\(\\) should return bool but return statement is missing\\.$#"
|
||||
count: 1
|
||||
path: src/library/Server/Manager/Plesk.php
|
||||
|
||||
-
|
||||
message: "#^Undefined variable\\: \\$client$#"
|
||||
count: 10
|
||||
path: src/library/Server/Manager/Plesk.php
|
||||
|
||||
-
|
||||
message: "#^Undefined variable\\: \\$domainId$#"
|
||||
count: 1
|
||||
path: src/library/Server/Manager/Plesk.php
|
||||
@@ -0,0 +1,26 @@
|
||||
includes:
|
||||
- phpstan-baseline.neon
|
||||
|
||||
parameters:
|
||||
level: 0
|
||||
paths:
|
||||
- src
|
||||
excludePaths:
|
||||
analyse:
|
||||
- src/vendor
|
||||
- src/rb.php
|
||||
- src/library/Registrar/Adapter/srsx.php
|
||||
- src/library/Box/Request.php
|
||||
- src/library/Server/Manager/Custom.php
|
||||
ignoreErrors:
|
||||
- '#^Function __trans not found\.$#'
|
||||
- message: '#^Function rmAllDir not found\.$#'
|
||||
path: src/install/install.php
|
||||
- message: '#^Access to an undefined property FOSSPatchAbstract\:\:\$di\.$#'
|
||||
path: src/foss-update.php
|
||||
- '#^Inner named functions are not supported by PHPStan\. Consider refactoring to an anonymous function, class method, or a top\-level\-defined function\. See issue \#165 \(https\://github\.com/phpstan/phpstan/issues/165\) for more details\.$#'
|
||||
- message: '#^Result of function curl_close \(void\) is used\.$#'
|
||||
path: src/modules/Spamchecker/akismet.curl.class.php
|
||||
- message: '#^Result of function header \(void\) is used\.$#'
|
||||
path: src/modules/Custompages/Controller/Client.php
|
||||
- '#^Method Box\\Mod\\Currency\\Service\:\:_getRate\(\) should return float but return statement is missing\.$#'
|
||||
@@ -389,12 +389,6 @@ $di['license_server'] = function () use ($di) {
|
||||
return $server;
|
||||
};
|
||||
|
||||
$di['service_boxbilling'] = $di->protect(function ($config) {
|
||||
$service = new \Box\Mod\Serviceboxbillinglicense\ServiceBoxbilling($config);
|
||||
|
||||
return $service;
|
||||
});
|
||||
|
||||
$di['ftp'] = $di->protect(function ($params) { return new \Box_Ftp($params); });
|
||||
|
||||
$di['geoip'] = function () { return new \GeoIp2\Database\Reader(PATH_LIBRARY . '/GeoLite2-Country.mmdb'); };
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
|
||||
class Box_DbLoggedPDOStatement extends PDOStatement
|
||||
{
|
||||
public function execute ($input_parameters = null)
|
||||
public function execute ($input_parameters = null): bool
|
||||
{
|
||||
error_log($this->queryString);
|
||||
parent::execute($input_parameters);
|
||||
return parent::execute($input_parameters);
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@
|
||||
$params = array();
|
||||
$params['type'] = $type;
|
||||
$params['id'] = $id;
|
||||
return $this->_request('extension/' . $params['id'] . '/version');
|
||||
return $this->_request('extension/' . $params['id'] . '/version', $params);
|
||||
}
|
||||
|
||||
public function getLatest($type = null)
|
||||
|
||||
@@ -343,7 +343,7 @@ class Server_Manager_Vesta extends Server_Manager
|
||||
'returncode' => $vst_returncode,
|
||||
'cmd' => $vst_command,
|
||||
'arg1' => $a->getUsername(),
|
||||
'arg2' => $this->create_tmp_file($new),
|
||||
'arg2' => $new,
|
||||
];
|
||||
// Make request and change password
|
||||
$result = $this->_makeRequest($postvars);
|
||||
|
||||
@@ -632,12 +632,7 @@ class xmlapi {
|
||||
if ( (defined('XMLAPI_DEBUG')) && (XMLAPI_DEBUG == '1') ) {
|
||||
$this->debug = true;
|
||||
}
|
||||
|
||||
// Check if raw xml output must be enabled
|
||||
if ( (defined('XMLAPI_RAW_XML')) && (XMLAPI_RAW_XML == '1') ) {
|
||||
$this->raw_xml = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Authentication
|
||||
* This can either be passed at this point or by using the set_hash or set_password functions
|
||||
@@ -1907,7 +1902,7 @@ class xmlapi {
|
||||
* @link http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/EditPackage XML API Call documentation
|
||||
*/
|
||||
public function editpkg($pkg) {
|
||||
if (!$isset($pkg['name'])) {
|
||||
if (!isset($pkg['name'])) {
|
||||
error_log("editpkg requires that name is defined in the array passed to it");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ class Service
|
||||
{
|
||||
try {
|
||||
$api->{$method}($params);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception($e);
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception($e);
|
||||
} finally {
|
||||
if ('cli' == php_sapi_name()) {
|
||||
echo "\e[32mSuccessfully ran " . $method . '(' . $params . ')' . ".\e[0m\n";
|
||||
|
||||
@@ -364,7 +364,6 @@ class Service implements InjectionAwareInterface
|
||||
*
|
||||
* @since 4.22.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function updateKey($key)
|
||||
{
|
||||
@@ -372,7 +371,7 @@ class Service implements InjectionAwareInterface
|
||||
$values = [':key' => $key];
|
||||
|
||||
$db = $this->di['db'];
|
||||
$currency = $db->exec($sql, $values);
|
||||
$db->exec($sql, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,7 +379,7 @@ class Service implements InjectionAwareInterface
|
||||
*
|
||||
* @since 4.22.0
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public function isCronEnabled()
|
||||
{
|
||||
@@ -403,7 +402,6 @@ class Service implements InjectionAwareInterface
|
||||
*
|
||||
* @var int
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setCron($data)
|
||||
{
|
||||
@@ -418,7 +416,7 @@ class Service implements InjectionAwareInterface
|
||||
$values = [':key' => $key];
|
||||
|
||||
$db = $this->di['db'];
|
||||
$currency = $db->exec($sql, $values);
|
||||
$db->exec($sql, $values);
|
||||
}
|
||||
|
||||
public function toApiArray(\Model_Currency $model)
|
||||
|
||||
@@ -515,8 +515,8 @@ class Service implements InjectionAwareInterface
|
||||
}
|
||||
|
||||
$info = $mod->getManifest();
|
||||
if (isset($info['minimum_boxbilling_version']) && Box_Version::compareVersion($info['minimum_boxbilling_version']) > 0) {
|
||||
throw new \Box_Exception('Module can not be installed. It requires at least :min version of FOSSBilling. You are using :v', [':min' => $info['minimum_boxbilling_version'], ':v' => Box_Version::VERSION]);
|
||||
if (isset($info['minimum_boxbilling_version']) && \Box_Version::compareVersion($info['minimum_boxbilling_version']) > 0) {
|
||||
throw new \Box_Exception('Module can not be installed. It requires at least :min version of FOSSBilling. You are using :v', [':min' => $info['minimum_boxbilling_version'], ':v' => \Box_Version::VERSION]);
|
||||
}
|
||||
|
||||
// Allow install module even if no installer exists
|
||||
|
||||
@@ -160,7 +160,7 @@ class Service implements \Box\InjectionAwareInterface
|
||||
'client_id' => $client_id,
|
||||
];
|
||||
|
||||
$extensionService = $di['mod_service']('extension');
|
||||
$extensionService = $this->di['mod_service']('extension');
|
||||
if ($extensionService->isExtensionActive('mod', 'demo')) {
|
||||
throw new \Box_Exception('Disabled for security reasons (Demo mode enabled)');
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ class Admin implements \Box\InjectionAwareInterface
|
||||
*
|
||||
* @param string $code - client area theme code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function save_theme_settings(\Box_App $app, $theme)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user