From 2bc23cc6e3431f92652dcbbacb10b6c5b6346bf3 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 8 Jul 2021 16:03:47 +0200 Subject: [PATCH] Deprecate imap NIL constant Part of https://wiki.php.net/rfc/deprecations_php_8_1. --- UPGRADING | 4 ++++ ext/imap/php_imap.c | 2 +- ext/imap/tests/imap_open_error.phpt | 2 +- ext/imap/tests/nil_constant.phpt | 11 +++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 ext/imap/tests/nil_constant.phpt diff --git a/UPGRADING b/UPGRADING index a2426ad40cc..aad55c83197 100644 --- a/UPGRADING +++ b/UPGRADING @@ -350,6 +350,10 @@ PHP 8.1 UPGRADE NOTES instead. RFC: https://wiki.php.net/rfc/deprecations_php_8_1 +- IMAP: + . The NIL constant has been deprecated. Use 0 instead. + RFC: https://wiki.php.net/rfc/deprecations_php_8_1 + - Intl: . Calling IntlCalendar::roll() with bool argument is deprecated. Pass 1 and -1 instead of true and false respectively. diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 8a57d39cb60..37d4681d484 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -491,7 +491,7 @@ PHP_MINIT_FUNCTION(imap) imap_object_handlers.clone_obj = NULL; /* lets allow NIL */ - REGISTER_LONG_CONSTANT("NIL", NIL, CONST_PERSISTENT | CONST_CS); + REGISTER_LONG_CONSTANT("NIL", NIL, CONST_PERSISTENT | CONST_CS | CONST_DEPRECATED); /* plug in our gets */ mail_parameters(NIL, SET_GETS, (void *) NIL); diff --git a/ext/imap/tests/imap_open_error.phpt b/ext/imap/tests/imap_open_error.phpt index 8cd9c385cf7..965109db5e8 100644 --- a/ext/imap/tests/imap_open_error.phpt +++ b/ext/imap/tests/imap_open_error.phpt @@ -23,7 +23,7 @@ try { } try { - imap_open('', '', '', NIL, -1); + imap_open('', '', '', 0, -1); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } diff --git a/ext/imap/tests/nil_constant.phpt b/ext/imap/tests/nil_constant.phpt new file mode 100644 index 00000000000..dbf07aa2b00 --- /dev/null +++ b/ext/imap/tests/nil_constant.phpt @@ -0,0 +1,11 @@ +--TEST-- +NIL constant is deprecated +--EXTENSIONS-- +imap +--FILE-- + +--EXPECTF-- +Deprecated: Constant NIL is deprecated in %s on line %d +int(0)