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

NiftyDisplay: add "Suggestion" block #3

Open
kktsvetkov opened this issue Aug 15, 2017 · 0 comments
Open

NiftyDisplay: add "Suggestion" block #3

kktsvetkov opened this issue Aug 15, 2017 · 0 comments

Comments

@kktsvetkov
Copy link
Owner

Add a new block (in the same fashion as "backtrace" and "source code") which will suggest how to fix the reported PHP error message. The idea is to help solve these issues easier without having to look elsewhere.

For example if there is a PHP notice "Array to string conversion", the suggestion will be something like:

You are probably trying to print or concatenate an array variable. You must check the type of the variable to understand whether it is a scalar or an array (or an object):
if (is_array($a)) {...

You can find more here:
stackoverflow.com/.../notice-array-to-string-conversion-in

In order to collect data for the suggestions, scan the PHP source code for zend_error(). Here is an example:

Zend/zend_list.c

0075 | if (ld->list_dtor_ex) {
0076 | ld->list_dtor_ex(&r);
0077 | }
0078 | } else {
0079 | zend_error(E_WARNING, "Unknown list entry type (%d)", r.type);

0116 | const char *space;
0117 | const char *class_name = get_active_class_name(&space);
0118 | zend_error(E_WARNING, "%s%s%s(): supplied resource is not a valid %s resource", class_name, space, get_active_function_name(), resource_type_name);

Put this in a separate class (\Wano\Display\Suggestions perhaps) and make it optional, enabled by default.

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

No branches or pull requests

1 participant