scramble icon indicating copy to clipboard operation
scramble copied to clipboard

No detection of return type

Open zenire opened this issue 1 year ago • 5 comments

On my Eloquent model I've got a custom function like this:

public function userCount(): int
{
   return $this->users()->count();
}

As you can see the return type is int.

Next I've got a CompanyResource with:

[
   ...
   'userCount' => $this->userCount(),
   ...
]

I would expect Scramble to list "userCount": 0, however Scramble shows: "userCount": "string"

Scramble fails to detect and use the return type.

zenire avatar Jul 24 '24 11:07 zenire

@zenire does it work when you write it in the resource like so?

$this->resource->userCount()

romalytvynenko avatar Jul 24 '24 12:07 romalytvynenko

@zenire does it work when you write it in the resource like so?


$this->resource->userCount()

I tried, but no, same behavior.

zenire avatar Jul 24 '24 15:07 zenire

@zenire gotcha. Please help me reproduce. What's your versions, show some code, etc

romalytvynenko avatar Jul 24 '24 17:07 romalytvynenko

Version v0.11.5

Not really sure what I can share more (without sharing too much code). Return type of userCount() is int indicating it's an integer. The resource calls userCount() and the resource is returned in a controller with return new CompanyResource($company);

zenire avatar Aug 07 '24 08:08 zenire

@zenire sorry, I need a way to reproduce it. And currently I can't.

Maybe you can create a fresh repo and make a reproduction?

romalytvynenko avatar Aug 07 '24 13:08 romalytvynenko