Skip to content

ext/readline: declare true as the return type of readline_completion_function() - #23433

Open
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/readline-completion-function-true
Open

ext/readline: declare true as the return type of readline_completion_function()#23433
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/readline-completion-function-true

Conversation

@lacatoire

Copy link
Copy Markdown
Member

readline_completion_function() is declared bool, but the function assigns a static function pointer to rl_attempted_completion_function and then returns RETURN_BOOL(rl_attempted_completion_function != NULL) — a tautology. The only other exit is the TypeError from ZPP. true is always returned.

The commit declares true and returns it directly instead of the redundant pointer comparison.

ksort(), asort(), and natsort() already declare true in ext/standard, so this follows existing practice.

Changes: readline.stub.php (booltrue), readline.c (RETURN_BOOL(...)RETURN_TRUE), regenerated arginfo, added test.

@LamentXU123

LamentXU123 commented Aug 24, 2026

Copy link
Copy Markdown
Member

I don't think this needs a test tho.

…function()

The returned value was RETURN_BOOL(rl_attempted_completion_function !=
NULL) on the line right after that variable is assigned the address of
a static function, so it is true unconditionally. Return true directly
and declare it.
@lacatoire
lacatoire force-pushed the fix/readline-completion-function-true branch from 3786224 to aafd86d Compare August 24, 2026 08:06
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