Re: [PHP_DEV] [RFC] Add file_descriptor() function
| From: | Bob Weinand | Date: | Mon, 16 Jan 2023 15:32:43 +0000 |
| Subject: | Re: [PHP_DEV] [RFC] Add file_descriptor() function | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119279@lists.php.net to get a copy of this message | ||
> Am 16.01.2023 um 16:01 schrieb G. P. B. <george.banyard@gmail.com>:
>
> Hello internals,
>
> I would like to start the discussion about the "Add file_descriptor()
> function" RFC:
> https://wiki.php.net/rfc/file-descriptor-function
>
> This RFC proposes the addition of the file_descriptor() function to
> retrieve the underlying file descriptor of stream if it exists. This is
> useful when interacting with a USB device.
>
> Best regards,
>
> George P. Banyard
Hey George,
I like the idea. However two questions:
Why is it its own function and not part of stream_get_meta_data()? (which you anyway want to check
to ensure that it's the proper stream type)
Why are all resources throwing a TypeError and not only resources which aren't streams? I could
imagine calling that function to check whether the stream is in memory or backed by a fd for
example. I'd propose to return a proper checkable value like -1 in that case.
Thanks,
Bob