Several bug fixes using phpstan
This commit is contained in:
parent
717cafe213
commit
4a69541419
15
build/phpstan/bootstrap.php
Normal file
15
build/phpstan/bootstrap.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
// Example to use PHPStan
|
||||
// cd git/dolibarr
|
||||
// /usr/bin/php7.2 ../phpstan.phar -l1 analyze htdocs/societe/website.php --memory-limit 2G
|
||||
|
||||
// Defined some constants and load Dolibarr env to reduce PHPStan bootstrap that fails to load a lot of things.
|
||||
define('DOL_DOCUMENT_ROOT', __DIR__ . '/../../htdocs');
|
||||
define('DOL_DATA_ROOT', __DIR__ . '/../../documents');
|
||||
define('DOL_URL_ROOT', '/');
|
||||
|
||||
// Load the main.inc.php file to have finctions llx_Header and llx_Footer defined
|
||||
if (! defined("NOLOGIN")) define("NOLOGIN",'1');
|
||||
global $conf, $langs, $user, $db;
|
||||
include_once __DIR__ . '/../../htdocs/main.inc.php';
|
||||
|
||||
@ -660,16 +660,19 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
|
||||
if (empty($type)) // For a filesystem path
|
||||
{
|
||||
$res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path
|
||||
foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array("main"=>"/home/main/htdocs", "alt0"=>"/home/dirmod/htdocs", ...)
|
||||
if (is_array($conf->file->dol_document_root))
|
||||
{
|
||||
if ($key == 'main')
|
||||
foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array("main"=>"/home/main/htdocs", "alt0"=>"/home/dirmod/htdocs", ...)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (file_exists($dirroot.'/'.$path))
|
||||
{
|
||||
$res=$dirroot.'/'.$path;
|
||||
return $res;
|
||||
if ($key == 'main')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (file_exists($dirroot.'/'.$path))
|
||||
{
|
||||
$res=$dirroot.'/'.$path;
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($returnemptyifnotfound) // Not found into alternate dir
|
||||
|
||||
@ -1152,7 +1152,7 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0)
|
||||
$contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY;
|
||||
|
||||
if (! is_object($hookmanager)) $hookmanager = new HookManager($db);
|
||||
$hookmanager->initHooks("main");
|
||||
$hookmanager->initHooks(array("main"));
|
||||
|
||||
$parameters=array('contentsecuritypolicy'=>$contentsecuritypolicy);
|
||||
$result=$hookmanager->executeHooks('setContentSecurityPolicy', $parameters); // Note that $action and $object may have been modified by some hooks
|
||||
@ -1212,7 +1212,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
|
||||
if (empty($disablehead))
|
||||
{
|
||||
if (! is_object($hookmanager)) $hookmanager = new HookManager($db);
|
||||
$hookmanager->initHooks("main");
|
||||
$hookmanager->initHooks(array("main"));
|
||||
|
||||
$ext='layout='.$conf->browser->layout.'&version='.urlencode(DOL_VERSION);
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file class/societeaccount.class.php
|
||||
* \file societe/class/societeaccount.class.php
|
||||
* \ingroup societe
|
||||
* \brief This file is a CRUD class file for SocieteAccount (Create/Read/Update/Delete)
|
||||
*/
|
||||
|
||||
@ -37,6 +37,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
|
||||
$langs->loadLangs(array("companies","website"));
|
||||
|
||||
$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||
$show_files = GETPOST('show_files', 'int');
|
||||
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search
|
||||
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||
|
||||
$search_status=GETPOST('search_status');
|
||||
|
||||
// Security check
|
||||
@ -340,14 +346,14 @@ $objecttmp=new SocieteAccount($db);
|
||||
$trackid='thi'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($sall)
|
||||
/*if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
}*/
|
||||
|
||||
/*$moreforfilter = '';
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter = '';
|
||||
/*$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
|
||||
$moreforfilter.= '</div>';*/
|
||||
|
||||
|
||||
35
phpstan.neon
35
phpstan.neon
@ -1,8 +1,27 @@
|
||||
parameters:
|
||||
bootstrap: null
|
||||
bootstrap: %currentWorkingDirectory%/build/phpstan/bootstrap.php
|
||||
excludes_analyse:
|
||||
- %rootDir%/htdocs/includes/*
|
||||
autoload_directories: []
|
||||
- %currentWorkingDirectory%/htdocs/includes/*
|
||||
autoload_directories:
|
||||
- %currentWorkingDirectory%/htdocs/accountancy/class
|
||||
- %currentWorkingDirectory%/htdocs/adherents/class
|
||||
- %currentWorkingDirectory%/htdocs/api/class
|
||||
- %currentWorkingDirectory%/htdocs/asset/class
|
||||
- %currentWorkingDirectory%/htdocs/blockedlog/class
|
||||
- %currentWorkingDirectory%/htdocs/bom/class
|
||||
- %currentWorkingDirectory%/htdocs/bookmarks/class
|
||||
- %currentWorkingDirectory%/htdocs/cashdesk/class
|
||||
- %currentWorkingDirectory%/htdocs/categories/class
|
||||
- %currentWorkingDirectory%/htdocs/comm/action/class
|
||||
- %currentWorkingDirectory%/htdocs/comm/propal/class
|
||||
- %currentWorkingDirectory%/htdocs/commande/class
|
||||
- %currentWorkingDirectory%/htdocs/compta/bank/class
|
||||
- %currentWorkingDirectory%/htdocs/conf
|
||||
- %currentWorkingDirectory%/htdocs/contact/class
|
||||
- %currentWorkingDirectory%/htdocs/contrat/class
|
||||
- %currentWorkingDirectory%/htdocs/core/class
|
||||
- %currentWorkingDirectory%/htdocs/societe/class
|
||||
- %currentWorkingDirectory%/htdocs/user/class
|
||||
autoload_files: []
|
||||
featureToggles:
|
||||
subtractableTypes: false
|
||||
@ -30,7 +49,15 @@ parameters:
|
||||
polluteCatchScopeWithTryAssignments: false
|
||||
reportMagicMethods: false
|
||||
reportMagicProperties: false
|
||||
ignoreErrors: []
|
||||
ignoreErrors:
|
||||
-
|
||||
message: '#Call to an undefined method abcdef#'
|
||||
path: %currentWorkingDirectory%/dirtoignoreerror/*
|
||||
- '#Undefined variable: \$langs#'
|
||||
- '#Undefined variable: \$user#'
|
||||
- '#Undefined variable: \$db#'
|
||||
- '#Undefined variable: \$conf#'
|
||||
- '#Undefined variable: \$hookmanager#'
|
||||
internalErrorsCountLimit: 50
|
||||
cache:
|
||||
nodesByFileCountMax: 512
|
||||
|
||||
Loading…
Reference in New Issue
Block a user