Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully support Request::validate method in IDE #22474

Closed
denirun opened this issue Dec 19, 2017 · 7 comments
Closed

Fully support Request::validate method in IDE #22474

denirun opened this issue Dec 19, 2017 · 7 comments

Comments

@denirun
Copy link

denirun commented Dec 19, 2017

  • Laravel Version: 5.5.26
  • PHP Version: 7.1.11
  • Database Driver & Version: -

Description:

IDE not fully support Illuminate\Http\Request::validate autocomplete for object instances.

Steps To Reproduce:

When you using barryvdh/laravel-ide-helper library, and try call \Request::validate() all works perfectly.

When you have instance of Illuminate\Http\Request class and try to call method validate IDE don't see implementation of this method.

Can you please fix this annoying small problem.

public function index(\Illuminate\Http\Request $request): View
{
       // All good
      \Request::validate();

       // Method 'validate' not found
	$request->validate([
	    'name' => 'required',
	]);
}
@LKaemmerling
Copy link

This should go to barryvdh/laravel-ide-helper's repository and isn't an issue from laravel itself.

@denirun
Copy link
Author

denirun commented Dec 21, 2017

No! You are not right! If you write like this

$request = new \Illuminate\Http\Request();
$request->validate();

Does your IDE see method validate() ?
Strange but my not, also i checked this class, and all traits and there is no implementation of validate method. Please add this!

@devcircus
Copy link
Contributor

'validate' is implemented as a macro on request in the core, here. FoundationServiceProvider.

Seems @LKDevelopment is correct. Don't really see another way.

@denirun
Copy link
Author

denirun commented Dec 21, 2017

Thanks @devcircus i get it now. My opinion validate it's very good syntax sugar to place inside Request class. Code much smaller and elegant. But idea to make it via macros and fully lost autocomplete with check implementation, phpdoc and e.t.c..... very controversial. I personally don't like "magical", but if no way to fix this... sad :-(

@devcircus
Copy link
Contributor

True. Still confused by this. I don't know of any other macros used in the core but I can't help but think that maybe there was a good reason for implementing it this way. Maybe worth opening an issue on the internals repo to discuss?

@rs-sliske
Copy link

#19063 (comment)

@devcircus
Copy link
Contributor

Makes sense! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants