From 7e67366a9b71f6fe52a09bdbadf75f167551f9f0 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 4 Nov 2021 16:58:24 +0100 Subject: [PATCH] Remove unnecessary assertion zend_class_implements_interface works fine if the "class" is an interface, so simply drop this assertion. This avoids the need to special case this situation. --- Zend/tests/interface_with_tostring.phpt | 18 ++++++++++++++++++ Zend/zend_operators.c | 1 - 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/interface_with_tostring.phpt diff --git a/Zend/tests/interface_with_tostring.phpt b/Zend/tests/interface_with_tostring.phpt new file mode 100644 index 00000000000..a7771c5e27a --- /dev/null +++ b/Zend/tests/interface_with_tostring.phpt @@ -0,0 +1,18 @@ +--TEST-- +Interface with __toString() method +--FILE-- +getInterfaceNames()); + +?> +--EXPECT-- +array(1) { + [0]=> + string(10) "Stringable" +} diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index ee86f9e96d3..acda841979e 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2276,7 +2276,6 @@ ZEND_API zend_result ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zv ZEND_API zend_bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce) /* {{{ */ { uint32_t i; - ZEND_ASSERT(!(class_ce->ce_flags & ZEND_ACC_INTERFACE)); ZEND_ASSERT(interface_ce->ce_flags & ZEND_ACC_INTERFACE); if (class_ce->num_interfaces) {