square / laravel-hyrule

Object-oriented, composable, fluent API for writing validations in Laravel
Apache License 2.0
340 stars 10 forks source link

using ->end() doesn't give RootNode's typehint to the IDE #6

Closed sawirricardo closed 2 years ago

sawirricardo commented 2 years ago

since ->end() return the CompoundNode, instead of RootNode, it didn't give access to method like ->string(), ->numeric etc

Maybe we can use something like public function end(): CompoundNode|RootNode so we can have access to that method.

Thoughts?

bezhermoso commented 2 years ago

Hi @sawirricardo,

This should be taken care of via these @mixin PHPDoc directives on CompoundNode.

What IDE are you using? If you can get it to understand those, you should get them in auto-complete. Here is what it looks like in IntelliJ IDEA or PHPStorm:

Screen Shot 2022-06-14 at 10 23 58 AM
sawirricardo commented 2 years ago

Using vscode with laravel-ide-helper. maybe due to the ide-helper package? it seems vscode doesnt take the things

image
bezhermoso commented 2 years ago

I did some quick Googling and found this: https://github.com/neild3r/vscode-php-docblocker/issues/120.

I'm going to close this as I don't believe it's a Hyrule issue. Let me know if that VSCode plugin helps!

sawirricardo commented 2 years ago

@bezhermoso Oops, Actually, I've installed the docblocker ext too, but it's not working. Is it possible to simply add the return docblock to include RootNode? like this

image

that way the IDE (vscode) works

bezhermoso commented 2 years ago

Hi @sawirricardo, VSCode auto-complete should work better now: https://github.com/square/laravel-hyrule/pull/1

Screen Shot 2022-07-09 at 10 03 27 AM