-
Notifications
You must be signed in to change notification settings - Fork 436
allowing camelCase method calls #445
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
base: master
Are you sure you want to change the base?
Conversation
As in ``` \models\User::findByEmail(); $post->toJSON(); ```
|
Needs tests. And why would anyone use the camelCased version of methods, when that in the end performs worse (not sure, only assuming that passing a method call to |
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.
Why even have this method_exists() check block?
This won't allow for the build or create methods and this __call method already handles the error case if a method doesn't exist.
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.
Same goes for the static version above.
|
Everything works as before: the only addon feature is that a call to a nonexistent method: findAllByCategory will be translated to a call to: find_all_by_category
....nothing fancy, just allowing cameCase method calls "And why would anyone use the camelCased version of methods" i just find camelCase more readable (and modern). You don't call finders 1000 times per request, I hope no one even call them 100 times per request, so performance will not be affected even if call_user_func_array is slower. also any magic method call is slower than callign an existing method, but that is how php-activerecord magic finders are implemented. Again the numer of calls per request make this negligible. kindly |
|
I understand what it does, but to verify the functionality, and to be sure that it won't break in the future there need to be tests |
|
I think a lot of developers are switching over to this convention and it would be nice to allow it in the finders. I agree that performance impact would be trivial if any from method_exist lookups. Could you include a test which includes using your camelCased finders if you want us to merge this in. |
As in