diff --git a/src/Concerns/AsObject.php b/src/Concerns/AsObject.php index 9108ad6..ce46fa7 100644 --- a/src/Concerns/AsObject.php +++ b/src/Concerns/AsObject.php @@ -6,6 +6,9 @@ trait AsObject { + /** + * @return static + */ public static function make() { return app(static::class); diff --git a/tests/AsActionTest.php b/tests/AsActionTest.php index 73258a3..ecd3551 100644 --- a/tests/AsActionTest.php +++ b/tests/AsActionTest.php @@ -85,11 +85,15 @@ public function asCommand(Command $command): void expect(AsActionTest::$latestResult)->toBe(42); }); -it('returns void when calling make()', function () { - // Make sure that the static function ::make() returns not a type. - $result = (new \ReflectionMethod(AsActionTest::class, 'make'))->getReturnType(); +it('uses a comment instead of a return type on make()', function () { + // Make sure that the static function ::make() does not have a return type. + $reflectionMethod = new \ReflectionMethod(AsActionTest::class, 'make'); - expect($result)->toBeEmpty(); + $returnType = $reflectionMethod->getReturnType(); + $docComment = $reflectionMethod->getDocComment(); + + expect($returnType)->toBeEmpty(); + expect($docComment)->toContain('@return static'); }); it('runs as a controller', function () {