Skip to content

Commit

Permalink
check if pipelines is array and not empty and items is implemented Pi…
Browse files Browse the repository at this point in the history
…peline contract
  • Loading branch information
salahhusa9 committed Oct 22, 2023
1 parent 16c0571 commit 783de73
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ private function updateTo($version): string
$pipelines[] = config('updater.after_update_pipelines');
}

foreach ($pipelines as $key => $pipeline) {
if (! is_object($pipeline) && ($pipeline instanceof \Salahhusa9\Updater\Contracts\Pipeline)) {
unset($pipelines[$key]);
} else {
throw new \Exception('Pipeline must be implement \Salahhusa9\Updater\Contracts\Pipeline');
}
// check if pipelines is array and not empty and items is implemented Pipeline contract
if (is_array($pipelines) && count($pipelines) > 0 && array_reduce($pipelines, function ($carry, $item) {

Check failure on line 77 in src/Updater.php

View workflow job for this annotation

GitHub Actions / phpstan

Comparison operation ">" between int<1, 10> and 0 is always true.

Check failure on line 77 in src/Updater.php

View workflow job for this annotation

GitHub Actions / phpstan

Result of && is always true.
return $carry && in_array(Pipeline::class, class_implements($item));
}, true)) {
$pipelines = array_map(function ($item) {
return new $item();
}, $pipelines);
} else {
throw new \Exception('Pipelines is not array or empty or not implemented Pipeline contract');
}

Pipeline::send([
Expand Down

0 comments on commit 783de73

Please sign in to comment.