Skip to content

Commit

Permalink
Improve type handling for better count output (#15)
Browse files Browse the repository at this point in the history
* Fix link href

* stan: improve typing

* build: upgrade ci

* stan: improve type handling
  • Loading branch information
g105b authored Sep 30, 2021
1 parent f16a6a9 commit 711ac05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Command/SyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function run(ArgumentValueList $arguments = null):void {
try {
$pattern = $arguments->get("pattern");
}
catch(ArgumentValueListNotSetException $exception) {
catch(ArgumentValueListNotSetException) {
$pattern = null;
}

Expand All @@ -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(".");
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/DirectorySync.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 711ac05

Please sign in to comment.