php_ion_serializer_php_ctor(obj);
}
-static ZEND_METHOD(ion_Serializer_PHP, __invoke)
+static ZEND_METHOD(ion_Serializer_PHP, serialize)
{
zend_object *obj = Z_OBJ_P(ZEND_THIS);
Z_PARAM_ZVAL(data)
ZEND_PARSE_PARAMETERS_END();
- if (obj->ce == ce_Serializer_PHP) {
- // default, fast path
- php_ion_serialize(&php_ion_obj(serializer_php, obj)->serializer, data, return_value);
- } else {
- zend_call_method_with_1_params(obj, obj->ce, NULL /* TODO */, "serialize", return_value, data);
- }
+ php_ion_serialize(&php_ion_obj(serializer_php, obj)->serializer, data, return_value);
}
static ZEND_FUNCTION(ion_serialize)
{
php_ion_serializer *ser = zo_ser ? &php_ion_obj(serializer_php, zo_ser)->serializer : NULL;
php_ion_serialize(ser, data, return_value);
} else {
- zend_call_method_with_1_params(zo_ser, NULL, NULL, "__invoke", return_value, data);
+ zend_call_method_with_1_params(zo_ser, NULL, NULL, "serialize", return_value, data);
}
}
-static ZEND_METHOD(ion_Serializer_PHP, serialize)
-{
- //zend_object *obj = Z_OBJ_P(ZEND_THIS);
-
- zval *data;
- ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ZVAL(data)
- ZEND_PARSE_PARAMETERS_END();
-
- // TODO
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Not implemented");
-}
static ZEND_METHOD(ion_Unserializer_PHP, __construct)
{
php_ion_unserializer_php_ctor(obj);
}
-static ZEND_METHOD(ion_Unserializer_PHP, __invoke)
+static ZEND_METHOD(ion_Unserializer_PHP, unserialize)
{
zend_object *obj = Z_OBJ_P(ZEND_THIS);
Z_PARAM_ZVAL(data)
ZEND_PARSE_PARAMETERS_END();
- if (obj->ce == ce_Unserializer_PHP) {
- php_ion_unserialize(&php_ion_obj(unserializer_php, obj)->unserializer, data, return_value);
- } else {
- zend_call_method_with_1_params(obj, obj->ce, NULL /* TODO */, "unserialize", return_value, data);
- }
+ php_ion_unserialize(&php_ion_obj(unserializer_php, obj)->unserializer, data, return_value);
}
static ZEND_FUNCTION(ion_unserialize)
{
zend_call_method_with_1_params(zo_ser, NULL, NULL, "__invoke", return_value, data);
}
}
-static ZEND_METHOD(ion_Unserializer_PHP, unserialize)
-{
- //zend_object *obj = Z_OBJ_P(ZEND_THIS);
-
- zval *data;
- ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ZVAL(data)
- ZEND_PARSE_PARAMETERS_END();
-
- // TODO
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Not implemented");
-}
PHP_RINIT_FUNCTION(ion)
{
namespace ion;
interface Serializer {
- public function __invoke(mixed $data) : string;
- // protected function serialize(mixed $data) : string;
+ public function serialize(mixed $data) : string;
}
namespace ion;
interface Unserializer {
/** @param string|resource $data */
- public function __invoke($data) : mixed;
- // /** @param string|resource $data */
- // protected function unserialize($data) : mixed;
+ public function unserialize($data) : mixed;
}
namespace ion\Serializer;
public readonly bool $callMagicSerialize = true,
public readonly ?string $callCustomSerialize = null,
) {}
- public function __invoke(mixed $data) : string {}
- protected function serialize(mixed $data) : string {}
+ public function serialize(mixed $data) : string {}
}
namespace ion\Unserializer;
public readonly ?string $callCustomUnserialize = null,
){}
/** @param string|resource $data */
- public function __invoke($data) : mixed {}
- /** @param string|resource $data */
- protected function unserialize($data) : mixed {}
+ public function unserialize($data) : mixed {}
}
namespace ion;
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 7322502dd0c48787538abe7e2fa1894b20a736ba */
+ * Stub hash: 6aa30c4f415607e9d724405a1b4c0fb10e4027f3 */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_ion_Symbol_Table_PHP, 0, 0, ion\\Symbol\\Table, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_ion_Writer_Stream_Writer_getStream arginfo_class_ion_Symbol_Table_Local___construct
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Serializer___invoke, 0, 1, IS_STRING, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Serializer_serialize, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_MIXED, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Unserializer___invoke, 0, 1, IS_MIXED, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Unserializer_unserialize, 0, 1, IS_MIXED, 0)
ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO()
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, callCustomSerialize, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-#define arginfo_class_ion_Serializer_PHP___invoke arginfo_class_ion_Serializer___invoke
-
-#define arginfo_class_ion_Serializer_PHP_serialize arginfo_class_ion_Serializer___invoke
+#define arginfo_class_ion_Serializer_PHP_serialize arginfo_class_ion_Serializer_serialize
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Unserializer_PHP___construct, 0, 0, 0)
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, readerOptions, ion\\Reader\\Options, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, callCustomUnserialize, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-#define arginfo_class_ion_Unserializer_PHP___invoke arginfo_class_ion_Unserializer___invoke
-
-#define arginfo_class_ion_Unserializer_PHP_unserialize arginfo_class_ion_Unserializer___invoke
+#define arginfo_class_ion_Unserializer_PHP_unserialize arginfo_class_ion_Unserializer_unserialize
static ZEND_FUNCTION(ion_Symbol_Table_PHP);
static ZEND_METHOD(ion_Writer_Stream_Writer, __construct);
static ZEND_METHOD(ion_Writer_Stream_Writer, getStream);
static ZEND_METHOD(ion_Serializer_PHP, __construct);
-static ZEND_METHOD(ion_Serializer_PHP, __invoke);
static ZEND_METHOD(ion_Serializer_PHP, serialize);
static ZEND_METHOD(ion_Unserializer_PHP, __construct);
-static ZEND_METHOD(ion_Unserializer_PHP, __invoke);
static ZEND_METHOD(ion_Unserializer_PHP, unserialize);
static const zend_function_entry class_ion_Serializer_methods[] = {
- ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Serializer, __invoke, arginfo_class_ion_Serializer___invoke, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
+ ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Serializer, serialize, arginfo_class_ion_Serializer_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_ion_Unserializer_methods[] = {
- ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Unserializer, __invoke, arginfo_class_ion_Unserializer___invoke, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
+ ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Unserializer, unserialize, arginfo_class_ion_Unserializer_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
ZEND_FE_END
};
static const zend_function_entry class_ion_Serializer_PHP_methods[] = {
ZEND_ME(ion_Serializer_PHP, __construct, arginfo_class_ion_Serializer_PHP___construct, ZEND_ACC_PUBLIC)
- ZEND_ME(ion_Serializer_PHP, __invoke, arginfo_class_ion_Serializer_PHP___invoke, ZEND_ACC_PUBLIC)
- ZEND_ME(ion_Serializer_PHP, serialize, arginfo_class_ion_Serializer_PHP_serialize, ZEND_ACC_PROTECTED)
+ ZEND_ME(ion_Serializer_PHP, serialize, arginfo_class_ion_Serializer_PHP_serialize, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_ion_Unserializer_PHP_methods[] = {
ZEND_ME(ion_Unserializer_PHP, __construct, arginfo_class_ion_Unserializer_PHP___construct, ZEND_ACC_PUBLIC)
- ZEND_ME(ion_Unserializer_PHP, __invoke, arginfo_class_ion_Unserializer_PHP___invoke, ZEND_ACC_PUBLIC)
- ZEND_ME(ion_Unserializer_PHP, unserialize, arginfo_class_ion_Unserializer_PHP_unserialize, ZEND_ACC_PROTECTED)
+ ZEND_ME(ion_Unserializer_PHP, unserialize, arginfo_class_ion_Unserializer_PHP_unserialize, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
echo "\n";
$u = new ion\Unserializer\PHP(multiSequence: true);
-var_dump($u($buf));
+var_dump($u->unserialize($buf));
?>
DONE
echo "\n";
$u = new ion\Unserializer\PHP(multiSequence: true);
-var_dump($u($buf));
+var_dump($u->unserialize($buf));
$u = new ion\Unserializer\PHP(multiSequence: true,
readerOptions: new ion\Reader\Options(
catalog: $c,
onContextChange: fn(ion\Reader $r) => print("on_context_change\n")));
-var_dump($u($buf));
+var_dump($u->unserialize($buf));
?>
DONE