# [RFC] [Vote] Resource to object conversion

- Thread: https://externals.io/message/122116
- Original archive: https://news-web.php.net/php.internals/122116
- Started by kocsismate90@gmail.com on 2024-01-05T08:18:38+00:00
- Messages: 6
- RFC: Resource to object conversion (Accepted) — https://externals.io/rfc/resource_to_object_conversion.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #122116 — kocsismate90@gmail.com — 2024-01-05T08:18:38+00:00

URL: https://externals.io/message/122116#122116

Hi Everyone,

As mentioned a few days ago, I've just opened the vote about resource to
object conversion.
The vote will be open for 2 weeks.

RFC link: https://wiki.php.net/rfc/resource_to_object_conversion
Discussion thread: https://externals.io/message/121660

Regards,
Máté

---

## #122123 — Kamil Tekiela — 2024-01-05T13:41:34+00:00

URL: https://externals.io/message/122116#122123 · In reply to: #122116

Hi Máté,

I have one question. If the primary stream resources get the
is_resource hack, what hampers the changes from landing in a minor
version? I'd assume that the migration would be mostly seamless. Is it
the get_resource_type checks? Is it because is_resource also checks
whether the resource is closed?

Regards,
Kamil

---

## #122139 — kocsismate90@gmail.com — 2024-01-09T08:08:08+00:00

URL: https://externals.io/message/122116#122139 · In reply to: #122123

Hi Kamil,

Good question... After the workaround, I think there's less reason to
do the conversion in the next major version indeed. To be honest,
I am not able to recall any use-case where a real BC break could happen.
I mean, there is a very tiny one where resources can be casted to
integers, while objects by default cannot be, but this problem is also
easily solvable (and Nikita had to do it for CurlHandle in the past),
so I don't have any other idea.

In my opinion, the main argument for converting stream resources to objects
in a major version is the "marketing value" of this achievement and possibly
the unintended side-effects/edge cases which we don't yet foresee.

Regards,
Máté

---

## #122186 — kocsismate90@gmail.com — 2024-01-19T10:08:50+00:00

URL: https://externals.io/message/122116#122186 · In reply to: #122116

Hi Everyone,

I've just closed the votes with the following outcomes:
- The primary vote for the described approach for converting resources to
objects was accepted unanimously (30 yes, 0 no)
- Primary stream resources are going to be migrated in a major version,
rather in any minor or major version (23 vs. 7 votes)
- Auxiliary stream resources are going to be migrated in a major version,
rather in any minor or major version (16 vs. 14 votes)
- The Process resource is going to be migrated in the next major version,
rather in the next minor or major version (15 vs. 14 votes)
- Resources of other extensions are going to be migrated in any minor or
major version, rather than in any major version (17 vs. 12 votes)

Thanks to everyone who participated in the discussion or the vote.

Regards,
Máté

---

## #122256 — Nicolas Grekas — 2024-01-25T14:13:54+00:00

URL: https://externals.io/message/122116#122256 · In reply to: #122186

Hello Mate,

I've just closed the votes with the following outcomes:
> - The primary vote for the described approach for converting resources to
> objects was accepted unanimously (30 yes, 0 no)
> - Primary stream resources are going to be migrated in a major version,
> rather in any minor or major version (23 vs. 7 votes)
> - Auxiliary stream resources are going to be migrated in a major version,
> rather in any minor or major version (16 vs. 14 votes)
> - The Process resource is going to be migrated in the next major version,
> rather in the next minor or major version (15 vs. 14 votes)
> - Resources of other extensions are going to be migrated in any minor or
> major version, rather than in any major version (17 vs. 12 votes)
>

Congrats for this result :)

I just had a look at the Symfony codebase and FYI we do use
cast-to-integers for a few resources:

- for curl - that's already supported by CurlHandle so this is seamless
- for DBA, because dba_list() <https://www.php.net/dba_list> works by
resourceid
- for resources created by `stream_socket_server()` and `stream_socket_accept()`

I only checked situations where the resource id is used as an index in an
array, there might be some others (but not a lot, if any).

It looks like we should implement the cast to int for these resource types
at least.

Cheers,
Nicolas

---

## #122277 — kocsismate90@gmail.com — 2024-02-04T06:47:03+00:00

URL: https://externals.io/message/122116#122277 · In reply to: #122256

Hi Nicolas,

- for curl - that's already supported by CurlHandle so this is seamless
> - for DBA, because dba_list() <https://www.php.net/dba_list> works by
> resourceid
> - for resources created by `stream_socket_server()` and
> `stream_socket_accept()`
>
> I only checked situations where the resource id is used as an index in an
> array, there might be some others (but not a lot, if any).
>
> It looks like we should implement the cast to int for these resource types
> at least.
>

Thank you very much for your research, this is very valuable information!
Surely, we will implement the necessary code to keep
supporting these use-cases.

Regards,
Máté
