From 27de6106ab343bcea5ae9261a4d960ef31ba214b Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 18 Jun 2021 22:01:16 +0100 Subject: [PATCH] Adds type hinting --- src/Concerns/Expectable.php | 5 ++++- src/Concerns/RetrievesValues.php | 8 ++++---- src/Expectation.php | 9 ++++++--- src/HigherOrderExpectation.php | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Concerns/Expectable.php b/src/Concerns/Expectable.php index 371bf8d4..5087572f 100644 --- a/src/Concerns/Expectable.php +++ b/src/Concerns/Expectable.php @@ -12,9 +12,12 @@ use Pest\Expectation; trait Expectable { /** + * @template TValue + * * Creates a new expectation. * - * @param mixed $value + * @param TValue $value + * @return Expectation */ public function expect($value): Expectation { diff --git a/src/Concerns/RetrievesValues.php b/src/Concerns/RetrievesValues.php index e0c93bbc..1d789e9d 100644 --- a/src/Concerns/RetrievesValues.php +++ b/src/Concerns/RetrievesValues.php @@ -10,14 +10,14 @@ namespace Pest\Concerns; trait RetrievesValues { /** - * @template TValue + * @template TRetrievableValue * * Safely retrieve the value at the given key from an object or array. * - * @param array|object $value - * @param TValue|null $default + * @param array|object $value + * @param TRetrievableValue|null $default * - * @return TValue|null + * @return TRetrievableValue|null */ private function retrieve(string $key, $value, $default = null) { diff --git a/src/Expectation.php b/src/Expectation.php index 73b78508..d9519f00 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -16,6 +16,8 @@ use SebastianBergmann\Exporter\Exporter; /** * @internal * + * @template TValue + * * @property Expectation $not Creates the opposite expectation. * @property Each $each Creates an expectation on each element on the traversable value. */ @@ -47,7 +49,7 @@ final class Expectation /** * Creates a new expectation. * - * @param mixed $value + * @param TValue $value */ public function __construct($value) { @@ -57,7 +59,8 @@ final class Expectation /** * Creates a new expectation. * - * @param mixed $value + * @param TValue $value + * @return Expectation */ public function and($value): Expectation { @@ -722,7 +725,7 @@ final class Expectation * * @param array $parameters * - * @return mixed + * @return HigherOrderExpectation|mixed */ public function __call(string $method, array $parameters) { diff --git a/src/HigherOrderExpectation.php b/src/HigherOrderExpectation.php index d2710ecc..8d29aa3d 100644 --- a/src/HigherOrderExpectation.php +++ b/src/HigherOrderExpectation.php @@ -66,7 +66,7 @@ final class HigherOrderExpectation /** * Dynamically calls methods on the class with the given arguments. * - * @param array $arguments + * @param array $arguments */ public function __call(string $name, array $arguments): self { @@ -115,7 +115,7 @@ final class HigherOrderExpectation /** * Performs the given assertion with the current expectation. * - * @param array $arguments + * @param array $arguments */ private function performAssertion(string $name, array $arguments): self {