From 9950a0b1c53ba167d09081307170194999daf9c8 Mon Sep 17 00:00:00 2001 From: Tomas Ebenlendr Date: Tue, 16 Apr 2024 09:29:46 +0200 Subject: [PATCH] Php::Value constructor from _zend_string Previous commit exposes mishandling of _zend_string function arguments by PHP-CPP to compiler. This commit fixes that problem. --- include/value.h | 1 + zend/value.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/value.h b/include/value.h index 084102c1..996eb48f 100644 --- a/include/value.h +++ b/include/value.h @@ -60,6 +60,7 @@ class PHPCPP_EXPORT Value : private HashParent Value(char value); Value(const std::string &value); Value(const char *value, int size = -1); + Value(struct _zend_string *value); Value(double value); Value(const IniValue &value); diff --git a/zend/value.cpp b/zend/value.cpp index 6f53af42..aa05efcb 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -128,6 +128,25 @@ Value::Value(const char *value, int size) } } +/** + * Constructor based on zend_string + * @param value + */ +Value::Value(struct _zend_string *value) +{ + // is there a value? + if (value) + { + // create a string zval + ZVAL_STRINGL(_val, value->val, value->len); + } + else + { + // store null + ZVAL_NULL(_val); + } +} + /** * Constructor based on decimal value * @param value