mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 09:08:09 +01:00
switching on phpstan v2 level 10 (#31764)
* switching on phpstan v2 level 10 * switching on phpstan v2 level 10 * switching on phpstan v2 level 10 * switching on phpstan v2 level 10 * switching on phpstan v2 level 10 * version * fix phpstan * fix phpstan * test * test * test * test * test * fix * fix * fix * fix * fix * fix * fix * add action to refresh phpstan baseline * add action to refresh phpstan baseline * add action to refresh phpstan baseline * add action to refresh phpstan baseline * fix phpstan * fix phpstan * fix phpstan * fix phpstan * update baseline
This commit is contained in:
@@ -26,3 +26,7 @@ trim_trailing_whitespace = false
|
||||
indent_style = tab
|
||||
trim_trailing_whitespace = true
|
||||
indent_size = 4
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
10
.github/workflows/phpstan.yml
vendored
10
.github/workflows/phpstan.yml
vendored
@@ -37,14 +37,14 @@ jobs:
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Get PHP and addons
|
||||
- name: Setup PHP
|
||||
id: setup-php
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
tools: phpstan:1.12, cs2pr
|
||||
coverage: none # disable xdebug, pcov
|
||||
tools: phpstan:2.0, cs2pr
|
||||
extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap,
|
||||
mysql, pgsql, sqlite3, ldap, xml, mcrypt
|
||||
|
||||
@@ -86,3 +86,9 @@ jobs:
|
||||
name: phpstan-srcrt
|
||||
path: ${{ github.workspace }}/_stan.xml
|
||||
retention-days: 2
|
||||
# Run PHPStan generate baseline
|
||||
# - name: Run PHPStan generate baseline
|
||||
# id: phpstan-baseline
|
||||
# if: ${{ success() }}
|
||||
# run: |
|
||||
# phpstan -vv analyse --memory-limit 7G -a build/phpstan/bootstrap_action.php --generate-baseline build/phpstan/phpstan-baseline.neon
|
||||
|
||||
73
.github/workflows/phpstan_baseline.yml
vendored
Normal file
73
.github/workflows/phpstan_baseline.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
name: 'PHPStan'
|
||||
|
||||
on:
|
||||
# Every Monday we want to refresh the baseline
|
||||
schedule:
|
||||
- cron: '0 6 * * 1'
|
||||
|
||||
# We want to be able to manually refresh the baseline too
|
||||
workflow_dispatch:
|
||||
|
||||
workflow_call:
|
||||
inputs:
|
||||
gh_event:
|
||||
required: true
|
||||
type: string
|
||||
# Run PHPStan analyse on pull requests
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
PHP_VERSION: '8.2'
|
||||
gh_event: ${{ inputs.gh_event || github.event_name }}
|
||||
CACHE_KEY_PART: ${{ ( inputs.gh_event == 'pull_request' || github.event_name == 'pull_request' ) && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }}
|
||||
jobs:
|
||||
phpstan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ env.PHP_VERSION }}
|
||||
coverage: none # disable xdebug, pcov
|
||||
tools: phpstan:2.0, cs2pr
|
||||
extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap,
|
||||
mysql, pgsql, sqlite3, ldap, xml, mcrypt
|
||||
env:
|
||||
fail-fast: true
|
||||
# Restore old cache
|
||||
- name: Restore phpstan cache
|
||||
id: cache
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ./.github/tmp
|
||||
key: phpstan-cache-${{ env.PHP_VERSION }}-${{ env.CACHE_KEY_PART }}-${{
|
||||
github.run_id }}
|
||||
restore-keys: |
|
||||
phpstan-cache-${{ env.PHP_VERSION }}-${{ env.CACHE_KEY_PART }}-
|
||||
phpstan-cache-${{ env.PHP_VERSION }}-${{ github.head_ref }}-
|
||||
phpstan-cache-${{ env.PHP_VERSION }}-${{ github.base_ref }}-
|
||||
phpstan-cache-${{ env.PHP_VERSION }}-
|
||||
- uses: ruudk/phpstan-baseline-refresh-create-pr-action@main
|
||||
with:
|
||||
github_token: ${{ secrets.PAT_GITHUB_TOKEN }}
|
||||
phpstan_path: phpstan
|
||||
configuration_path: phpstan.neon.dist
|
||||
phpstan_additional_arguments: --memory-limit 7G -a build/phpstan/bootstrap_action.php
|
||||
baseline_path: build/phpstan/phpstan-baseline.neon
|
||||
commit_name: Dolibot
|
||||
commit_email: dolibarr-bot@users.noreply.github.com
|
||||
commit_message: PHPStan > Update baseline
|
||||
target_branch: develop
|
||||
pr_create: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && 1 || 0 }}
|
||||
pr_title: PHPStan > Update baseline
|
||||
pr_reviewer: eldy
|
||||
pr_body: |
|
||||
This PR is automatically created to cleanup our baseline.
|
||||
|
||||
Since the last refresh of the baseline we have fixed {0} ignored errors.
|
||||
|
||||
Keep it up all! :muscle:
|
||||
|
||||
There are only {1} ignored errors left :sweat_smile:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2014-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -29,7 +30,11 @@
|
||||
// $nomessageinsetmoduleoptions can be set to 1
|
||||
// $formSetup may be defined
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var FormSetup $formSetup
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
* @var string $action
|
||||
* @var int $error
|
||||
* @var ?int $nomessageinupdate
|
||||
|
||||
@@ -27,10 +27,20 @@
|
||||
// $permissionnote must be defined to permission to edit object
|
||||
// $object must be defined (object is loaded in this file with fetch)
|
||||
// $id must be defined (object is loaded in this file with fetch)
|
||||
|
||||
/**
|
||||
* @var CommonObject $object
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*
|
||||
* @var ?string $action
|
||||
* @var int $id
|
||||
* @var int $permissionnote
|
||||
*/
|
||||
// Set public note
|
||||
if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) {
|
||||
if (empty($action) || !is_object($object) || empty($id)) {
|
||||
if (!is_object($object) || empty($id)) {
|
||||
dol_print_error(null, 'Include of actions_setnotes.inc.php was done but required variable was not set before');
|
||||
}
|
||||
if (empty($object->id)) {
|
||||
@@ -79,7 +89,7 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel',
|
||||
} elseif ($action == 'setnote_private' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) { // Set public note
|
||||
if (empty($user->socid)) {
|
||||
// Private notes (always hidden to external users)
|
||||
if (empty($action) || !is_object($object) || empty($id)) {
|
||||
if (!is_object($object) || empty($id)) {
|
||||
dol_print_error(null, 'Include of actions_setnotes.inc.php was done but required variable was not set before');
|
||||
}
|
||||
if (empty($object->id)) {
|
||||
|
||||
@@ -694,7 +694,7 @@ class FormFile
|
||||
if (is_array($genallowed)) {
|
||||
$modellist = $genallowed;
|
||||
} else {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/movement/modules_movement.php';
|
||||
$modellist = ModelePDFMovement::liste_modeles($this->db);
|
||||
}
|
||||
} elseif ($modulepart == 'export') {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* \brief File of class to build ODT documents for assets
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/core/modules/asset/modules_asset.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/modules/asset/modules_asset.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
* \brief File of class to generate document from standard template
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/asset/core/modules/asset/modules_asset.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/modules/asset/modules_asset.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -123,9 +124,9 @@ abstract class ModelePDFFactures extends CommonDocGenerator
|
||||
|
||||
// Load the autoload file generated by composer
|
||||
if (file_exists(DOL_DOCUMENT_ROOT.'/includes/sprain/swiss-qr-bill/autoload.php')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/sprain/swiss-qr-bill/autoload.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/sprain/swiss-qr-bill/autoload.php'; // @phpstan-ignore-line
|
||||
} elseif (file_exists(DOL_DOCUMENT_ROOT.'/includes/autoload.php')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/autoload.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/autoload.php'; // @phpstan-ignore-line
|
||||
} else {
|
||||
$this->error = 'PHP library sprain/swiss-qr-bill was not found. Please install it with:<br>cd '.dirname(DOL_DOCUMENT_ROOT).'; cp composer.json.disabled composer.json; composer require sprain/swiss-qr-bill;';
|
||||
return false;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* \brief File of class to build PDF documents for stocks movements
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/movement/modules_movement.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
require '../main.inc.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/eventorganization/lib/eventorganization_conferenceorboothattendee.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/eventorganization/lib/eventorganization_conferenceorbooth.lib.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
* Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -137,6 +138,7 @@ $conffiletoshow = "htdocs/conf/conf.php";
|
||||
// --- End of part replaced by Dolibarr packager makepack-dolibarr
|
||||
|
||||
// Include configuration
|
||||
// @phpstan-ignore-next-line
|
||||
$result = @include_once $conffile; // Keep @ because with some error reporting mode, this breaks the redirect done when file is not found
|
||||
|
||||
// Disable some not used PHP stream
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2008-2024 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2008-2024 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -91,7 +91,13 @@ if (is_numeric($entity)) {
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
$object = new ActionComm($db);
|
||||
|
||||
// Not older than
|
||||
|
||||
@@ -54,7 +54,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/public.lib.php';
|
||||
if (!isModEnabled('bookcal')) {
|
||||
httponly_accessforbidden('Module Bookcal isn\'t enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var Translate $langs
|
||||
*/
|
||||
$langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "companies"));
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
@@ -11,7 +11,7 @@ parameters:
|
||||
# minimumNumberOfJobsPerProcess: 2 # default is 2
|
||||
# buffer: 134217728 # 128 MB # Not documented
|
||||
customRulesetUsed: true
|
||||
level: 9
|
||||
level: 10
|
||||
fileExtensions:
|
||||
- php
|
||||
paths:
|
||||
@@ -28,9 +28,9 @@ parameters:
|
||||
analyse:
|
||||
- htdocs/includes/*
|
||||
- htdocs/core/class/lessc.class.php
|
||||
checkAlwaysTrueCheckTypeFunctionCall: false
|
||||
checkAlwaysTrueInstanceof: false
|
||||
checkAlwaysTrueStrictComparison: false
|
||||
# checkAlwaysTrueCheckTypeFunctionCall: false
|
||||
# checkAlwaysTrueInstanceof: false
|
||||
# checkAlwaysTrueStrictComparison: false
|
||||
checkClassCaseSensitivity: true
|
||||
checkFunctionArgumentTypes: true
|
||||
checkFunctionNameCase: true
|
||||
@@ -52,7 +52,7 @@ parameters:
|
||||
- '#.*phan-var#'
|
||||
internalErrorsCountLimit: 50
|
||||
cache:
|
||||
nodesByFileCountMax: 512
|
||||
# nodesByFileCountMax: 512
|
||||
nodesByStringCountMax: 512
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
universalObjectCratesClasses:
|
||||
|
||||
Reference in New Issue
Block a user