From 49619ff2b532294d938e8feb8d1af395196307f5 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 17 Feb 2023 21:02:07 +0000 Subject: [PATCH] feat: improves DX on auto-complete --- overrides/Runner/TestSuiteLoader.php | 3 +-- phpstan.neon | 1 + src/Functions.php | 6 +++--- src/PendingCalls/TestCall.php | 3 ++- src/Support/HigherOrderTapProxy.php | 4 ---- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/overrides/Runner/TestSuiteLoader.php b/overrides/Runner/TestSuiteLoader.php index 055ace22..efc50b04 100644 --- a/overrides/Runner/TestSuiteLoader.php +++ b/overrides/Runner/TestSuiteLoader.php @@ -40,8 +40,8 @@ use function array_diff; use function array_values; use function basename; use function class_exists; -use function get_declared_classes; use Exception; +use function get_declared_classes; use Pest\Contracts\HasPrintableTestCaseName; use Pest\TestCases\IgnorableTestCase; use Pest\TestSuite; @@ -108,7 +108,6 @@ final class TestSuiteLoader if ( is_subclass_of($loadedClass, HasPrintableTestCaseName::class) || is_subclass_of($loadedClass, TestCase::class)) { - try { $class = new ReflectionClass($loadedClass); // @codeCoverageIgnoreStart diff --git a/phpstan.neon b/phpstan.neon index a75d68cc..15f9f39c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -14,6 +14,7 @@ parameters: ignoreErrors: - "#Language construct isset\\(\\) should not be used.#" - "#is not allowed to extend#" + - "#is concrete, but does not have a Test suffix#" - "#with a nullable type declaration#" - "#type mixed is not subtype of native#" - "# with null as default value#" diff --git a/src/Functions.php b/src/Functions.php index fd341fad..42d8c964 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -88,7 +88,7 @@ if (! function_exists('test')) { * is the test description; the second argument is * a closure that contains the test expectations. * - * @return HigherOrderTapProxy|TestCall|mixed + * @return TestCall|TestCase|mixed */ function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall { @@ -108,7 +108,7 @@ if (! function_exists('it')) { * is the test description; the second argument is * a closure that contains the test expectations. * - * @return HigherOrderTapProxy|TestCall|mixed + * @return TestCall|TestCase|mixed */ function it(string $description, Closure $closure = null): TestCall { @@ -127,7 +127,7 @@ if (! function_exists('todo')) { * is marked as incomplete. Yet, Collision, Pest's * printer, will display it as a "todo" test. * - * @return HigherOrderTapProxy|TestCall|mixed + * @return TestCall|TestCase|mixed */ function todo(string $description): TestCall { diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 430e632d..c793ef17 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -15,11 +15,12 @@ use Pest\Support\Exporter; use Pest\Support\HigherOrderCallables; use Pest\Support\NullClosure; use Pest\TestSuite; +use PHPUnit\Framework\TestCase; /** * @internal * - * @mixin HigherOrderCallables + * @mixin HigherOrderCallables|TestCase */ final class TestCall { diff --git a/src/Support/HigherOrderTapProxy.php b/src/Support/HigherOrderTapProxy.php index 6a4f8ecd..1b5f12cf 100644 --- a/src/Support/HigherOrderTapProxy.php +++ b/src/Support/HigherOrderTapProxy.php @@ -10,10 +10,6 @@ use Throwable; /** * @internal - * - * @template TProxy - * - * @mixin TProxy */ final class HigherOrderTapProxy {