Browse Source

feat(dev-tools): Mise en place phpcs+phpstan (#4716)

Co-authored-by: JamesRezo <james@rezo.net>
Reviewed-on: #4716
Co-authored-by: JamesRezo <jamesrezo@noreply.git.spip.net>
Co-committed-by: JamesRezo <jamesrezo@noreply.git.spip.net>
master
JamesRezo 1 month ago
parent
commit
4b0fb4e4aa
  1. 7
      .gitignore
  2. 5
      action/restaurer.php
  3. 18
      base/restaurer.php
  4. 7
      composer.json
  5. 4
      dump_autoriser.php
  6. 19
      formulaires/restaurer.php
  7. 15
      formulaires/sauvegarder.php
  8. 58
      inc/dump.php
  9. 9
      inc/sauvegarder.php
  10. 14
      phpcs.xml.dist
  11. 567
      phpstan-baseline.neon
  12. 11
      phpstan.neon.dist
  13. 6
      prive/squelettes/contenu/restaurer_fonctions.php
  14. 2
      prive/squelettes/contenu/sauvegarder_fonctions.php

7
.gitignore

@ -0,0 +1,7 @@
/vendor/
/composer.phar
/composer.lock
/phpcs.xml
/phpstan.neon
/.php_cs.cache
/.php_cs.txt

5
action/restaurer.php

@ -42,7 +42,8 @@ function action_restaurer_dist($arg = null) {
$status_file = $arg;
define('_DUMP_STATUS_FILE', $status_file);
$status_file = _DIR_TMP . basename($status_file) . '.txt';
if (!lire_fichier($status_file, $status)
if (
!lire_fichier($status_file, $status)
or !$status = unserialize($status)
) {
include_spip('inc/headers');
@ -50,7 +51,7 @@ function action_restaurer_dist($arg = null) {
} else {
utiliser_langue_visiteur();
$archive = '<br />' . joli_repertoire($status['archive']);
$action = _T('dump:info_restauration_sauvegarde', array('archive' => $archive));
$action = _T('dump:info_restauration_sauvegarde', ['archive' => $archive]);
$admin = charger_fonction('admin', 'inc');
echo $admin('restaurer', $action, '', true);
}

18
base/restaurer.php

@ -26,7 +26,8 @@ include_spip('inc/actions');
function base_restaurer_dist($titre = '', $reprise = false) {
$status_file = _DUMP_STATUS_FILE;
$status_file = _DIR_TMP . basename($status_file) . '.txt';
if (!lire_fichier($status_file, $status)
if (
!lire_fichier($status_file, $status)
or !$status = unserialize($status)
) {
} else {
@ -56,14 +57,15 @@ function base_restaurer_dist($titre = '', $reprise = false) {
// au premier coup on ne fait rien sauf afficher l'ecran de sauvegarde
if (_request('step')) {
$options = array(
$options = [
'callback_progression' => 'dump_afficher_progres',
'max_time' => $max_time,
'no_erase_dest' => lister_tables_noerase(),
'where' => $status['where'] ? $status['where'] : array(),
'desc_tables_dest' => array()
);
if ($desc = sql_getfetsel('valeur', 'spip_meta', "nom='dump_structure_temp'", '', '', '', '', 'dump')
'where' => $status['where'] ? $status['where'] : [],
'desc_tables_dest' => []
];
if (
$desc = sql_getfetsel('valeur', 'spip_meta', "nom='dump_structure_temp'", '', '', '', '', 'dump')
and $desc = unserialize($desc)
) {
$options['desc_tables_dest'] = $desc;
@ -71,8 +73,8 @@ function base_restaurer_dist($titre = '', $reprise = false) {
$res = base_copier_tables($status_file, $status['tables'], 'dump', '', $options);
} else {
// mais on en profite pour reparer les version base pour etre sur de ne pas les perdre
sql_updateq('spip_meta', array('impt' => 'oui'), "nom='version_installee'", '', 'dump');
sql_updateq('spip_meta', array('impt' => 'oui'), "nom LIKE '%_base_version'", '', 'dump');
sql_updateq('spip_meta', ['impt' => 'oui'], "nom='version_installee'", '', 'dump');
sql_updateq('spip_meta', ['impt' => 'oui'], "nom LIKE '%_base_version'", '', 'dump');
}
echo("</div>\n");

7
composer.json

@ -0,0 +1,7 @@
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"spip/coding-standards": "^1.2",
"phpstan/phpstan": "^0.12.98"
}
}

4
dump_autoriser.php

@ -40,5 +40,5 @@ function dump_autoriser() {
* @return bool true s'il a le droit, false sinon
**/
function autoriser_restaurer_menu_dist($faire, $type, $id, $qui, $opt) {
return autoriser('sauvegarder', $type, $id, $qui, $opt);
}
return autoriser('sauvegarder', $type, $id, $qui, $opt);
}

19
formulaires/restaurer.php

@ -24,14 +24,14 @@ include_spip('inc/dump');
function formulaires_restaurer_charger_dist() {
// ici on liste tout, les tables exclue sont simplement non cochees
$valeurs = array(
$valeurs = [
'_dir_dump' => dump_repertoire(),
'choisi' => _request('fichier') ? _request('fichier') : _request('nom'),
'nom_sauvegarde' => '',
'tout_restaurer' => (_request('check_tables') and !_request('tout_restaurer')) ? '' : 'oui',
'fichier' => '',
'tri' => 'nom',
);
];
return $valeurs;
}
@ -42,7 +42,7 @@ function formulaires_restaurer_charger_dist() {
* @return array
*/
function formulaires_restaurer_verifier_dist() {
$erreurs = array();
$erreurs = [];
$nom = '';
if (!$fichier = _request('fichier') and !$nom = _request('nom_sauvegarde')) {
$erreurs['fichier'] = _T('info_obligatoire');
@ -71,7 +71,7 @@ function formulaires_restaurer_verifier_dist() {
}
dump_serveur($args);
$tables = base_lister_toutes_tables('dump');
$tables = base_saisie_tables('tables', $tables, array(), _request('tables') ? _request('tables') : array(), 'dump');
$tables = base_saisie_tables('tables', $tables, [], _request('tables') ? _request('tables') : [], 'dump');
$erreurs['tables'] = "<ol class='spip'><li class='choix'>\n" . join(
"</li>\n<li class='choix'>",
$tables
@ -85,14 +85,15 @@ function formulaires_restaurer_verifier_dist() {
}
}
if ($nom
if (
$nom
and (!count($erreurs) or (count($erreurs) == 1 and isset($erreurs['tables'])))
) {
if (_request('confirm') !== $nom) {
$erreurs['message_confirm'] =
_T(
'dump:info_selection_sauvegarde',
array('fichier' => '<i>' . joli_repertoire(dump_repertoire() . $nom) . '</i>')
['fichier' => '<i>' . joli_repertoire(dump_repertoire() . $nom) . '</i>']
)
. "<br /><input type='checkbox' name='confirm' value='$nom' id='confirm' /> ";
$erreurs['message_confirm'] .= "<label for='confirm'><strong>";
@ -136,7 +137,7 @@ function formulaires_restaurer_traiter_dist() {
}
include_spip('inc/dump');
$res = dump_init($status_file, $archive, $tables, array('spip_meta' => "impt='oui'"));
$res = dump_init($status_file, $archive, $tables, ['spip_meta' => "impt='oui'"]);
if ($res === true) {
// on lance l'action restaurer qui va realiser la sauvegarde
@ -144,8 +145,8 @@ function formulaires_restaurer_traiter_dist() {
include_spip('inc/actions');
$redirect = generer_action_auteur('restaurer', $status_file);
return array('message_ok' => 'ok', 'redirect' => $redirect);
return ['message_ok' => 'ok', 'redirect' => $redirect];
} else {
return array('message_erreur' => $res);
return ['message_erreur' => $res];
}
}

15
formulaires/sauvegarder.php

@ -35,7 +35,7 @@ function formulaires_sauvegarder_charger_dist() {
list($tables, ) = base_liste_table_for_dump($exclude);
$tables = base_lister_toutes_tables('', $tables);
$valeurs = array(
$valeurs = [
'_dir_dump' => joli_repertoire($dir_dump),
'_dir_img' => joli_repertoire(_DIR_IMG),
'_spipnet' => $GLOBALS['home_server'] . '/' . $GLOBALS['spip_lang'] . '_article1489.html',
@ -47,11 +47,11 @@ function formulaires_sauvegarder_charger_dist() {
'tables',
$tables,
$exclude,
_request('nom_sauvegarde') ? (_request('tables') ? _request('tables') : array()) : null
_request('nom_sauvegarde') ? (_request('tables') ? _request('tables') : []) : null
)
) . "</li></ol>\n",
'_prefixe' => base_prefixe_tables(''),
);
];
return $valeurs;
}
@ -62,10 +62,11 @@ function formulaires_sauvegarder_charger_dist() {
* @return array
*/
function formulaires_sauvegarder_verifier_dist() {
$erreurs = array();
$erreurs = [];
if (!$nom = _request('nom_sauvegarde')) {
$erreurs['nom_sauvegarde'] = _T('info_obligatoire');
} elseif (!preg_match(',^[\w_][\w_.]*$,', $nom)
} elseif (
!preg_match(',^[\w_][\w_.]*$,', $nom)
or basename($nom) !== $nom
) {
$erreurs['nom_sauvegarde'] = _T('dump:erreur_nom_fichier');
@ -103,8 +104,8 @@ function formulaires_sauvegarder_traiter_dist() {
include_spip('inc/actions');
$redirect = generer_action_auteur('sauvegarder', $status_file);
return array('message_ok' => 'ok', 'redirect' => $redirect);
return ['message_ok' => 'ok', 'redirect' => $redirect];
} else {
return array('message_erreur' => $res);
return ['message_erreur' => $res];
}
}

58
inc/dump.php

@ -32,7 +32,8 @@ if (!defined('_ECRIRE_INC_VERSION')) {
*/
function dump_repertoire() {
$repertoire = _DIR_DUMP;
if (!@file_exists($repertoire)
if (
!@file_exists($repertoire)
and !$repertoire = sous_repertoire(_DIR_DUMP, '', false, true)
) {
$repertoire = preg_replace(',' . _DIR_TMP . ',', '', _DIR_DUMP);
@ -58,7 +59,7 @@ function dump_nom_fichier($dir, $extension = 'sqlite') {
if (isset($GLOBALS['meta']['nom_site'])) {
$site = typo($GLOBALS['meta']['nom_site']); // extraire_multi
$site = couper(translitteration(trim($site)), 30, '');
$site = preg_replace(array(',\W,is', ',_(?=_),', ',_$,'), array('_', '', ''), $site);
$site = preg_replace([',\W,is', ',_(?=_),', ',_$,'], ['_', '', ''], $site);
}
$site .= '_' . date('Ymd');
@ -85,11 +86,13 @@ function dump_type_serveur() {
if (function_exists('spip_versions_sqlite3') and spip_versions_sqlite3()) {
return 'sqlite3';
}
if (function_exists('spip_versions_sqlite3')) {
spip_log("ERREUR sqlite3 n'est pas correctement installé : "
."extension_loaded('pdo')=".extension_loaded('pdo')
." extension_loaded('pdo_sqlite')=".extension_loaded('pdo_sqlite'),
_LOG_ERREUR);
if (function_exists('spip_versions_sqlite3')) {
spip_log(
"ERREUR sqlite3 n'est pas correctement installé : "
. "extension_loaded('pdo')=" . extension_loaded('pdo')
. " extension_loaded('pdo_sqlite')=" . extension_loaded('pdo_sqlite'),
_LOG_ERREUR
);
}
return '';
@ -119,7 +122,7 @@ function dump_connect_args($archive) {
return null;
}
return array(dirname($archive), '', '', '', basename($archive, '.sqlite'), $type_serveur, 'spip');
return [dirname($archive), '', '', '', basename($archive, '.sqlite'), $type_serveur, 'spip'];
}
/**
@ -132,10 +135,11 @@ function dump_connect_args($archive) {
* @param string $action Pour differencier la sauvegarde de l'import
* @return bool/string
*/
function dump_init($status_file, $archive, $tables = null, $where = array(), $action = 'sauvegarde') {
function dump_init($status_file, $archive, $tables = null, $where = [], $action = 'sauvegarde') {
$status_file = _DIR_TMP . basename($status_file) . '.txt';
if (lire_fichier($status_file, $status)
if (
lire_fichier($status_file, $status)
and $status = unserialize($status)
and $status['etape'] !== 'fini'
and filemtime($status_file) >= time() - 120
@ -151,7 +155,7 @@ function dump_init($status_file, $archive, $tables = null, $where = array(), $ac
if (!$tables) {
list($tables, ) = base_liste_table_for_dump(lister_tables_noexport());
}
$status = array('tables' => $tables, 'where' => $where, 'archive' => $archive);
$status = ['tables' => $tables, 'where' => $where, 'archive' => $archive];
$status['connect'] = dump_connect_args($archive);
dump_serveur($status['connect']);
@ -162,13 +166,13 @@ function dump_init($status_file, $archive, $tables = null, $where = array(), $ac
// la constante sert a verifier qu'on utilise bien le connect/dump du plugin,
// et pas une base externe homonyme
if (!defined('_DUMP_SERVEUR_OK')) {
return _T('erreur_connect_dump', array('dump' => 'dump'));
return _T('erreur_connect_dump', ['dump' => 'dump']);
}
$status['etape'] = 'init';
if (!ecrire_fichier($status_file, serialize($status))) {
return _T('dump:avis_probleme_ecriture_fichier', array('fichier' => $status_file));
return _T('dump:avis_probleme_ecriture_fichier', ['fichier' => $status_file]);
}
return true;
@ -225,7 +229,8 @@ function dump_relance($redirect) {
*/
function dump_end($status_file, $action = '') {
$status_file = _DIR_TMP . basename($status_file) . '.txt';
if (!lire_fichier($status_file, $status)
if (
!lire_fichier($status_file, $status)
or !$status = unserialize($status)
) {
return;
@ -238,7 +243,7 @@ function dump_end($status_file, $action = '') {
break;
case 'sauvegarder':
// stocker dans le dump la structure de la base source
$structure = array();
$structure = [];
foreach ($status['tables_copiees'] as $t => $n) {
$structure[$t] = sql_showtable($t, true);
}
@ -252,8 +257,8 @@ function dump_end($status_file, $action = '') {
sql_delete('spip_meta', "nom='dump_structure_temp'", 'dump'); #enlever une vieille structure deja la, au cas ou
sql_insertq(
'spip_meta',
array('nom' => 'dump_structure_temp', 'valeur' => serialize($structure), 'impt' => 'non'),
array(),
['nom' => 'dump_structure_temp', 'valeur' => serialize($structure), 'impt' => 'non'],
[],
'dump'
);
break;
@ -277,12 +282,12 @@ function dump_lister_sauvegardes($dir, $tri = 'nom', $extension = 'sqlite', $lim
$liste_dump = preg_files($dir, '\.' . $extension . '$', $limit, false);
$n = strlen($dir);
$tn = $tl = $tt = $td = array();
$tn = $tl = $tt = $td = [];
foreach ($liste_dump as $fichier) {
$d = filemtime($fichier);
$t = filesize($fichier);
$fichier = substr($fichier, $n);
$tl[] = array('fichier' => $fichier, 'taille' => $t, 'date' => $d);
$tl[] = ['fichier' => $fichier, 'taille' => $t, 'date' => $d];
$td[] = $d;
$tt[] = $t;
$tn[] = $fichier;
@ -306,7 +311,8 @@ function dump_lister_sauvegardes($dir, $tri = 'nom', $extension = 'sqlite', $lim
*/
function dump_lire_status($status_file) {
$status_file = _DIR_TMP . basename($status_file) . '.txt';
if (!lire_fichier($status_file, $status)
if (
!lire_fichier($status_file, $status)
or !$status = unserialize($status)
) {
return '';
@ -322,7 +328,8 @@ function dump_lire_status($status_file) {
* @return string Chaine non vide s'il reste des choses a faire
*/
function dump_verifie_sauvegarde_finie($status_file) {
if (!$status = dump_lire_status($status_file)
if (
!$status = dump_lire_status($status_file)
or $status['etape'] !== 'fini'
) {
return '';
@ -338,7 +345,8 @@ function dump_verifie_sauvegarde_finie($status_file) {
* @return string Nom ou chaine vide si on a un probleme
*/
function dump_nom_sauvegarde($status_file) {
if (!$status = dump_lire_status($status_file)
if (
!$status = dump_lire_status($status_file)
or !file_exists($f = $status['archive'] . '.sqlite')
) {
return '';
@ -354,7 +362,8 @@ function dump_nom_sauvegarde($status_file) {
* @return string/int Taille ou Chaine vide en cas de probleme
*/
function dump_taille_sauvegarde($status_file) {
if (!$f = dump_nom_sauvegarde($status_file)
if (
!$f = dump_nom_sauvegarde($status_file)
or !$s = filesize($f)
) {
return '';
@ -370,7 +379,8 @@ function dump_taille_sauvegarde($status_file) {
* @return string/int Date ou Chaine vide en cas de probleme
*/
function dump_date_sauvegarde($status_file) {
if (!$f = dump_nom_sauvegarde($status_file)
if (
!$f = dump_nom_sauvegarde($status_file)
or !$d = filemtime($f)
) {
return '';

9
inc/sauvegarder.php

@ -26,7 +26,8 @@ include_spip('inc/dump');
*/
function inc_sauvegarder_dist($status_file, $redirect = '') {
$status_file = _DIR_TMP . basename($status_file) . '.txt';
if (!lire_fichier($status_file, $status)
if (
!lire_fichier($status_file, $status)
or !$status = unserialize($status)
) {
} else {
@ -54,12 +55,12 @@ function inc_sauvegarder_dist($status_file, $redirect = '') {
// au premier coup on ne fait rien sauf afficher l'ecran de sauvegarde
$res = false;
if (_request('step')) {
$options = array(
$options = [
'callback_progression' => 'dump_afficher_progres',
'max_time' => $max_time,
'no_erase_dest' => lister_tables_noerase(),
'where' => $status['where'] ? $status['where'] : array(),
);
'where' => $status['where'] ? $status['where'] : [],
];
$res = base_copier_tables($status_file, $status['tables'], '', 'dump', $options);
}

14
phpcs.xml.dist

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<ruleset>
<file>.</file>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>lang/*</exclude-pattern>
<rule ref="SPIP41"/>
<config name="ignore_warnings_on_exit" value="1"/>
<arg name="cache" value=".php_cs.cache"/>
<arg name="report-full" value=".php_cs.txt"/>
<arg name="report-summary"/>
<arg value="s"/>
</ruleset>

567
phpstan-baseline.neon

@ -0,0 +1,567 @@
parameters:
ignoreErrors:
-
message: "#^Function _T not found\\.$#"
count: 1
path: action/restaurer.php
-
message: "#^Function charger_fonction not found\\.$#"
count: 2
path: action/restaurer.php
-
message: "#^Function generer_url_ecrire not found\\.$#"
count: 1
path: action/restaurer.php
-
message: "#^Function include_spip not found\\.$#"
count: 3
path: action/restaurer.php
-
message: "#^Function joli_repertoire not found\\.$#"
count: 1
path: action/restaurer.php
-
message: "#^Function lire_fichier not found\\.$#"
count: 1
path: action/restaurer.php
-
message: "#^Function redirige_formulaire not found\\.$#"
count: 1
path: action/restaurer.php
-
message: "#^Function utiliser_langue_visiteur not found\\.$#"
count: 1
path: action/restaurer.php
-
message: "#^Undefined variable\\: \\$status$#"
count: 2
path: action/restaurer.php
-
message: "#^Function _request not found\\.$#"
count: 1
path: action/sauvegarder.php
-
message: "#^Function charger_fonction not found\\.$#"
count: 2
path: action/sauvegarder.php
-
message: "#^Function generer_action_auteur not found\\.$#"
count: 1
path: action/sauvegarder.php
-
message: "#^Function generer_url_ecrire not found\\.$#"
count: 1
path: action/sauvegarder.php
-
message: "#^Function include_spip not found\\.$#"
count: 3
path: action/sauvegarder.php
-
message: "#^Function parametre_url not found\\.$#"
count: 1
path: action/sauvegarder.php
-
message: "#^Function redirige_formulaire not found\\.$#"
count: 1
path: action/sauvegarder.php
-
message: "#^Function utiliser_langue_visiteur not found\\.$#"
count: 1
path: action/sauvegarder.php
-
message: "#^Function autoriser not found\\.$#"
count: 1
path: action/supprimer_dump.php
-
message: "#^Function charger_fonction not found\\.$#"
count: 1
path: action/supprimer_dump.php
-
message: "#^Function include_spip not found\\.$#"
count: 3
path: action/supprimer_dump.php
-
message: "#^Function spip_unlink not found\\.$#"
count: 1
path: action/supprimer_dump.php
-
message: "#^Function _T not found\\.$#"
count: 2
path: action/telecharger_dump.php
-
message: "#^Function autoriser not found\\.$#"
count: 1
path: action/telecharger_dump.php
-
message: "#^Function charger_fonction not found\\.$#"
count: 1
path: action/telecharger_dump.php
-
message: "#^Function http_status not found\\.$#"
count: 1
path: action/telecharger_dump.php
-
message: "#^Function include_spip not found\\.$#"
count: 3
path: action/telecharger_dump.php
-
message: "#^Function minipres not found\\.$#"
count: 1
path: action/telecharger_dump.php
-
message: "#^Function _T not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function _request not found\\.$#"
count: 2
path: base/restaurer.php
-
message: "#^Function base_copier_tables not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function chemin_image not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function chercher_filtre not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function generer_action_auteur not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function generer_url_ecrire not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function http_script not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function include_spip not found\\.$#"
count: 4
path: base/restaurer.php
-
message: "#^Function install_debut_html not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function install_fin_html not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function lire_fichier not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function lister_tables_noerase not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function parametre_url not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function redirige_formulaire not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function spip_connect not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function sql_getfetsel not found\\.$#"
count: 1
path: base/restaurer.php
-
message: "#^Function sql_updateq not found\\.$#"
count: 2
path: base/restaurer.php
-
message: "#^Undefined variable\\: \\$status$#"
count: 2
path: base/restaurer.php
-
message: "#^Function include_spip not found\\.$#"
count: 1
path: connect/dump.php
-
message: "#^Function autoriser not found\\.$#"
count: 1
path: dump_autoriser.php
-
message: "#^Function base_dump_meta_name not found\\.$#"
count: 1
path: exec/base_restaurer.php
-
message: "#^Function charger_fonction not found\\.$#"
count: 1
path: exec/base_restaurer.php
-
message: "#^Function include_spip not found\\.$#"
count: 1
path: exec/base_restaurer.php
-
message: "#^Function include_spip not found\\.$#"
count: 1
path: formulaires/inc-lister-sauvegardes_fonctions.php
-
message: "#^Function _T not found\\.$#"
count: 9
path: formulaires/restaurer.php
-
message: "#^Function _request not found\\.$#"
count: 19
path: formulaires/restaurer.php
-
message: "#^Function base_dump_meta_name not found\\.$#"
count: 1
path: formulaires/restaurer.php
-
message: "#^Function base_lister_toutes_tables not found\\.$#"
count: 2
path: formulaires/restaurer.php
-
message: "#^Function base_saisie_tables not found\\.$#"
count: 1
path: formulaires/restaurer.php
-
message: "#^Function generer_action_auteur not found\\.$#"
count: 1
path: formulaires/restaurer.php
-
message: "#^Function include_spip not found\\.$#"
count: 4
path: formulaires/restaurer.php
-
message: "#^Function joli_repertoire not found\\.$#"
count: 1
path: formulaires/restaurer.php
-
message: "#^Function _T not found\\.$#"
count: 2
path: formulaires/sauvegarder.php
-
message: "#^Function _request not found\\.$#"
count: 9
path: formulaires/sauvegarder.php
-
message: "#^Function base_dump_meta_name not found\\.$#"
count: 1
path: formulaires/sauvegarder.php
-
message: "#^Function base_liste_table_for_dump not found\\.$#"
count: 2
path: formulaires/sauvegarder.php
-
message: "#^Function base_lister_toutes_tables not found\\.$#"
count: 2
path: formulaires/sauvegarder.php
-
message: "#^Function base_prefixe_tables not found\\.$#"
count: 1
path: formulaires/sauvegarder.php
-
message: "#^Function base_saisie_tables not found\\.$#"
count: 1
path: formulaires/sauvegarder.php
-
message: "#^Function generer_action_auteur not found\\.$#"
count: 1
path: formulaires/sauvegarder.php
-
message: "#^Function include_spip not found\\.$#"
count: 4
path: formulaires/sauvegarder.php
-
message: "#^Function joli_repertoire not found\\.$#"
count: 2
path: formulaires/sauvegarder.php
-
message: "#^Function lister_tables_noexport not found\\.$#"
count: 2
path: formulaires/sauvegarder.php
-
message: "#^Function _T not found\\.$#"
count: 5
path: inc/dump.php
-
message: "#^Function base_liste_table_for_dump not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function couper not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function ecrire_fichier not found\\.$#"
count: 2
path: inc/dump.php
-
message: "#^Function include_spip not found\\.$#"
count: 2
path: inc/dump.php
-
message: "#^Function lire_fichier not found\\.$#"
count: 3
path: inc/dump.php
-
message: "#^Function lister_tables_noexport not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function preg_files not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function sous_repertoire not found\\.$#"
count: 2
path: inc/dump.php
-
message: "#^Function spip_connect not found\\.$#"
count: 2
path: inc/dump.php
-
message: "#^Function spip_log not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function spip_versions_sqlite3 not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function sql_create not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function sql_delete not found\\.$#"
count: 2
path: inc/dump.php
-
message: "#^Function sql_insertq not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function sql_showtable not found\\.$#"
count: 3
path: inc/dump.php
-
message: "#^Function translitteration not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function typo not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Function unique not found\\.$#"
count: 1
path: inc/dump.php
-
message: "#^Undefined variable\\: \\$status$#"
count: 6
path: inc/dump.php
-
message: "#^Function _T not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function _request not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function base_copier_tables not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function chemin_image not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function chercher_filtre not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function http_script not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function inc_sauvegarder_dist\\(\\) should return bool but return statement is missing\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function include_spip not found\\.$#"
count: 2
path: inc/sauvegarder.php
-
message: "#^Function install_debut_html not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function install_fin_html not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function lire_fichier not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function lister_tables_noerase not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Function spip_connect not found\\.$#"
count: 1
path: inc/sauvegarder.php
-
message: "#^Undefined variable\\: \\$status$#"
count: 2
path: inc/sauvegarder.php
-
message: "#^Function _T not found\\.$#"
count: 3
path: prive/squelettes/contenu/restaurer_fonctions.php
-
message: "#^Function include_spip not found\\.$#"
count: 1
path: prive/squelettes/contenu/restaurer_fonctions.php
-
message: "#^Function sql_countsel not found\\.$#"
count: 1
path: prive/squelettes/contenu/restaurer_fonctions.php
-
message: "#^Function sql_showtable not found\\.$#"
count: 1
path: prive/squelettes/contenu/restaurer_fonctions.php
-
message: "#^Function _T not found\\.$#"
count: 1
path: prive/squelettes/contenu/sauvegarder_fonctions.php
-
message: "#^Function include_spip not found\\.$#"
count: 1
path: prive/squelettes/contenu/sauvegarder_fonctions.php
-
message: "#^Function spip_connect not found\\.$#"
count: 1
path: prive/squelettes/contenu/sauvegarder_fonctions.php
-
message: "#^Function sql_countsel not found\\.$#"
count: 1
path: prive/squelettes/contenu/sauvegarder_fonctions.php

11
phpstan.neon.dist

@ -0,0 +1,11 @@
includes:
- phpstan-baseline.neon
parameters:
paths:
- .
excludePaths:
analyseAndScan:
- vendor
- lang
level: 0

6
prive/squelettes/contenu/restaurer_fonctions.php

@ -27,7 +27,7 @@ function dump_afficher_tables_restaurees_erreurs($status_file) {
$tables = $status['tables_copiees'];
$corps = '';
$erreurs = array();
$erreurs = [];
if (!$tables) {
return '<p>' . _T('dump:erreur_aucune_donnee_restauree') . '</p>';
@ -37,12 +37,12 @@ function dump_afficher_tables_restaurees_erreurs($status_file) {
// qu'on a le bon nombre de donnees
foreach ($tables as $t => $n) {
if (!sql_showtable($t, true) or $n === 0) {
$erreurs[$t] = _T('dump:erreur_table_absente', array('table' => "<strong>$t</strong>"));
$erreurs[$t] = _T('dump:erreur_table_absente', ['table' => "<strong>$t</strong>"]);
} else {
$n = abs(intval($n));
$n_dump = intval(sql_countsel($t));
if ($n_dump < $n) {
$erreurs[$t] = _T('dump:erreur_table_donnees_manquantes', array('table' => "<strong>$t</strong>"));
$erreurs[$t] = _T('dump:erreur_table_donnees_manquantes', ['table' => "<strong>$t</strong>"]);
};
}
}

2
prive/squelettes/contenu/sauvegarder_fonctions.php

@ -51,7 +51,7 @@ function dump_afficher_tables_sauvegardees($status_file) {
case 0:
break;
case 1:
$corps = "<div style='width:49%;float:left;'><ul class='spip'><li class='spip'>" .join("</li><li class='spip'>", $tables) . '</li></ul></div>';
$corps = "<div style='width:49%;float:left;'><ul class='spip'><li class='spip'>" . join("</li><li class='spip'>", $tables) . '</li></ul></div>';
break;
default:
$n = floor(count($tables) / 2);

Loading…
Cancel
Save