Skip to content

Commit c7a098f

Browse files
committed
Deprecate mysqli::init()
In favor of parent::__construct(). Part of https://wiki.php.net/rfc/deprecations_php_8_1.
1 parent bf0c1ce commit c7a098f

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

ext/mysqli/mysqli.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ public function get_server_info(): string {}
158158
*/
159159
public function get_warnings(): mysqli_warning|false {}
160160

161-
/** @return bool|null */
161+
/**
162+
* @deprecated
163+
* @return bool|null
164+
* */
162165
public function init() {}
163166

164167
/**

ext/mysqli/mysqli_arginfo.h

Lines changed: 2 additions & 2 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: 2f96f80badee5623220fd720e91aec7795e32723 */
2+
* Stub hash: 3a51cb95700990b4722dfefe341aeeb0b28461d7 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING)
55
ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0)
@@ -989,7 +989,7 @@ static const zend_function_entry class_mysqli_methods[] = {
989989
#endif
990990
ZEND_ME_MAPPING(get_server_info, mysqli_get_server_info, arginfo_class_mysqli_get_server_info, ZEND_ACC_PUBLIC)
991991
ZEND_ME_MAPPING(get_warnings, mysqli_get_warnings, arginfo_class_mysqli_get_warnings, ZEND_ACC_PUBLIC)
992-
ZEND_ME(mysqli, init, arginfo_class_mysqli_init, ZEND_ACC_PUBLIC)
992+
ZEND_ME(mysqli, init, arginfo_class_mysqli_init, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
993993
ZEND_ME_MAPPING(kill, mysqli_kill, arginfo_class_mysqli_kill, ZEND_ACC_PUBLIC)
994994
ZEND_ME_MAPPING(multi_query, mysqli_multi_query, arginfo_class_mysqli_multi_query, ZEND_ACC_PUBLIC)
995995
ZEND_ME_MAPPING(more_results, mysqli_more_results, arginfo_class_mysqli_more_results, ZEND_ACC_PUBLIC)

ext/mysqli/tests/bug33263.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require_once('skipifconnectfailure.inc');
1313
class test extends mysqli
1414
{
1515
public function __construct($host, $user, $passwd, $db, $port, $socket) {
16-
parent::init();
16+
parent::__construct();
1717
parent::real_connect($host, $user, $passwd, $db, $port, $socket);
1818
}
1919
}

ext/mysqli/tests/bug46109.phpt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ require_once('skipifconnectfailure.inc');
88
?>
99
--FILE--
1010
<?php
11-
require_once("connect.inc");
11+
require_once("connect.inc");
1212

13-
$mysqli = new mysqli();
14-
$mysqli->init();
15-
$mysqli->init();
16-
echo "done";
13+
$mysqli = new mysqli();
14+
$mysqli->init();
15+
$mysqli->init();
16+
echo "done";
1717
?>
18-
--EXPECT--
18+
--EXPECTF--
19+
Deprecated: Method mysqli::init() is deprecated in %s on line %d
20+
21+
Deprecated: Method mysqli::init() is deprecated in %s on line %d
1922
done

ext/mysqli/tests/connect.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
$flags = ($enable_env_flags) ? $connect_flags : 0;
9393

9494
if ($flags !== false) {
95-
parent::init();
95+
parent::__construct();
9696
$this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
9797
} else {
9898
parent::__construct($host, $user, $passwd, $db, $port, $socket);

0 commit comments

Comments
 (0)