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

[9.x] Fix withoutVite #43826

Merged
merged 3 commits into from
Aug 23, 2022
Merged

[9.x] Fix withoutVite #43826

merged 3 commits into from
Aug 23, 2022

Conversation

iamgergo
Copy link
Contributor

This PR fixes the withoutVite method.


With the latest release some Vite methods were added, however currently they are not compatible with the withoutVite testing method.

For example in an app.blade.php:

    {{
        Vite::withEntryPoints('resources/js/app.js')
            ->useBuildDirectory('vendor/package-name/build')
            ->useHotFile(public_path('vendor/package-name/hot'))
    }}

The following error is coming up:

Error: Call to a member function useBuildDirectory() on string in ...

The methods that are returning other value type than a string for example $this must be defined. Also, the __toString is added to the anonymus class to make sure blade can render it.


I was not sure how to test it since no other tests were added to the similar fake methods.

@mabdullahsari
Copy link
Contributor

I opened the PR for the very first fix.

I think that it'd be much better if an instance of $this is returned from __call. Then the __toString() can take on the responsibility for rendering nothing in the blade views.

Thoughts?

@iamgergo
Copy link
Contributor Author

Yes, I think you are right, it's a clever solution, thanks!

So, only __call, __invoke and __toString should stay, right? __call and __invoke should return with $this and __toString with ''. It is correct?

@iamgergo
Copy link
Contributor Author

Okay, so for now, I leave it as is, because I'm not sure what side effects this refactoring would have.

Thank you!

@mabdullahsari
Copy link
Contributor

Yes, I think you are right, it's a clever solution, thanks!

So, only __call, __invoke and __toString should stay, right? __call and __invoke should return with $this and __toString with ''. It is correct?

Yup, that's correct.

@taylorotwell taylorotwell merged commit 698a891 into laravel:9.x Aug 23, 2022
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

Successfully merging this pull request may close these issues.

3 participants