Skip to content

Commit bce040d

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Set opline before calling undef op helper Add more specific array return type hints for various extensions - part 6 (#7474)
2 parents de04211 + e32c850 commit bce040d

File tree

12 files changed

+97
-6
lines changed

12 files changed

+97
-6
lines changed

Zend/Optimizer/zend_func_infos.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,13 @@ static const func_info_t func_infos[] = {
299299
F1("mysqli_stat", MAY_BE_STRING|MAY_BE_FALSE),
300300
F1("mysqli_store_result", MAY_BE_OBJECT|MAY_BE_FALSE),
301301
F1("mysqli_use_result", MAY_BE_OBJECT|MAY_BE_FALSE),
302+
FN("oci_fetch_row", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
303+
FN("oci_fetch_assoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
304+
FN("oci_fetch_array", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
302305
FN("oci_new_connect", MAY_BE_RESOURCE|MAY_BE_FALSE),
303306
FN("oci_connect", MAY_BE_RESOURCE|MAY_BE_FALSE),
304307
FN("oci_pconnect", MAY_BE_RESOURCE|MAY_BE_FALSE),
308+
F1("oci_error", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
305309
FN("oci_parse", MAY_BE_RESOURCE|MAY_BE_FALSE),
306310
FN("oci_get_implicit_resultset", MAY_BE_RESOURCE|MAY_BE_FALSE),
307311
FN("oci_password_change", MAY_BE_RESOURCE|MAY_BE_BOOL),
@@ -333,6 +337,15 @@ static const func_info_t func_infos[] = {
333337
#endif
334338
F1("opcache_get_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
335339
F1("opcache_get_configuration", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
340+
F1("openssl_x509_parse", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
341+
F1("openssl_csr_get_subject", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
342+
F1("openssl_pkey_get_details", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
343+
F1("openssl_get_md_methods", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
344+
F1("openssl_get_cipher_methods", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
345+
#if defined(HAVE_EVP_PKEY_EC)
346+
F1("openssl_get_curve_names", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
347+
#endif
348+
F1("openssl_get_cert_locations", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING),
336349
FN("pcntl_signal_get_handler", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_OBJECT|MAY_BE_LONG),
337350
FN("preg_replace", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_NULL),
338351
FN("preg_filter", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_NULL),
@@ -406,10 +419,19 @@ static const func_info_t func_infos[] = {
406419
F1("session_encode", MAY_BE_STRING|MAY_BE_FALSE),
407420
F1("session_get_cookie_params", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY),
408421
F1("session_cache_limiter", MAY_BE_STRING|MAY_BE_FALSE),
422+
F1("socket_get_option", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_LONG|MAY_BE_FALSE),
409423
FN("socket_export_stream", MAY_BE_RESOURCE|MAY_BE_FALSE),
424+
F1("socket_addrinfo_lookup", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_FALSE),
425+
F1("socket_addrinfo_explain", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY),
410426
FN("sodium_crypto_kx_client_session_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
411427
FN("sodium_crypto_kx_server_session_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
412428
F0("sodium_crypto_generichash_update", MAY_BE_TRUE),
429+
#if defined(crypto_secretstream_xchacha20poly1305_ABYTES)
430+
FN("sodium_crypto_secretstream_xchacha20poly1305_init_push", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
431+
#endif
432+
#if defined(crypto_secretstream_xchacha20poly1305_ABYTES)
433+
FN("sodium_crypto_secretstream_xchacha20poly1305_pull", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
434+
#endif
413435
F1("class_implements", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
414436
F1("class_parents", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
415437
F1("class_uses", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),

ext/oci8/oci8.stub.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,16 @@ function oci_pconnect(string $username, string $password, ?string $connection_st
326326
*/
327327
function ociplogon(string $username, string $password, ?string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT) {}
328328

329-
/** @param resource|null $connection_or_statement */
329+
/**
330+
* @param resource|null $connection_or_statement
331+
* @return array<string, int|string>|false
332+
* @refcount 1
333+
*/
330334
function oci_error($connection_or_statement = null): array|false {}
331335

332336
/**
333337
* @param resource|null $connection_or_statement
338+
* @return array<string, int|string>|false
334339
* @alias oci_error
335340
* @deprecated
336341
*/

ext/oci8/oci8_arginfo.h

Lines changed: 1 addition & 1 deletion
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: 1bb2deae12b80335372768e1eb21ec86cfddfae9 */
2+
* Stub hash: 46ee8ce62b36639636b4f5126e20a4b4e1df2e25 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0)
55
ZEND_ARG_INFO(0, statement)

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11608,6 +11608,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst,
1160811608
if (op2_info & MAY_BE_ANY) {
1160911609
| IF_NOT_ZVAL_TYPE op2_addr, IS_UNDEF, >1, ZREG_TMP1
1161011610
}
11611+
| SET_EX_OPLINE opline, REG0
1161111612
| LOAD_32BIT_VAL FCARG1w, opline->op2.var
1161211613
| EXT_CALL zend_jit_undefined_op_helper, REG0
1161311614
|1:

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12286,6 +12286,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst,
1228612286
if (op2_info & MAY_BE_ANY) {
1228712287
| IF_NOT_ZVAL_TYPE op2_addr, IS_UNDEF, >1
1228812288
}
12289+
| SET_EX_OPLINE opline, r0
1228912290
| mov FCARG1d, opline->op2.var
1229012291
| EXT_CALL zend_jit_undefined_op_helper, r0
1229112292
|1:

ext/opcache/tests/jit/isset_001.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
ISSET_ISEMPTY_DIM with undefined variable
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function test() {
11+
var_dump(isset($a[$undef]));
12+
}
13+
test();
14+
?>
15+
--EXPECTF--
16+
Warning: Undefined variable $undef in %s on line %d
17+
bool(false)

ext/openssl/openssl.stub.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ function openssl_x509_check_private_key(OpenSSLCertificate|string $certificate,
3939
/** @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $public_key */
4040
function openssl_x509_verify(OpenSSLCertificate|string $certificate, $public_key): int {}
4141

42+
/**
43+
* @return array<string, int|string|array>|false
44+
* @refcount 1
45+
*/
4246
function openssl_x509_parse(OpenSSLCertificate|string $certificate, bool $short_names = true): array|false {}
4347

4448
function openssl_x509_checkpurpose(OpenSSLCertificate|string $certificate, int $purpose, array $ca_info = [], ?string $untrusted_certificates_file = null): bool|int {}
@@ -71,6 +75,10 @@ function openssl_csr_sign(OpenSSLCertificateSigningRequest|string $csr, OpenSSLC
7175
/** @param OpenSSLAsymmetricKey $private_key */
7276
function openssl_csr_new(array $distinguished_names, &$private_key, ?array $options = null, ?array $extra_attributes = null): OpenSSLCertificateSigningRequest|false {}
7377

78+
/**
79+
* @return array<string, string|array>|false
80+
* @refcount 1
81+
*/
7482
function openssl_csr_get_subject(OpenSSLCertificateSigningRequest|string $csr, bool $short_names = true): array|false {}
7583

7684
function openssl_csr_get_public_key(OpenSSLCertificateSigningRequest|string $csr, bool $short_names = true): OpenSSLAsymmetricKey|false {}
@@ -113,6 +121,10 @@ function openssl_pkey_get_private($private_key, ?string $passphrase = null): Ope
113121
*/
114122
function openssl_get_privatekey($private_key, ?string $passphrase = null): OpenSSLAsymmetricKey|false {}
115123

124+
/**
125+
* @return array<string, int|string|array>|false
126+
* @refcount 1
127+
*/
116128
function openssl_pkey_get_details(OpenSSLAsymmetricKey $key): array|false {}
117129

118130
function openssl_pbkdf2(string $password, string $salt, int $key_length, int $iterations, string $digest_algo = "sha1"): string|false {}
@@ -199,11 +211,23 @@ function openssl_seal(string $data, &$sealed_data, &$encrypted_keys, array $publ
199211
*/
200212
function openssl_open(string $data, &$output, string $encrypted_key, $private_key, string $cipher_algo, ?string $iv = null): bool {}
201213

214+
/**
215+
* @return array<int, string>
216+
* @refcount 1
217+
*/
202218
function openssl_get_md_methods(bool $aliases = false): array {}
203219

220+
/**
221+
* @return array<int, string>
222+
* @refcount 1
223+
*/
204224
function openssl_get_cipher_methods(bool $aliases = false): array {}
205225

206226
#ifdef HAVE_EVP_PKEY_EC
227+
/**
228+
* @return array<int, string>|false
229+
* @refcount 1
230+
*/
207231
function openssl_get_curve_names(): array|false {}
208232
#endif
209233

@@ -235,4 +259,8 @@ function openssl_spki_export(string $spki): string|false {}
235259

236260
function openssl_spki_export_challenge(string $spki): string|false {}
237261

262+
/**
263+
* @return array<string, string>
264+
* @refcount 1
265+
*/
238266
function openssl_get_cert_locations(): array {}

ext/openssl/openssl_arginfo.h

Lines changed: 1 addition & 1 deletion
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: b0d7811060ba2499a0c2908aad8ab160cd604043 */
2+
* Stub hash: 3ad007a0b29648c29051f9ee00fe43dd6f2a766d */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_x509_export_to_file, 0, 2, _IS_BOOL, 0)
55
ZEND_ARG_OBJ_TYPE_MASK(0, certificate, OpenSSLCertificate, MAY_BE_STRING, NULL)

ext/sockets/sockets.stub.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,16 @@ function socket_recvfrom(Socket $socket, &$data, int $length, int $flags, &$addr
7070

7171
function socket_sendto(Socket $socket, string $data, int $length, int $flags, string $address, ?int $port = null): int|false {}
7272

73+
/**
74+
* @return array<string, mixed>|int|false
75+
* @refcount 1
76+
*/
7377
function socket_get_option(Socket $socket, int $level, int $option): array|int|false {}
7478

75-
/** @alias socket_get_option */
79+
/**
80+
* @return array<string, mixed>|int|false
81+
* @alias socket_get_option
82+
*/
7683
function socket_getopt(Socket $socket, int $level, int $option): array|int|false {}
7784

7885
/** @param array|string|int $value */
@@ -109,12 +116,20 @@ function socket_recvmsg(Socket $socket, array &$message, int $flags = 0): int|fa
109116

110117
function socket_cmsg_space(int $level, int $type, int $num = 0): ?int {}
111118

119+
/**
120+
* @return array<int, AddressInfo>|false
121+
* @refcount 1
122+
*/
112123
function socket_addrinfo_lookup(string $host, ?string $service = null, array $hints = []): array|false {}
113124

114125
function socket_addrinfo_connect(AddressInfo $address): Socket|false {}
115126

116127
function socket_addrinfo_bind(AddressInfo $address): Socket|false {}
117128

129+
/**
130+
* @return array<string, int|string|array>
131+
* @refcount 1
132+
*/
118133
function socket_addrinfo_explain(AddressInfo $address): array {}
119134

120135
#ifdef PHP_WIN32

ext/sockets/sockets_arginfo.h

Lines changed: 1 addition & 1 deletion
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: 7a34d96387ed5cba14a8a661f31b22bd88b2ec67 */
2+
* Stub hash: bc0f8cd2cab1e077231ed74a9be15a88f5a08e4b */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(1, read, IS_ARRAY, 1)

ext/sodium/libsodium.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ function sodium_crypto_secretbox_open(string $ciphertext, string $nonce, string
152152
#ifdef crypto_secretstream_xchacha20poly1305_ABYTES
153153
function sodium_crypto_secretstream_xchacha20poly1305_keygen(): string {}
154154

155+
/** @return array<int, string> */
155156
function sodium_crypto_secretstream_xchacha20poly1305_init_push(string $key): array {}
156157

157158
function sodium_crypto_secretstream_xchacha20poly1305_push(string &$state, string $message, string $additional_data = "", int $tag = SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_MESSAGE): string {}
158159

159160
function sodium_crypto_secretstream_xchacha20poly1305_init_pull(string $header, string $key): string {}
160161

162+
/** @return array<int, int|string>|false */
161163
function sodium_crypto_secretstream_xchacha20poly1305_pull(string &$state, string $ciphertext, string $additional_data = ""): array|false {}
162164

163165
function sodium_crypto_secretstream_xchacha20poly1305_rekey(string &$state): void {}

ext/sodium/libsodium_arginfo.h

Lines changed: 1 addition & 1 deletion
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: ec5e4bdb70ff9416e66b6b8ffd30063a692be910 */
2+
* Stub hash: 83363d4c65a99ae18e8e475524ce7aa20a768556 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_sodium_crypto_aead_aes256gcm_is_available, 0, 0, _IS_BOOL, 0)
55
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)