Hello internals,
I would like to propose a short RFC about warning on conversions from resources to strings,
similar to what a conversion from array to string does.
Let me know what you think about it:
https://wiki.php.net/rfc/warn-resource-to-string
Best regards,
Gina P. Banyard
I would like to propose a short RFC about warning on conversions from resources to strings,
similar to what a conversion from array to string does.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
Christoph
I would like to propose a short RFC about warning on conversions from resources to strings,
similar to what a conversion from array to string does.Let me know what you think about it:
https://wiki.php.net/rfc/warn-resource-to-stringThe 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.
I guess that it could always use the integer representation of the resource.
Or, more sensibly, be converted to an opaque object that implements a __toString() method.
I have encountered some other issues in the engine exposed by this conversion,
the biggest one being array_diff/array_intersect, so I could also spend some time working on that extension.
Best regards,
Gina P. Banyard
Let me know what you think about it:
https://wiki.php.net/rfc/warn-resource-to-stringThe 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.I guess that it could always use the integer representation of the resource.
Or, more sensibly, be converted to an opaque object that implements a __toString() method.
The former would require to change existing code (I presume that this
"feature" is used quite often); the latter would be something that
wouldn't break such code, and be a good idea generally.
I have encountered some other issues in the engine exposed by this conversion,
the biggest one being array_diff/array_intersect, so I could also spend some time working on that extension.
That would be great. I think that ssh2 is one of the more important
PECL extensions, but unfortunately in low maintenance mode. However,
I'm not sure about the future of libssh2[1].
[1] https://github.com/libssh2/libssh2/discussions/1249
Christoph
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.
Let me know what you think about it:
https://wiki.php.net/rfc/warn-resource-to-stringThe 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.
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