From e1e926076af9e2792efdfb53dcbe708ed0527755 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 14 Dec 2022 14:56:11 +0000 Subject: [PATCH] fix: types on arch expectations --- src/Expectation.php | 13 ++++--------- src/Expectations/OppositeExpectation.php | 12 +++++++----- src/Mixins/Expectation.php | 4 ---- src/Repositories/DatasetsRepository.php | 3 +-- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index 21e2ee0e..2277d95a 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -290,15 +290,11 @@ final class Expectation return new HigherOrderExpectation($this, call_user_func_array($this->value->$method(...), $parameters)); } - $result = ExpectationPipeline::for($this->getExpectationClosure($method)) + ExpectationPipeline::for($this->getExpectationClosure($method)) ->send(...$parameters) ->through($this->pipes($method, $this, Expectation::class)) ->run(); - if ($result !== null) { - return $result; - } - return $this; } @@ -363,7 +359,7 @@ final class Expectation * Asserts that the layer depends (not exclusively) on the given layers. * * @param array|string $targets - * @return ArchExpectation + * @return ArchExpectation */ public function toDependOn(array|string $targets): ArchExpectation { @@ -374,7 +370,7 @@ final class Expectation * Asserts that the layer only depends on the given layers. * * @param array|string $targets - * @return ArchExpectation + * @return ArchExpectation */ public function toOnlyDependOn(array|string $targets): ArchExpectation { @@ -384,8 +380,7 @@ final class Expectation /** * Asserts that the layer is not allowed to depend on any other layer. * - * @param array|string $targets - * @return ArchExpectation + * @return ArchExpectation */ public function toDependOnNothing(): ArchExpectation { diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index 4780a8a2..a59b13b1 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -60,7 +60,7 @@ final class OppositeExpectation * Asserts that the layer does not depend on the given layers. * * @param array|string $targets - * @return ArchExpectation + * @return ArchExpectation */ public function toDependOn(array|string $targets): ArchExpectation { @@ -73,7 +73,7 @@ final class OppositeExpectation * Asserts that the layer does not only depends on the given layers. * * @param array|string $targets - * @return ArchExpectation + * @return ArchExpectation */ public function toOnlyDependOn(array|string $targets): ArchExpectation { @@ -85,7 +85,7 @@ final class OppositeExpectation /** * Asserts that the layer is depends on at least one layer. * - * @return ArchExpectation + * @return ArchExpectation */ public function toDependOnNothing(): ArchExpectation { @@ -131,10 +131,12 @@ final class OppositeExpectation /** * Creates a new expectation failed exception with a nice readable message. * - * @param array $arguments + * @param array|string $arguments */ - public function throwExpectationFailedException(string $name, array $arguments = []): never + public function throwExpectationFailedException(string $name, array|string $arguments = []): never { + $arguments = is_array($arguments) ? $arguments : [$arguments]; + $exporter = new Exporter(); $toString = fn ($argument): string => $exporter->shortenedExport($argument); diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 3c444591..886ffab2 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -8,10 +8,6 @@ use BadMethodCallException; use Closure; use Error; use InvalidArgumentException; -use Pest\Arch\ArchExpectation; -use Pest\Arch\Expectations\ToDependOn; -use Pest\Arch\Expectations\ToDependOnNothing; -use Pest\Arch\Expectations\ToOnlyDependOn; use Pest\Exceptions\InvalidExpectationValue; use Pest\Matchers\Any; use Pest\Support\Arr; diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index 83eddac2..47f710ef 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -158,11 +158,10 @@ final class DatasetsRepository $datasets[$index] = iterator_to_array($datasets[$index], false); } - // @phpstan-ignore-next-line foreach ($datasets[$index] as $key => $values) { $values = is_array($values) ? $values : [$values]; $processedDataset[] = [ - 'label' => self::getDatasetDescription($key, $values), // @phpstan-ignore-line + 'label' => self::getDatasetDescription($key, $values), 'values' => $values, ]; }