Skip to content

Commit efbdcb8

Browse files
authored
Rename FFI getFuncArg* to getFuncParameter*, $arg_index->$index (#7236)
PHP is already already using "Parameter" instead of "Argument" for reflection on types elsewhere. Parameter is used to refer to the function declarations (AST_PARAM internally in the AST, ReflectionFunctionAbstract->getParameters(), etc.) Argument is used to refer to expressions passed to the functions by the caller (ArgumentCountError, etc.). (Error messages were also changed in php 8.x to refer to passing too many arguments to a function) Other languages use similar definitions, e.g. https://developer.mozilla.org/en-US/docs/Glossary/Parameter
1 parent 90e6a74 commit efbdcb8

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

ext/ffi/ffi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,7 +4653,7 @@ ZEND_METHOD(FFI_CType, getStructFieldOffset) /* {{{ */
46534653

46544654
ptr = zend_hash_find_ptr(&type->record.fields, name);
46554655
if (!ptr) {
4656-
zend_throw_error(zend_ffi_exception_ce, "Wrong fileld name");
4656+
zend_throw_error(zend_ffi_exception_ce, "Wrong field name");
46574657
RETURN_THROWS();
46584658
}
46594659
RETURN_LONG(ptr->offset);
@@ -4680,7 +4680,7 @@ ZEND_METHOD(FFI_CType, getStructFieldType) /* {{{ */
46804680

46814681
ptr = zend_hash_find_ptr(&type->record.fields, name);
46824682
if (!ptr) {
4683-
zend_throw_error(zend_ffi_exception_ce, "Wrong fileld name");
4683+
zend_throw_error(zend_ffi_exception_ce, "Wrong field name");
46844684
RETURN_THROWS();
46854685
}
46864686

@@ -4730,7 +4730,7 @@ ZEND_METHOD(FFI_CType, getFuncReturnType) /* {{{ */
47304730
}
47314731
/* }}} */
47324732

4733-
ZEND_METHOD(FFI_CType, getFuncArgCount) /* {{{ */
4733+
ZEND_METHOD(FFI_CType, getFuncParameterCount) /* {{{ */
47344734
{
47354735
zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS));
47364736
zend_ffi_type *type;
@@ -4748,7 +4748,7 @@ ZEND_METHOD(FFI_CType, getFuncArgCount) /* {{{ */
47484748
}
47494749
/* }}} */
47504750

4751-
ZEND_METHOD(FFI_CType, getFuncArgType) /* {{{ */
4751+
ZEND_METHOD(FFI_CType, getFuncParameterType) /* {{{ */
47524752
{
47534753
zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS));
47544754
zend_ffi_type *type, *ptr;

ext/ffi/ffi.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public function getStructFieldType(string $field_name): CType {}
9292

9393
public function getFuncABI(): int {}
9494
public function getFuncReturnType(): CType {}
95-
public function getFuncArgCount(): int {}
96-
public function getFuncArgType(int $arg_index): CType {}
95+
public function getFuncParameterCount(): int {}
96+
public function getFuncParameterType(int $index): CType {}
9797
}
9898

9999
class Exception extends \Error {

ext/ffi/ffi_arginfo.h

Lines changed: 8 additions & 8 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: bdfc4211d30630290aaf5046dd4ae72936982703 */
2+
* Stub hash: 2675462a253edd2a0ea6106b9640f0d1a5a09489 */
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, "\"\"")
@@ -115,10 +115,10 @@ ZEND_END_ARG_INFO()
115115

116116
#define arginfo_class_FFI_CType_getFuncReturnType arginfo_class_FFI_CType_getArrayElementType
117117

118-
#define arginfo_class_FFI_CType_getFuncArgCount arginfo_class_FFI_CType_getKind
118+
#define arginfo_class_FFI_CType_getFuncParameterCount arginfo_class_FFI_CType_getKind
119119

120-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_CType_getFuncArgType, 0, 1, FFI\\CType, 0)
121-
ZEND_ARG_TYPE_INFO(0, arg_index, IS_LONG, 0)
120+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_CType_getFuncParameterType, 0, 1, FFI\\CType, 0)
121+
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
122122
ZEND_END_ARG_INFO()
123123

124124

@@ -153,8 +153,8 @@ ZEND_METHOD(FFI_CType, getStructFieldOffset);
153153
ZEND_METHOD(FFI_CType, getStructFieldType);
154154
ZEND_METHOD(FFI_CType, getFuncABI);
155155
ZEND_METHOD(FFI_CType, getFuncReturnType);
156-
ZEND_METHOD(FFI_CType, getFuncArgCount);
157-
ZEND_METHOD(FFI_CType, getFuncArgType);
156+
ZEND_METHOD(FFI_CType, getFuncParameterCount);
157+
ZEND_METHOD(FFI_CType, getFuncParameterType);
158158

159159

160160
static const zend_function_entry class_FFI_methods[] = {
@@ -199,8 +199,8 @@ static const zend_function_entry class_FFI_CType_methods[] = {
199199
ZEND_ME(FFI_CType, getStructFieldType, arginfo_class_FFI_CType_getStructFieldType, ZEND_ACC_PUBLIC)
200200
ZEND_ME(FFI_CType, getFuncABI, arginfo_class_FFI_CType_getFuncABI, ZEND_ACC_PUBLIC)
201201
ZEND_ME(FFI_CType, getFuncReturnType, arginfo_class_FFI_CType_getFuncReturnType, ZEND_ACC_PUBLIC)
202-
ZEND_ME(FFI_CType, getFuncArgCount, arginfo_class_FFI_CType_getFuncArgCount, ZEND_ACC_PUBLIC)
203-
ZEND_ME(FFI_CType, getFuncArgType, arginfo_class_FFI_CType_getFuncArgType, ZEND_ACC_PUBLIC)
202+
ZEND_ME(FFI_CType, getFuncParameterCount, arginfo_class_FFI_CType_getFuncParameterCount, ZEND_ACC_PUBLIC)
203+
ZEND_ME(FFI_CType, getFuncParameterType, arginfo_class_FFI_CType_getFuncParameterType, ZEND_ACC_PUBLIC)
204204
ZEND_FE_END
205205
};
206206

ext/ffi/tests/046.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ $x = FFI::type("void (*)(double,int32_t)");
4747
var_dump($x->getKind() === $x::TYPE_POINTER);
4848
var_dump($x->getPointerType()->getKind() === $x::TYPE_FUNC);
4949
var_dump($x->getPointerType()->getFuncReturnType()->getKind() === $x::TYPE_VOID);
50-
var_dump($x->getPointerType()->getFuncArgCount());
51-
var_dump($x->getPointerType()->getFuncArgType(0)->getKind() === $x::TYPE_DOUBLE);
52-
var_dump($x->getPointerType()->getFuncArgType(1)->getKind() === $x::TYPE_SINT32);
50+
var_dump($x->getPointerType()->getFuncParameterCount());
51+
var_dump($x->getPointerType()->getFuncParameterType(0)->getKind() === $x::TYPE_DOUBLE);
52+
var_dump($x->getPointerType()->getFuncParameterType(1)->getKind() === $x::TYPE_SINT32);
5353
?>
5454
--EXPECT--
5555
bool(true)

ext/ffi/tests/bug80847.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bug #80847 (Nested structs)
44
ffi
55
--SKIPIF--
66
<?php
7-
if (PHP_OS_FAMILY == 'Windows' && ((1 << 31) > 0)) die('xfail libffi doesn\'t properly support passing big strctures by value on Windows/64');
7+
if (PHP_OS_FAMILY == 'Windows' && ((1 << 31) > 0)) die('xfail libffi doesn\'t properly support passing big structures by value on Windows/64');
88
?>
99
--FILE--
1010
<?php

0 commit comments

Comments
 (0)