-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Adding ignoreStrictCheck option for call_user_func_array, if throwing exception #1236
Conversation
… exception Signed-off-by: Barta Tamás <barta.tamas.d@gmail.com>
// to call is not supported. If ignoreStrictCheck is true, we should return null. | ||
try { | ||
$ret = call_user_func_array(array($object, $method), $arguments); | ||
} catch (Exception $e) { |
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.
Here, you basically catch all exception for all methods, which of course is not possible.
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.
I expected a similar response, but I had no other idea for a clean solution. I was going to write about alternate methods of solving this problem, but then I looked up BadMethodCallException, and it looks like a built-in PHP exception (since 5.1.0). I thought since, that it would be a FuelPHP dependency to use that. Would it be OK to simply replace Exception with BadMethodCallException?
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.
I added a new commit reflecting to your complaint. Please take a look if you find it possible to merge. Thanks!
Any update on this? |
@TamasBarta Can you add some unit tests? |
closing in favor of #1286 |
…y, if throwing exception (fabpot) This PR was merged into the master branch. Discussion ---------- Adding ignoreStrictCheck option for call_user_func_array, if throwing exception Same as #1236 with added unit tests and C extension support (to come). "I experienced the issue when using FuelPHP's ORM with EAV containers. When I tried to reference a property that was not defined I expected to get null, but instead the whole application stopped because an exception was thrown in the ORM, that no such function is present. I couldn't find other possible exception that could be thrown when this function is called, so I assumed it's safe to take the ignoreStrictCheck into consideration here." Commits ------- 1abf5d9 [ext] Mirroring PHP change for call_user_func_array, see #1286 9ab290b added tests for exceptions thrown in __call() c711d37 Adding ignoreStrictCheck option for call_user_func_array, if throwing exception
Awesome news! Thanks! |
I experienced the issue when using FuelPHP's ORM with EAV containers. When I tried to reference a property that was not defined I expected to get null, but instead the whole application stopped because an exception was thrown in the ORM, that no such function is present.
I couldn't find other possible exception that could be thrown when this function is called, so I assumed it's safe to take the ignoreStrictCheck into consideration here.