-
-
Notifications
You must be signed in to change notification settings - Fork 598
Closes #177 - use the magic __call method for IDE completion #180
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
Conversation
Why don't you just call the api function from the __call function? |
@GrahamCampbell that's not a bad idea. I could easily add the camel cased aliases too. WIll do that now. |
Done! |
* | ||
* @return ApiInterface | ||
* | ||
* @throws InvalidArgumentException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should throw a BadMethodCallException instead for __call
when calling the wrong method (you should catch the InvalidArgumentException
and throw another exception)
The usage of the magic api should be covered by a few tests too |
Where is the best place to test this? |
The new way calling the old one. Not sure it's very cool. The [edit] and test in ClientTest.php ofc. |
@stof for the tests, would this make sense? /**
* @test
* @dataProvider getApiClassesProvider
*/
public function shouldGetMagicApiInstance($apiName, $class)
{
$client = new Client();
$this->assertInstanceOf($class, $client->$apiName());
} |
yes
well, if we decide that |
What error message should be thrown by |
|
Make sense? |
@cursedcoder can we see this merged? :) |
if @stof is ok with it |
👍 |
Awesome! :) |
@cursedcoder Please bump the package version to 1.3.x when releasing this, to start followign semver for the version numbers (and I think it deserves being mentionned in the changelog of the release) |
The branch alias is already for 1.3. |
Closes #177 - use the magic __call method for IDE completion
I know I might be out of place, but I am going through the code, and am curious why this implementation was needed. Why use magic methods here? Just for the aliasing, or is there any other reason I don't understand? I ended up here but it is not explained :D |
All of the new methods are camelCase. They have all of the same aliases too.