On 11.02.2021 at 05:57, Brent Roose wrote:
> The chagelog for PHP 8.1 lists the two following changes:
>
>
> - Fileinfo:
> . The fileinfo functions now accept and return, respectively, finfo objects
> instead of resources.
>
> - IMAP:
> . The IMAP functions now accept and return, respectively, IMAPConnection objects
> instead of resources.
>
> I suppose these changes are part of the move away from "resources everywhere" ? I was wondering whether these function will still accept resource objects in PHP 8, or if support for them is completely removed.
>
> I tried searching externals.io <http://externals.io/> for a previous discussion but could only find https://externals.io/message/111297#111298 <https://externals.io/message/111297#111298>
Yes, these changes fall under the general resource to object conversion
(which is IMO generally a very good move), and the respective resources
are completely removed. However, it seems that the incompatibility is
not only wrt. is_resource() checks, which can easily be resolved (and
may not be an issue for some code bases), but also regarding conversion
to int. It might be sensible to implement cast_object handlers for
those classes, which may be deprecated.
The SSH2 extension would need particular attention in this regard, since
it deliberately uses resource to int/string conversion for its wrappers,
and even looks up the resources from the regular_list[1].
[1]
<https://github.com/php/pecl-networking-ssh2/blob/93265d71bdeb23350e8320126c7949ed791310df/ssh2_fopen_wrappers.c#L26-L36>
--
Christoph