Skip to content

Replace boolean inputs in type juggling tests - #25947

Open
theodorejb wants to merge 1 commit into
php:masterfrom
theodorejb:replace-bool-test-inputs
Open

theodorejb wants to merge 1 commit into
php:masterfrom
theodorejb:replace-bool-test-inputs

Conversation

@theodorejb

@theodorejb theodorejb commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Split out of #25889 per request, so it can be reviewed separately.

Many older tests include booleans in their lists of inputs for int, float, or string parameters, or other scalars in their lists of inputs for bool parameters. Each of these inputs is now replaced with the value it was converted to (0, 0.0, or "" for false, and 1, 1.0, or "1" for true), or removed when the test already has an input which converts to the same value. The functions are called with the same values as before, so the tests keep their coverage without relying on implicit conversions to or from bool. Booleans which are not converted, such as array elements joined by implode() or $res_arr values in tempnam_variation3-win32.phpt, are kept.

The fscanf() tests which write booleans to a file as test data now convert them to strings explicitly. call_user_func_strict_arginfo_check.phpt passes an int instead of false to strlen(), so it still covers a weak mode conversion. The get_cfg_var(), proc_nice(), and imageantialias() tests which only passed booleans are removed, as the values they converted to are covered by the other tests of these functions, with an empty string case added to get_cfg_var_variation7.phpt. The ReflectionClass::getConstant(), hasConstant(), hasMethod(), and hasProperty() tests of invalid arguments are also removed, as they only test parameter parsing.

@kamil-tekiela kamil-tekiela left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved for mysqli only.

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Didn't have the time to look at ext/standard yet, but at one point in the past I tried to clean those tests up and didn't get round to it.

But the rest LGTM.

@theodorejb
theodorejb force-pushed the replace-bool-test-inputs branch from 2c17ad9 to 94d6fc4 Compare November 30, 2026 16:15
Many older tests include booleans in their lists of inputs for int, float, or string parameters, or other scalars in their lists of inputs for bool parameters. Each of these inputs is now replaced with the value it was converted to (0, 0.0, or "" for false, and 1, 1.0, or "1" for true), or removed when the test already has an input which converts to the same value. The functions are called with the same values as before, so the tests keep their coverage without relying on implicit conversions to or from bool. Booleans which are not converted, such as array elements joined by implode() or $res_arr values in tempnam_variation3-win32.phpt, are kept.

The fscanf() tests which write booleans to a file as test data now convert them to strings explicitly. call_user_func_strict_arginfo_check.phpt passes an int instead of false to strlen(), so it still covers a weak mode conversion. The get_cfg_var(), proc_nice(), and imageantialias() tests which only passed booleans are removed, as the values they converted to are covered by the other tests of these functions, with an empty string case added to get_cfg_var_variation7.phpt. The ReflectionClass::getConstant(), hasConstant(), hasMethod(), and hasProperty() tests of invalid arguments are also removed, as they only test parameter parsing.
@theodorejb
theodorejb force-pushed the replace-bool-test-inputs branch from 94d6fc4 to 986df7b Compare December 1, 2026 03:43
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.

3 participants