Skip to content

zend_test: test ZPP specifiers - #23192

Merged
Girgias merged 23 commits into
php:masterfrom
Girgias:2026-08-zpp-tests
Aug 14, 2026
Merged

zend_test: test ZPP specifiers#23192
Girgias merged 23 commits into
php:masterfrom
Girgias:2026-08-zpp-tests

Conversation

@Girgias

@Girgias Girgias commented Aug 9, 2026

Copy link
Copy Markdown
Member

Move ZPP tests from Zend/ to zend_test/ and add tests for the bool/int/float/number ZPP specifiers.

We don't test ZPP in normal functional tests, but it should still be tested somewhere.

Missing specifiers:

  • Z_PARAM_ENUM(dest, _ce)

  • old "a"

    • Z_PARAM_ARRAY_EX2(dest, check_null, deref, separate)
    • Z_PARAM_ARRAY_EX(dest, check_null, separate)
    • Z_PARAM_ARRAY(dest)
    • Z_PARAM_ARRAY_OR_NULL(dest)
  • old "A"

    • Z_PARAM_ARRAY_OR_OBJECT_EX2(dest, check_null, deref, separate)
    • Z_PARAM_ARRAY_OR_OBJECT_EX(dest, check_null, separate)
    • Z_PARAM_ARRAY_OR_OBJECT(dest)
  • old "h"

    • Z_PARAM_ARRAY_HT_EX2(dest, check_null, deref, separate)
    • Z_PARAM_ARRAY_HT_EX(dest, check_null, separate)
    • Z_PARAM_ARRAY_HT(dest)
    • Z_PARAM_ARRAY_HT_OR_NULL(dest)
  • array|int:

    • Z_PARAM_ARRAY_HT_OR_LONG_EX(dest_ht, dest_long, is_null, allow_null)
    • Z_PARAM_ARRAY_HT_OR_LONG(dest_ht, dest_long)
    • Z_PARAM_ARRAY_HT_OR_LONG_OR_NULL(dest_ht, dest_long, is_null)
  • array|string:

    • Z_PARAM_ARRAY_HT_OR_STR_EX(dest_ht, dest_str, allow_null)
    • Z_PARAM_ARRAY_HT_OR_STR(dest_ht, dest_str)
    • Z_PARAM_ARRAY_HT_OR_STR_OR_NULL(dest_ht, dest_str)
  • old "H"

    • Z_PARAM_ARRAY_OR_OBJECT_HT_EX2(dest, check_null, deref, separate)
    • Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate)
    • Z_PARAM_ARRAY_OR_OBJECT_HT(dest)
  • old "f"

    • Z_PARAM_FUNC_EX2(dest_fci, dest_fcc, check_null, deref, free_trampoline)
    • Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, deref)
    • Z_PARAM_FUNC(dest_fci, dest_fcc)
    • Z_PARAM_FUNC_NO_TRAMPOLINE_FREE(dest_fci, dest_fcc)
    • Z_PARAM_FUNC_OR_NULL(dest_fci, dest_fcc)
    • Z_PARAM_FUNC_NO_TRAMPOLINE_FREE_OR_NULL(dest_fci, dest_fcc)
  • old "p"

    • Z_PARAM_PATH_EX(dest, dest_len, check_null, deref)
    • Z_PARAM_PATH(dest, dest_len)
    • Z_PARAM_PATH_OR_NULL(dest, dest_len)
  • old "P"

    • Z_PARAM_PATH_STR_EX(dest, check_null, deref)
    • Z_PARAM_PATH_STR(dest)
    • Z_PARAM_PATH_STR_OR_NULL(dest)
  • old "s"

    • Z_PARAM_STRING_EX(dest, dest_len, check_null, deref)
    • Z_PARAM_STRING(dest, dest_len)
    • Z_PARAM_STRING_OR_NULL(dest, dest_len)
  • old "S"

    • Z_PARAM_STR_EX(dest, check_null, deref)
    • Z_PARAM_STR(dest)
    • Z_PARAM_STR_OR_NULL(dest)
  • string|int

    • Z_PARAM_STR_OR_LONG_EX(dest_str, dest_long, is_null, allow_null)
    • Z_PARAM_STR_OR_LONG(dest_str, dest_long)
    • Z_PARAM_STR_OR_LONG_OR_NULL(dest_str, dest_long, is_null)
  • old "z"

    • Z_PARAM_ZVAL_EX2(dest, check_null, deref, separate)
    • Z_PARAM_ZVAL_EX(dest, check_null, separate)
    • Z_PARAM_ZVAL(dest)
    • Z_PARAM_ZVAL_OR_NULL(dest)
  • old "+" and "*"

    • Z_PARAM_VARIADIC_EX(spec, dest, dest_num, post_varargs)
    • Z_PARAM_VARIADIC(spec, dest, dest_num)
    • Z_PARAM_VARIADIC_WITH_NAMED(dest, dest_num, dest_named)
@Girgias
Girgias marked this pull request as ready for review August 9, 2026 23:41
@Girgias
Girgias requested a review from kocsismate as a code owner August 9, 2026 23:41

@arnaud-lb arnaud-lb 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.

IMHO we shouldn't have tests at all in ext/zend_test, unless they are testing the extension itself. That's usually not the case: We call functions of ext/zend_test for the purpose of testing something else.


$types = require 'types.inc';

foreach ($types as $type) {

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.

Please print something between each loop, and maybe before each try/catch block below, so that we can identify what the output relates to. This helps a lot when debugging a regression, or just when reviewing the test.

@kocsismate

Copy link
Copy Markdown
Member

I think it's a good idea to add these ZPP tests somewhere. I couldn't think of a better place than ext/zend_test 🤔 alternatively, it would be possible to reuse already existing functions (e.g. microtime() for bool tests), but this approach would make ZPP tests scattered.

Overall, LGTM for me, I agree though that the test output could be improved before merging. :)

@arnaud-lb

Copy link
Copy Markdown
Member

The tests can be in Zend/tests/zpp/ while the test helpers are in ext/zend_test/. This is what we usually do. For example, zend_leak_variable() is implemented in ext/zend_test/, but it's used by tests in ext/standard/tests/.

@Girgias
Girgias force-pushed the 2026-08-zpp-tests branch from b9a5e1e to 4959911 Compare August 12, 2026 15:21
@Girgias

Girgias commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

I'll move the tests to Zend/tests/zpp when I'm done :)

@Girgias

Girgias commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

I think I'm done for the moment, this is quite tedious and makes me think we maybe should try to remove some of the fast ZPP specifiers (mainly the Z_OBJECT_* ones IMHO as they don't have union equivalents)

@Girgias
Girgias force-pushed the 2026-08-zpp-tests branch from 0d532e7 to edaab1a Compare August 13, 2026 13:51
@Girgias
Girgias merged commit 308a241 into php:master Aug 14, 2026
18 checks passed
@Girgias
Girgias deleted the 2026-08-zpp-tests branch August 14, 2026 15:06
@Girgias Girgias mentioned this pull request Aug 14, 2026
63 tasks
@NickSdot

Copy link
Copy Markdown
Contributor

The tests can be in Zend/tests/zpp/ while the test helpers are in ext/zend_test/. This is what we usually do. For example, zend_leak_variable() is implemented in ext/zend_test/, but it's used by tests in ext/standard/tests/.

Should zpp tests in extensions then go into a dedicated zpp directory? Or is prefixing with zend_ fine to keep "thematic" grouping?

Example: https://github.com/php/php-src/pull/23286/changes#r3788972735

In the example I use zend_ prefix to have the test itself in parsing/.

@Girgias

Girgias commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

If the ZPP specifier is specified by the extension it is an extension implementation so DO NOT move this to Zend.

@NickSdot

Copy link
Copy Markdown
Contributor

If the ZPP specifier is specified by the extension it is an extension implementation so DO NOT move this to Zend.

My question was rather how to structure it within extensions.

@Girgias

Girgias commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

I'm not sure this really matters? You wouldn't create a custom function just to test the parsing, nor does adding stuff to zend_test make sense as it's not testing the engine.

Just testing a function is the most sensible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment