From 7c9c39584c952063e5c05000cce7335a3ac65cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 19 Oct 2025 17:37:38 +0200 Subject: [PATCH 1/2] zend_inheritance: Improve formatting of return-by-ref `&` in zend_get_function_declaration() (#20104) The space after `&` made it look like the `&` was not part of the signature, possibly leading to confusion why the two signatures are incompatible without carefully reading the message. --- Zend/tests/inheritance/argument_restriction_001.phpt | 2 +- Zend/tests/objects/objects_005.phpt | 2 +- Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt | 2 +- Zend/zend_inheritance.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Zend/tests/inheritance/argument_restriction_001.phpt b/Zend/tests/inheritance/argument_restriction_001.phpt index 2c54636a5817..6eb3ff8d2706 100644 --- a/Zend/tests/inheritance/argument_restriction_001.phpt +++ b/Zend/tests/inheritance/argument_restriction_001.phpt @@ -13,4 +13,4 @@ class Sub extends Base { } ?> --EXPECTF-- -Fatal error: Declaration of & Sub::test() must be compatible with & Base::test($foo, array $bar, $option = null, $extra = 'llllllllll...') in %s on line %d +Fatal error: Declaration of &Sub::test() must be compatible with &Base::test($foo, array $bar, $option = null, $extra = 'llllllllll...') in %s on line %d diff --git a/Zend/tests/objects/objects_005.phpt b/Zend/tests/objects/objects_005.phpt index 9b9a41465f95..7749a39d986f 100644 --- a/Zend/tests/objects/objects_005.phpt +++ b/Zend/tests/objects/objects_005.phpt @@ -19,4 +19,4 @@ class test3 extends test { ?> --EXPECTF-- -Fatal error: Declaration of test3::foo() must be compatible with & test::foo() in %s on line %d +Fatal error: Declaration of test3::foo() must be compatible with &test::foo() in %s on line %d diff --git a/Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt b/Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt index 84eb96826354..2c507d862be6 100644 --- a/Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt +++ b/Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt @@ -15,4 +15,4 @@ class A implements I { ?> --EXPECTF-- -Fatal error: Declaration of A::$prop::get() must be compatible with & I::$prop::get() in %s on line %d +Fatal error: Declaration of A::$prop::get() must be compatible with &I::$prop::get() in %s on line %d diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index a2da64b62c0d..1f128764bdd3 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -916,7 +916,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration( smart_str str = {0}; if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) { - smart_str_appends(&str, "& "); + smart_str_appendc(&str, '&'); } if (fptr->common.scope) { From ebbb1b42958f9c793cd10bf55d31837946905277 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 19 Oct 2025 20:52:19 +0200 Subject: [PATCH 2/2] Fix GH-19021: improve tidyOptGetCategory detection We now check both this symbol and TidyInternalCategory presence. Co-authored-by: Peter Kokot --- NEWS | 4 ++++ ext/tidy/config.m4 | 30 +++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 537673e64fa9..4b2a4777fef5 100644 --- a/NEWS +++ b/NEWS @@ -64,6 +64,10 @@ PHP NEWS - Standard: . Fix shm corruption with coercion in options of unserialize(). (nielsdos) +- Tidy: + . Fixed GH-19021 (improved tidyOptGetCategory detection). + (arjendekorte, David Carlier, Peter Kokot) + - XMLReader: . Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available. (nielsdos) diff --git a/ext/tidy/config.m4 b/ext/tidy/config.m4 index 802e12fc367c..ff80a2cde30f 100644 --- a/ext/tidy/config.m4 +++ b/ext/tidy/config.m4 @@ -62,16 +62,32 @@ if test "$PHP_TIDY" != "no"; then AC_DEFINE(HAVE_TIDYRELEASEDATE,1,[ ]) ], [], []) - dnl The tidyOptGetCategory function (added in libtidy 5.4.0) if only useable - dnl if TidyInternalCategory (added in libtidy 5.6.0) is also present. - PHP_CHECK_LIBRARY($TIDY_LIB_NAME,TidyInternalCategory, - [ - AC_DEFINE(HAVE_TIDYOPTGETCATEGORY,1,[ ]) - ], [], []) - PHP_ADD_LIBRARY_WITH_PATH($TIDY_LIB_NAME, $TIDY_LIBDIR, TIDY_SHARED_LIBADD) PHP_ADD_INCLUDE($TIDY_INCDIR) + old_CPPFLAGS=$CPPFLAGS + CPPFLAGS=-I$TIDY_INCDIR + + dnl The tidyOptGetCategory function (added in tidy-html5 5.4.0) is only + dnl useable if TidyInternalCategory (added in tidy-html5 5.6.0) is also + dnl present. + AC_CACHE_CHECK([for tidyOptGetCategory], [php_ac_cv_have_tidyoptgetcategory], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ],[ + TidyDoc doc = tidyCreate(); + TidyOption badopt = tidyGetOptionByName(doc, ""); + Bool v = (tidyOptGetCategory(badopt) == TidyInternalCategory); + (void)v; + tidyRelease(doc); + ])], + [php_ac_cv_have_tidyoptgetcategory=yes], + [php_ac_cv_have_tidyoptgetcategory=no]) + ]) + AS_VAR_IF([php_ac_cv_have_tidyoptgetcategory], [yes], + [AC_DEFINE([HAVE_TIDYOPTGETCATEGORY], [1], + [Define to 1 if tidyOptGetCategory is available.])]) + + CPPFLAGS=$old_CPPFLAGS + dnl Add -Wno-ignored-qualifiers as this is an issue upstream TIDY_COMPILER_FLAGS="$TIDY_CFLAGS -Wno-ignored-qualifiers -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared,, $TIDY_COMPILER_FLAGS)