Skip to content

Commit ed19cb6

Browse files
committed
Fix the signature of FFI::sizeof() and FFI::alignof()
1 parent 34aefa3 commit ed19cb6

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

ext/ffi/ffi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,7 +4165,7 @@ ZEND_METHOD(FFI, sizeof) /* {{{ */
41654165
type = ZEND_FFI_TYPE(ctype->type);
41664166
} else {
41674167
zend_wrong_parameter_class_error(1, "FFI\\CData or FFI\\CType", zv);
4168-
return;
4168+
RETURN_THROWS();
41694169
}
41704170

41714171
RETURN_LONG(type->size);
@@ -4191,7 +4191,7 @@ ZEND_METHOD(FFI, alignof) /* {{{ */
41914191
type = ZEND_FFI_TYPE(ctype->type);
41924192
} else {
41934193
zend_wrong_parameter_class_error(1, "FFI\\CData or FFI\\CType", zv);
4194-
return;
4194+
RETURN_THROWS();
41954195
}
41964196

41974197
RETURN_LONG(type->align);

ext/ffi/ffi.stub.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ public static function arrayType(FFI\CType $type, array $dimensions): ?FFI\CType
3333
/** @prefer-ref $ptr */
3434
public static function addr(FFI\CData $ptr): FFI\CData {}
3535

36-
/** @prefer-ref $ptr */
37-
public static function sizeof(object $ptr): ?int {}
36+
/**
37+
* @param FFI\CData|FFI\CType $ptr
38+
* @prefer-ref $ptr
39+
*/
40+
public static function sizeof($ptr): int {}
3841

39-
/** @prefer-ref $ptr */
40-
public static function alignof(object $ptr): ?int {}
42+
/**
43+
* @param FFI\CData|FFI\CType $ptr
44+
* @prefer-ref $ptr
45+
*/
46+
public static function alignof($ptr): int {}
4147

4248
/**
4349
* @param FFI\CData|string $from

ext/ffi/ffi_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: abd3bc186ae3f71f2b7eb1d47f3b6bab84fb2bda */
2+
* Stub hash: f106049da816d8fef7bbfb40c5335245b57044e0 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0)
55
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,
4646
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
4747
ZEND_END_ARG_INFO()
4848

49-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_sizeof, 0, 1, IS_LONG, 1)
50-
ZEND_ARG_TYPE_INFO(ZEND_SEND_PREFER_REF, ptr, IS_OBJECT, 0)
49+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_sizeof, 0, 1, IS_LONG, 0)
50+
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr)
5151
ZEND_END_ARG_INFO()
5252

5353
#define arginfo_class_FFI_alignof arginfo_class_FFI_sizeof

0 commit comments

Comments
 (0)