Hi Rowan, As Kamil says, a potential 1-year deprecation is probably not enough, > and we need to keep in mind that many libraries and applications need to > support multiple versions of PHP at once. If they are to become errors > in 9.0, there should be some way to write code that will run on both 8.0 > and 9.0. >
Yes, I agree that we should make the upgrade path of libraries as easy as possible, and I also agree that probably a 1-year deprecation is not enough.. although the suggested alternatives would be available 2 years in advance of the removal so this would allow a 2 year window for fixing code using the deprecated functionality. > The only ones in this list I can see that being easy for are > assert_options (you can write a polyfill for the new assert_set_option, > and switch all code to use that), and get_class() / get_parent_class() > (you can start passing $this right away). > As far as I see there are more deprecations which are easy to fix. In order to see the whole picture better, let's group the functions based on how a possible upgrade path would look like: - With existing suggested alternative: - get_class() and get_parent_class() - pg_fetch_result(), pg_field_prtlen(), and pg_field_is_null() - Phar::setStub() - ReflectionMethod::__construct() - ReflectionProperty::setValue() - session_set_save_handler() (because the OO and procedural style are interchangeable) - stream_context_set_option() - Polyfillable: - assert_options() - ldap_connect() - ldap_exop() - Requires conditional version check: - DatePeriod::__construct() - IntlCalendar::set() - IntlGregorianCalendar::__construct() (I intentionally did not include the FFI related methods, since this section is TBD) As it can be seen, most deprecations have an existing alternative. The 2nd category (polyfillable ones) mostly contains very little used functions, especially because the deprecation of ldap_connect() only affects PHP compiled with OracleLDAP. The category which requires conditional PHP version checks is indeed the most problematic one. Probably it's not a surprise that it only includes methods because it's not possible to polyfill methods according to my knowledge. The good news is that IntlCalendar::set() and IntlGregorianCalendar::__construct() seem to be very little used functionality. So in my opinion, DatePeriod::__construct() has the worst upgrade path, the rest are either easy or shouldn't cause much issues. Since the constructor is set to be removed completely based on Derick's preference, we should discuss with him whether it's worth to leave the public function __construct(DateTimeInterface $start, DateInterval $interval, DateTimeInterface $end, int $options = 0) {} signature alive so that people can change their code to use this instead of the other two signatures. I have particular concerns about session_set_save_handler. The impact is > hard to estimate, because it will be used directly in applications more > often than in libraries. The multiple parameter signature is much older, > dating back to PHP 4, with the object form added only in PHP 5.4. That > may seem a long time ago, but there is currently no incentive to change > existing code between the styles, and doing so requires a reasonable > amount of work. > Yes, but changing session_set_save_handler() to session_set_save_handlers() should be a reasonably small effort, isn't it? I understand that it's going to affect lots of codebases, however other PHP 8.x deprecations are much more difficult to fix than this one would be. > On a different point, I think "assert_options" is a peculiar name for > either setting or getting a single option, and would suggest it be > replaced with two new functions, assert_get_option and > assert_set_option. Replacing both variants also makes it easier for > users to find everywhere they've used it, and polyfill both variants, > rather than having to examine each. > Yes, I agree that the assert_options() name is at least weird but I wouldn't like to include changes into this RFC which are not strictly related to overloaded signatures. Just like in case of implode(), the 1-parameter version of assert_options() could be added to the PHP 8.3/8.4 deprecations RFC though. Regards, Máté