From 0ba16bc495f5ecab91d71f5fe23f279acba1eb7a Mon Sep 17 00:00:00 2001 From: JamesRezo Date: Tue, 8 Mar 2022 20:03:35 +0100 Subject: [PATCH] fix d'erreurs phpstan --- src/AbstractArchiver.php | 15 +++++++++------ src/ArchiveInterface.php | 8 +++++--- src/ArchiverInterface.php | 1 - src/TarArchive.php | 2 +- src/ZipArchive.php | 6 +++--- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/AbstractArchiver.php b/src/AbstractArchiver.php index a24b28f..8a1dee1 100644 --- a/src/AbstractArchiver.php +++ b/src/AbstractArchiver.php @@ -47,7 +47,7 @@ abstract class AbstractArchiver implements ArchiverInterface 8 => 'tentative_de_vidage_du_fichier', ]; - /** @var array liste des fichiers à exclure de l'archive */ + /** @var string[] liste des fichiers à exclure de l'archive */ protected array $fichiers_ignores = ['.ok']; /** @@ -140,6 +140,7 @@ abstract class AbstractArchiver implements ArchiverInterface */ protected function mimeType(): string { $file_mime_type = ''; + $file_mime_type_raw = ''; if (file_exists($this->fichier_archive)) { $finfo = finfo_open(\FILEINFO_MIME); @@ -305,6 +306,12 @@ abstract class AbstractArchiver implements ArchiverInterface return $racine; } + /** + * Scanner les dossiers. + * + * @param string[] $chemins + * @return string[] + */ protected function listerFichiers(array $chemins): array { $fichiers = []; @@ -315,11 +322,7 @@ abstract class AbstractArchiver implements ArchiverInterface new RecursiveDirectoryIterator($chemin, FilesystemIterator::SKIP_DOTS), ), function ($current, $key, $iterator) { - if (in_array($current->getFilename(), $this->fichiers_ignores)) { - return false; - } - - return true; + return !in_array($current->getFilename(), $this->fichiers_ignores); } ); foreach ($iterateur_dossier as $fichier) { diff --git a/src/ArchiveInterface.php b/src/ArchiveInterface.php index d3071fb..e120eb0 100644 --- a/src/ArchiveInterface.php +++ b/src/ArchiveInterface.php @@ -52,12 +52,14 @@ interface ArchiveInterface public function close(): bool; /** - * Associer un commentaire à l'archive + * Associer un commentaire à l'archive. */ - public function setComment(string $meta): bool; + public function setComment(string $comment): bool; /** - * Lire le commentaire associé à l'archive si il existe + * Lire le commentaire associé à l'archive si il existe. + * + * @return string */ public function getComment(); } diff --git a/src/ArchiverInterface.php b/src/ArchiverInterface.php index a2b37c7..2de01d3 100644 --- a/src/ArchiverInterface.php +++ b/src/ArchiverInterface.php @@ -50,7 +50,6 @@ interface ArchiverInterface * * @param array $fichiers Liste des fichiers à ajouter ou modifier * @param string|null $racine Repertoire racine des fichiers a retirer du chemin lorsqu'on zip - * @param string|null $meta Commentaire à associer à l'archive * * @return bool Succès de l'opération */ diff --git a/src/TarArchive.php b/src/TarArchive.php index 01f9c14..e6fd642 100644 --- a/src/TarArchive.php +++ b/src/TarArchive.php @@ -103,7 +103,7 @@ class TarArchive implements ArchiveInterface /** * {@inheritDoc} */ - public function setComment(string $meta): bool { + public function setComment(string $comment): bool { return true; } diff --git a/src/ZipArchive.php b/src/ZipArchive.php index 886930c..66d2877 100644 --- a/src/ZipArchive.php +++ b/src/ZipArchive.php @@ -93,14 +93,14 @@ class ZipArchive implements ArchiveInterface /** * {@inheritDoc} */ - public function setComment(string $text): bool { - return $this->zip->setArchiveComment($text); + public function setComment(string $comment): bool { + return $this->zip->setArchiveComment($comment); } /** * {@inheritDoc} */ public function getComment() { - return $this->zip->getArchiveComment(); + return $this->zip->getArchiveComment() ?: ''; } }