From 711ac05de467ec2f68835797844ae27eb4992124 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 30 Sep 2021 12:14:34 +0100 Subject: [PATCH] Improve type handling for better count output (#15) * Fix link href * stan: improve typing * build: upgrade ci * stan: improve type handling --- src/Command/SyncCommand.php | 8 ++++---- src/DirectorySync.php | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Command/SyncCommand.php b/src/Command/SyncCommand.php index 6039977..1056828 100644 --- a/src/Command/SyncCommand.php +++ b/src/Command/SyncCommand.php @@ -15,7 +15,7 @@ public function run(ArgumentValueList $arguments = null):void { try { $pattern = $arguments->get("pattern"); } - catch(ArgumentValueListNotSetException $exception) { + catch(ArgumentValueListNotSetException) { $pattern = null; } @@ -24,11 +24,11 @@ public function run(ArgumentValueList $arguments = null):void { if(!$arguments->contains("silent")) { $this->write("Copied "); - $this->write(count($sync->getCopiedFilesList())); + $this->write((string)count($sync->getCopiedFilesList())); $this->write(", skipped "); - $this->write(count($sync->getSkippedFilesList())); + $this->write((string)count($sync->getSkippedFilesList())); $this->write(", deleted "); - $this->write(count($sync->getDeletedFilesList())); + $this->write((string)count($sync->getDeletedFilesList())); $this->writeLine("."); } } diff --git a/src/DirectorySync.php b/src/DirectorySync.php index 8bdd19d..013b7f0 100644 --- a/src/DirectorySync.php +++ b/src/DirectorySync.php @@ -78,10 +78,12 @@ public function exec(int $settings = self::DEFAULT_SETTINGS):void { $destinationIterator, RecursiveIteratorIterator::CHILD_FIRST ); + foreach($iterator as $pathName => $file) { + $filename = $file->getFilename(); /** @var $file SplFileInfo */ - if($file->getFilename() === "." - || $file->getFilename() === "..") { + if($filename === "." + || $filename === "..") { continue; } @@ -104,9 +106,11 @@ public function exec(int $settings = self::DEFAULT_SETTINGS):void { $iterator = new RecursiveIteratorIterator($sourceIterator); foreach($iterator as $pathName => $file) { + $filename = $file->getFilename(); + /** @var $file SplFileInfo */ - if($file->getFilename() === "." - || $file->getFilename() === "..") { + if($filename === "." + || $filename === "..") { continue; }