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

Remove unnecessary InvalidArgumentExceptions #1069

Conversation

timoschinkel
Copy link
Contributor

@timoschinkel timoschinkel commented Oct 9, 2020

There are some locations where an object is type hinted and inside the method a check is performed to verify the type again. This is not necessary as PHP will take care of this. A consequence of this is that these methods no longer throw an instance of \Elasticsearch\Common\Exceptions\InvalidArgumentException but of \InvalidArgumentException. As theres no PHPDoc indicating that the aforementioned exception is thrown by these methods I don't see any issues with this.

I've been working with this library for a little while now and I notice discrepancies in type hints and docblocks. All of the public methods in \Elasticsearch\Client can throw exceptions, but this is not reflected in the docblocks. I did not want to make a large pull request with a lot of changes as it is an unsolicited pull request. Would you be interested in some pull requests to try and straighten that?

There are some locations where an object is type hinted and inside the method a check is performed to verify the type again. This is not necessary as PHP will take care of this. A consequence of this is that these methods no longer throw an instance of `\Elasticsearch\Common\Exceptions\InvalidArgumentException` but of `\InvalidArgumentException`. As theres no PHPDoc indicating that the aforementioned exception is thrown by these methods I dont see any issues with this.
@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@timoschinkel timoschinkel marked this pull request as ready for review October 9, 2020 08:55
@ezimuel ezimuel merged commit 2215c18 into elastic:master Dec 16, 2020
@ezimuel
Copy link
Contributor

ezimuel commented Dec 16, 2020

@timoschinkel thanks for the PR! Yes, there are some part of the code to be modified since we introduced type hint. If you find other issue please send other PRs. Thanks again.

@ezimuel
Copy link
Contributor

ezimuel commented Dec 16, 2020

Sorry @timoschinkel I just noticed that you sent the PR to master. You should work only on 7.x branch for the future, I'm rewriting master to be the next 8.0 version. Thanks.

ezimuel pushed a commit that referenced this pull request Dec 16, 2020
There are some locations where an object is type hinted and inside the method a check is performed to verify the type again. This is not necessary as PHP will take care of this. A consequence of this is that these methods no longer throw an instance of `\Elasticsearch\Common\Exceptions\InvalidArgumentException` but of `\InvalidArgumentException`. As theres no PHPDoc indicating that the aforementioned exception is thrown by these methods I dont see any issues with this.
@timoschinkel timoschinkel deleted the remove-unnecessary-invalid-argument-exceptions branch December 17, 2020 07:59
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