Compare commits

...

4 Commits
master ... 1.0

Author SHA1 Message Date
Matthieu Marcillaud 410a437c6c Version 1.0.2 1 year ago
JamesRezo e5570084bd feat(dev-tools): Mise en place phpcs+phpstan (#4414)
Co-authored-by: JamesRezo <james@rezo.net>
Reviewed-on: #4414
Co-authored-by: JamesRezo <jamesrezo@noreply.git.spip.net>
Co-committed-by: JamesRezo <jamesrezo@noreply.git.spip.net>
(cherry picked from commit 1447fc168b)
1 year ago
Matthieu Marcillaud 1b23faf191 Version 1.0.1 2 years ago
Matthieu Marcillaud e8b1584faf Compat [4.0.0;4.0.*] 2 years ago

7
.gitignore vendored

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

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

@ -59,8 +59,8 @@ class SpipArchives
$code = in_array($this->codeErreur, array_keys($this->erreurs)) ? $this->codeErreur : 1;
$this->codeErreur = $code;
if ($this->codeErreur!==1 or !$this->messageErreur) {
$this->messageErreur = 'archives:'.$this->erreurs[$code];
if ($this->codeErreur !== 1 or !$this->messageErreur) {
$this->messageErreur = 'archives:' . $this->erreurs[$code];
}
return $code;
@ -174,9 +174,11 @@ class SpipArchives
$total = $paths[0][''];
$i = 0;
while (isset($paths[$i])
while (
isset($paths[$i])
and count($paths[$i]) <= 1
and array_values($paths[$i]) == [$total]) {
and array_values($paths[$i]) == [$total]
) {
$i++;
}
@ -225,9 +227,11 @@ class SpipArchives
$ok = $zip->extract(
PCLZIP_OPT_PATH,
$destination,
PCLZIP_OPT_SET_CHMOD, _SPIP_CHMOD,
PCLZIP_OPT_SET_CHMOD,
_SPIP_CHMOD,
PCLZIP_OPT_REPLACE_NEWER,
PCLZIP_OPT_REMOVE_PATH, $infos['proprietes']['racine']
PCLZIP_OPT_REMOVE_PATH,
$infos['proprietes']['racine']
);
if (!$ok or $zip->error_code < 0) {
$errors[] = 'deballer() erreur zip ' . $zip->error_code . ' pour paquet: ' . $this->fichierArchive;
@ -239,10 +243,13 @@ class SpipArchives
$ok = $zip->extract(
PCLZIP_OPT_PATH,
$destination,
PCLZIP_OPT_SET_CHMOD, _SPIP_CHMOD,
PCLZIP_OPT_SET_CHMOD,
_SPIP_CHMOD,
PCLZIP_OPT_REPLACE_NEWER,
PCLZIP_OPT_REMOVE_PATH, $infos['proprietes']['racine'],
PCLZIP_OPT_BY_NAME, $fichier
PCLZIP_OPT_REMOVE_PATH,
$infos['proprietes']['racine'],
PCLZIP_OPT_BY_NAME,
$fichier
);
if (!$ok or $zip->error_code < 0) {
$errors[] = "deballer() Fichier $fichier: erreur zip " . $zip->error_code . ' pour paquet: ' . $this->fichierArchive;
@ -256,15 +263,15 @@ class SpipArchives
case 'tar':
case 'tgz':
include_spip('inc/pcltar');
if (!$fichiers){
if (!$fichiers) {
$ok = PclTarExtract($this->fichierArchive, $destination, $infos['proprietes']['racine'], $this->modeCompression);
if ($ok === 0){
if ($ok === 0) {
$errors[] = 'deballer() erreur tar ' . PclErrorString() . ' pour paquet: ' . $this->fichierArchive;
}
}
else {
$ok = PclTarExtractList($this->fichierArchive, $fichiers, $destination, $infos['proprietes']['racine'], $this->modeCompression);
if ($ok === 0){
if ($ok === 0) {
$errors[] = 'deballer() erreur tar ' . PclErrorString() . ' pour paquet: ' . $this->fichierArchive;
}
}
@ -323,7 +330,7 @@ class SpipArchives
);
if (!$v_list or $zip->error_code < 0) {
$this->codeErreur = 1;
$this->messageErreur = "emballer() : Echec creation du zip " . $zip->error_code . ' pour paquet: ' . $this->fichierArchive;
$this->messageErreur = 'emballer() : Echec creation du zip ' . $zip->error_code . ' pour paquet: ' . $this->fichierArchive;
return false;
}
@ -333,13 +340,12 @@ class SpipArchives
case 'tgz':
include_spip('inc/pcltar');
$ok = PclTarCreate($this->fichierArchive, $fichiers, $this->modeCompression, "", $racine);
if ($ok === 0){
$ok = PclTarCreate($this->fichierArchive, $fichiers, $this->modeCompression, '', $racine);
if ($ok === 0) {
$this->codeErreur = 1;
$this->messageErreur = "emballer() : Echec creation du ".$this->modeCompression. " " . PclErrorString() . ' pour paquet: ' . $this->fichierArchive;
$this->messageErreur = 'emballer() : Echec creation du ' . $this->modeCompression . ' ' . PclErrorString() . ' pour paquet: ' . $this->fichierArchive;
return false;
}
}
// verifier que le fichier existe bien
@ -376,7 +382,7 @@ class SpipArchives
$ok = $zip->delete(PCLZIP_OPT_BY_NAME, $fichiers);
if (!$ok or $zip->error_code < 0) {
$this->codeErreur = 1;
$this->messageErreur = "retirer() : Echec retirer fichiers ".json_encode($fichiers). " " . $zip->error_code . ' pour paquet: ' . $this->fichierArchive;
$this->messageErreur = 'retirer() : Echec retirer fichiers ' . json_encode($fichiers) . ' ' . $zip->error_code . ' pour paquet: ' . $this->fichierArchive;
return false;
}
break;
@ -385,9 +391,9 @@ class SpipArchives
case 'tgz':
include_spip('inc/pcltar');
$ok = PclTarDelete($this->fichierArchive, $fichiers, $this->modeCompression);
if ($ok === 0){
if ($ok === 0) {
$this->codeErreur = 1;
$this->messageErreur = "retirer() : Echec retirer fichiers ".json_encode($fichiers). " " . PclErrorString() . ' pour paquet: ' . $this->fichierArchive;
$this->messageErreur = 'retirer() : Echec retirer fichiers ' . json_encode($fichiers) . ' ' . PclErrorString() . ' pour paquet: ' . $this->fichierArchive;
return false;
}

@ -1,9 +1,9 @@
<paquet
prefix="archiviste"
categorie="outil"
version="1.0.0"
version="1.0.2"
etat="stable"
compatibilite="[4.0.0-beta;4.0.*]"
compatibilite="[4.0.0;4.0.*]"
logo="prive/themes/spip/images/archiviste.svg"
documentation=""
>

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<ruleset>
<file>.</file>
<exclude-pattern>inc/pclzip.php</exclude-pattern>
<exclude-pattern>inc/pcltar.php</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>lang/*</exclude-pattern>
<exclude-pattern>lib/*</exclude-pattern>
<exclude-pattern>tests/*</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>

@ -0,0 +1,7 @@
parameters:
ignoreErrors:
-
message: "#^Function include_spip not found\\.$#"
count: 8
path: inc/archives.php

@ -0,0 +1,16 @@
includes:
- phpstan-baseline.neon
parameters:
paths:
- .
excludePaths:
analyseAndScan:
- vendor
- lang
- tests
analyse:w
- inc/pcltar.php
- inc/pclzip.php
- lib
level: 0
Loading…
Cancel
Save