Skip to content

sapi/phpdbg: Use HASH_FOREACH macro #16211

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

Merged
merged 2 commits into from
Oct 6, 2024
Merged

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Oct 4, 2024

No description provided.

@Girgias Girgias marked this pull request as ready for review October 4, 2024 12:43
@Girgias Girgias requested a review from nielsdos October 4, 2024 12:43

zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position);
line = zend_get_executed_lineno();
file = zend_get_executed_filename_ex();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike zend_get_executed_filename, this can return NULL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why that is a problem? file is always guarded by a NULL check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, nvm

i++;
} else {
phpdbg_out(" => ");
phpdbg_dump_prototype(tmp);
phpdbg_out(" (internal function)\n");
}

file = zend_hash_find(Z_ARRVAL_P(tmp), ZSTR_KNOWN(ZEND_STR_FILE));
line = zend_hash_find(Z_ARRVAL_P(tmp), ZSTR_KNOWN(ZEND_STR_LINE));
zval *file_zv = zend_hash_find(Z_ARRVAL_P(tmp), ZSTR_KNOWN(ZEND_STR_FILE));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just change this to
file = zend_hash_find_ptr(Z_ARRVAL_P(tmp), ZSTR_KNOWN(ZEND_STR_FILE));
and remove the if-else part.
That makes the code less noisy.

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if CI green


zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position);
line = zend_get_executed_lineno();
file = zend_get_executed_filename_ex();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, nvm

@Girgias Girgias merged commit 2d217f0 into php:master Oct 6, 2024
10 checks passed
@Girgias Girgias deleted the phpdbg-hash-foreach branch October 6, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants