summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-09-23 16:33:24 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-09-23 16:39:52 +0200
commit3012d006ff4da73679fca9f0d78a82492fcd0b7a (patch)
tree8a8d552b816ff7ccc5ea15411929a92c335c050a /ext
parente441378b5422908474863a34cfa6f983a536ce5c (diff)
downloadphp-git-3012d006ff4da73679fca9f0d78a82492fcd0b7a.tar.gz
Don't set nullability flag for parameters without type
Use value 0 instead. To compensate we check in ReflectionParameter allowsNull() whether the type is set at all: If it isn't, it always allows null. This removes a discrepancy between internal&userland functions: For userland functions allowsNull() on untyped parameters returned true, but for internal functions it returned false.
Diffstat (limited to 'ext')
-rw-r--r--ext/com_dotnet/com_handlers.c2
-rw-r--r--ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt122
-rw-r--r--ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt12
-rw-r--r--ext/reflection/php_reflection.c3
4 files changed, 70 insertions, 69 deletions
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index fd4cb4ab3b..092e65db57 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -319,7 +319,7 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name
f.arg_info = ecalloc(bindptr.lpfuncdesc->cParams, sizeof(zend_arg_info));
for (i = 0; i < bindptr.lpfuncdesc->cParams; i++) {
- f.arg_info[i].type = ZEND_TYPE_ENCODE_CODE(0,1);
+ f.arg_info[i].type = ZEND_TYPE_ENCODE_NONE();
if (bindptr.lpfuncdesc->lprgelemdescParam[i].paramdesc.wParamFlags & PARAMFLAG_FOUT) {
f.arg_info[i].pass_by_reference = ZEND_SEND_BY_REF;
}
diff --git a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt
index 47beb1d79b..c341acf2b3 100644
--- a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt
+++ b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt
@@ -53,42 +53,42 @@ Number of Required Parameters: 0
Inspecting parameter 'host' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'user' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'password' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'database' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'port' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'socket' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -111,42 +111,42 @@ Number of Required Parameters: 0
Inspecting parameter 'host' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'user' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'password' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'database' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'port' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'socket' of method '__construct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -169,7 +169,7 @@ Number of Required Parameters: 1
Inspecting parameter 'mode' of method 'autocommit'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -192,14 +192,14 @@ Number of Required Parameters: 0
Inspecting parameter 'flags' of method 'begin_transaction'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'name' of method 'begin_transaction'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -222,21 +222,21 @@ Number of Required Parameters: 3
Inspecting parameter 'user' of method 'change_user'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'password' of method 'change_user'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'database' of method 'change_user'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -291,14 +291,14 @@ Number of Required Parameters: 0
Inspecting parameter 'flags' of method 'commit'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'name' of method 'commit'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -321,42 +321,42 @@ Number of Required Parameters: 0
Inspecting parameter 'host' of method 'connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'user' of method 'connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'password' of method 'connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'database' of method 'connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'port' of method 'connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'socket' of method 'connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -379,7 +379,7 @@ Number of Required Parameters: 1
Inspecting parameter 'debug_options' of method 'debug'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -418,7 +418,7 @@ Number of Required Parameters: 1
Inspecting parameter 'string_to_escape' of method 'escape_string'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -537,7 +537,7 @@ Number of Required Parameters: 1
Inspecting parameter 'connection_id' of method 'kill'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -576,7 +576,7 @@ Number of Required Parameters: 1
Inspecting parameter 'query' of method 'multi_query'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -615,14 +615,14 @@ Number of Required Parameters: 2
Inspecting parameter 'option' of method 'options'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'value' of method 'options'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -682,14 +682,14 @@ isDefaultValueAvailable: no
Inspecting parameter 'sec' of method 'poll'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'usec' of method 'poll'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -712,7 +712,7 @@ Number of Required Parameters: 1
Inspecting parameter 'query' of method 'prepare'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -735,14 +735,14 @@ Number of Required Parameters: 1
Inspecting parameter 'query' of method 'query'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'resultmode' of method 'query'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -765,49 +765,49 @@ Number of Required Parameters: 0
Inspecting parameter 'host' of method 'real_connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'user' of method 'real_connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'password' of method 'real_connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'database' of method 'real_connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'port' of method 'real_connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'socket' of method 'real_connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'flags' of method 'real_connect'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -830,7 +830,7 @@ Number of Required Parameters: 1
Inspecting parameter 'string_to_escape' of method 'real_escape_string'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -853,7 +853,7 @@ Number of Required Parameters: 1
Inspecting parameter 'query' of method 'real_query'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -892,7 +892,7 @@ Number of Required Parameters: 1
Inspecting parameter 'options' of method 'refresh'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -915,7 +915,7 @@ Number of Required Parameters: 1
Inspecting parameter 'name' of method 'release_savepoint'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -938,14 +938,14 @@ Number of Required Parameters: 0
Inspecting parameter 'flags' of method 'rollback'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
Inspecting parameter 'name' of method 'rollback'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -968,7 +968,7 @@ Number of Required Parameters: 1
Inspecting parameter 'name' of method 'savepoint'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -991,7 +991,7 @@ Number of Required Parameters: 1
Inspecting parameter 'database' of method 'select_db'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -1014,7 +1014,7 @@ Number of Required Parameters: 1
Inspecting parameter 'charset' of method 'set_charset'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -1037,14 +1037,14 @@ Number of Required Parameters: 2
Inspecting parameter 'option' of method 'set_opt'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'value' of method 'set_opt'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -1067,35 +1067,35 @@ Number of Required Parameters: 5
Inspecting parameter 'key' of method 'ssl_set'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'cert' of method 'ssl_set'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'certificate_authority' of method 'ssl_set'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'certificate_authority_path' of method 'ssl_set'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
Inspecting parameter 'cipher' of method 'ssl_set'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -1150,7 +1150,7 @@ Number of Required Parameters: 0
Inspecting parameter 'flags' of method 'store_result'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
diff --git a/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt
index b3b7759ace..c130e27a6b 100644
--- a/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt
+++ b/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt
@@ -101,7 +101,7 @@ Number of Required Parameters: 1
Inspecting parameter 'offset' of method 'data_seek'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -124,7 +124,7 @@ Number of Required Parameters: 0
Inspecting parameter 'result_type' of method 'fetch_all'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -147,7 +147,7 @@ Number of Required Parameters: 0
Inspecting parameter 'result_type' of method 'fetch_array'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -202,7 +202,7 @@ Number of Required Parameters: 1
Inspecting parameter 'field_nr' of method 'fetch_field_direct'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
@@ -241,7 +241,7 @@ Number of Required Parameters: 0
Inspecting parameter 'class_name' of method 'fetch_object'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: yes
isDefaultValueAvailable: no
@@ -287,7 +287,7 @@ Number of Required Parameters: 1
Inspecting parameter 'field_nr' of method 'field_seek'
isArray: no
-allowsNull: no
+allowsNull: yes
isPassedByReference: no
isOptional: no
isDefaultValueAvailable: no
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 6273c56def..92723240e9 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2593,7 +2593,8 @@ ZEND_METHOD(reflection_parameter, allowsNull)
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->arg_info->type));
+ RETVAL_BOOL(!ZEND_TYPE_IS_SET(param->arg_info->type)
+ || ZEND_TYPE_ALLOW_NULL(param->arg_info->type));
}
/* }}} */