From ed19cb6518b20895787b1d48a2b1c62c4cf128ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 23 Dec 2020 23:27:12 +0100 Subject: [PATCH] Fix the signature of FFI::sizeof() and FFI::alignof() --- ext/ffi/ffi.c | 4 ++-- ext/ffi/ffi.stub.php | 14 ++++++++++---- ext/ffi/ffi_arginfo.h | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 1b5784102d..620e4c6431 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -4165,7 +4165,7 @@ ZEND_METHOD(FFI, sizeof) /* {{{ */ type = ZEND_FFI_TYPE(ctype->type); } else { zend_wrong_parameter_class_error(1, "FFI\\CData or FFI\\CType", zv); - return; + RETURN_THROWS(); } RETURN_LONG(type->size); @@ -4191,7 +4191,7 @@ ZEND_METHOD(FFI, alignof) /* {{{ */ type = ZEND_FFI_TYPE(ctype->type); } else { zend_wrong_parameter_class_error(1, "FFI\\CData or FFI\\CType", zv); - return; + RETURN_THROWS(); } RETURN_LONG(type->align); diff --git a/ext/ffi/ffi.stub.php b/ext/ffi/ffi.stub.php index 0a347b2aa1..ab0342e43e 100644 --- a/ext/ffi/ffi.stub.php +++ b/ext/ffi/ffi.stub.php @@ -33,11 +33,17 @@ final class FFI /** @prefer-ref $ptr */ public static function addr(FFI\CData $ptr): FFI\CData {} - /** @prefer-ref $ptr */ - public static function sizeof(object $ptr): ?int {} + /** + * @param FFI\CData|FFI\CType $ptr + * @prefer-ref $ptr + */ + public static function sizeof($ptr): int {} - /** @prefer-ref $ptr */ - public static function alignof(object $ptr): ?int {} + /** + * @param FFI\CData|FFI\CType $ptr + * @prefer-ref $ptr + */ + public static function alignof($ptr): int {} /** * @param FFI\CData|string $from diff --git a/ext/ffi/ffi_arginfo.h b/ext/ffi/ffi_arginfo.h index 19e0adb25d..01e9e1f912 100644 --- a/ext/ffi/ffi_arginfo.h +++ b/ext/ffi/ffi_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: abd3bc186ae3f71f2b7eb1d47f3b6bab84fb2bda */ + * Stub hash: f106049da816d8fef7bbfb40c5335245b57044e0 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_STRING, 0, "\"\"") @@ -46,8 +46,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_addr, 0, 1, FFI\\CData, ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_sizeof, 0, 1, IS_LONG, 1) - ZEND_ARG_TYPE_INFO(ZEND_SEND_PREFER_REF, ptr, IS_OBJECT, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_sizeof, 0, 1, IS_LONG, 0) + ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr) ZEND_END_ARG_INFO() #define arginfo_class_FFI_alignof arginfo_class_FFI_sizeof -- 2.40.0