Skip to content

Zend: Add missing ZPP specifier tests - #23343

Open
timsurrealedu wants to merge 3 commits into
php:masterfrom
timsurrealedu:zpp-tests-missing
Open

Zend: Add missing ZPP specifier tests#23343
timsurrealedu wants to merge 3 commits into
php:masterfrom
timsurrealedu:zpp-tests-missing

Conversation

@timsurrealedu

@timsurrealedu timsurrealedu commented Aug 18, 2026

Copy link
Copy Markdown

Adds missing test coverage for Zend Parameter Parsing (ZPP) specifiers as outlined in GH-23280.

Summary of Changes

  • Added helper functions to ext/zend_test (test.stub.php and test.c) to exercise missing ZPP specifiers (Z_PARAM_ENUM, Z_PARAM_ARRAY*, Z_PARAM_ARRAY_HT*, Z_PARAM_ARRAY_OR_OBJECT*, Z_PARAM_FUNC*, Z_PARAM_PATH*, Z_PARAM_STRING*, Z_PARAM_STR*, Z_PARAM_ZVAL*, Z_PARAM_VARIADIC*, and union specifiers).
  • Added .phpt test cases in Zend/tests/zpp/ covering both strict and weak type modes.

Closes GH-23280.

Fix segfaults in zend_test ZPP specifier helpers when handling immutable arrays (such as []) and non-refcounted variadic arguments. Also update phpt expectation files.
try {
var_dump(zend_array_ht_or_long($type));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), "\n";

Would be nice to change all these assertions to use "\n". Context: #23316 and #22799

string(8) "stdClass"
string(8) "stdClass"
Using anon class name:
string(106) "class@anonymous%0/home/timsurreal/Documents/mycode/githubContributions/php-src/Zend/tests/zpp/types.inc:9$1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your local paths are leaking in here.

Address PR php#23343 review feedback (NickSdot) and CI failures:

- Replace hardcoded anonymous-class name expectation leaking the local
  build path (`string(106) "class@anonymous%0/home/timsurreal/...types.inc:9$1"`)
  with the canonical EXPECTF pattern `string(%d) "class@anonymous%s"`,
  matching the convention used by neighboring ZPP tests. The previous
  form baked in the author's local path and byte length, failing on all
  CI platforms. Affects: array_ht_or_str, str_or_long, str, zval,
  string_param (strict + weak).
- Replace `PHP_EOL` with `"\n"` in assertion echo lines across all added
  test files. PHP_EOL is "\r\n" on Windows, a portability hazard per
  phpGH-23316 and phpGH-22799.

All 59 Zend/tests/zpp tests pass locally with zend_test enabled.

Co-Authored-By: Claude <noreply@anthropic.com>
@timsurrealedu

Copy link
Copy Markdown
Author

Thanks for the review, @NickSdot! Both points are addressed in the latest push (8da2451a):

  1. Local path leak — the --EXPECTF-- sections that hardcoded the anonymous class name (string(106) "class@anonymous%0/home/timsurreal/.../types.inc:9$1") now use the canonical string(%d) "class@anonymous%s" pattern, matching the neighboring ZPP tests. This was the cause of all 10 CI failures (the hardcoded path and byte length differed on CI).

  2. PHP_EOL"\n" — all assertion echo lines in the newly added tests now use "\n" instead of PHP_EOL per Zend: applied fixers to improve test robustness (8/8) #23316 / Tests: Test exception type in error tests #22799.

All 59 tests in Zend/tests/zpp/ pass locally with zend_test enabled. The 8 failing platform checks should clear on re-run.

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.

Zend: add missing ZPP tests

2 participants