Re: [RFC] Warn on conversions from resource to string
| From: | Casper Langemeijer | Date: | Tue, 24 Sep 2024 20:00:24 +0000 |
| Subject: | Re: [RFC] Warn on conversions from resource to string | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-125672@lists.php.net to get a copy of this message | ||
Hi,
ssh2 maintainer here. Low maintenance is indeed somewhat accurate. I review and merge PR's,
have done some minor work on it, and do releases sometimes. Some others on this list have done minor
work on it too.
On Tue, Sep 24, 2024, at 19:53, Christoph M. Becker wrote:
> >>> Let me know what you think about it:
> >>> https://wiki.php.net/rfc/warn-resource-to-string
> >>
> >> The ssh2 wrappers[1] used to use this "feature". I'm not sure whether
> >> there is another way to accomplish the same now. If not, that should
> >> probably be done prior to emitting a warning for the resource to string
> >> conversion.
> >>
> >> [1] https://www.php.net/manual/en/wrappers.ssh2.php
Indeed, the ssh2 extension uses this.
I'm not sure what warnings on conversion to string would bring for PHP developers though.
The places where resource values are still used are all in very technical functions. Most developers
will use some wrapper class, or of not very likely know what they are doing. Personally I've
never accidentally echo'ed a resource and wished it would have registered in my monitoring
systems.
Secondly, I don't think it happens very often. (not nearly as much as array to string
conversion has hit me)
As a third argument against this RFC: We're moving away from the resource type. Processes,
sockets, curl and possibly others that have escaped my attention have already been changed to
objects. I've already concluded that ssh2 should follow and use an object, at least before
resource will be removed in core. I've noticed stream also still uses resource.
Greetings, Casper