-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Parameter Validation + Exceptions (GD, Hash) #4559
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
Thanks for the PR! Indeed, something like this should be done to augment https://wiki.php.net/rfc/consistent_type_errors. I'm not sure about the details, though. Do we want a new API for this? Which kind of Error should be thrown? Anyhow, we should figure out the details, and apply the changes consistently accross the code base (see PR #4553, #4554 and #4566). |
A standard certainly wouldn't hurt, maybe it's something we need to take to Internals? I've been in touch with GPB but we are taking slightly different approaches, mainly I'm going through a helper function that takes the parameter number. |
From what @nikic told me TypeError and normal Error are the way to go now maybe adding an API is better to get some nice consistent messages like he did with the TypeError RFC? |
I see a few main conditions:
The major problem here is going to be the test cases. Sooooo many test cases. Many of which would have different logic in a post-elevation scenario, particularly those that check for living after a bad function call. |
I think this should be separate PRs (one for implementation) and subsequent ones for each extension or part converted. As for the change itself, it is something that should at least be mentioned on the internals for a chance at feedback (I think its a fairly minimal change in itself so there should not be a need for the RFC process to be invoked here). |
@KalleZ Thanks. I've kicked it over to Internals for a quick discussion on format and then I'll likely pull this PR and create a new one on a per-module basis. |
First attempt at contributing. Tests are not currently blessed, need to discuss the idea of php_error_parameter_validation to enforce formatting of information, or if exceptions should be thrown directly.