Re: [PHP-DEV] [PHP_DEV] [RFC] Add file_descriptor() function

2023-01-17 Thread Tim Düsterhus

Hi

On 1/16/23 16:01, G. P. B. wrote:

useful when interacting with a USB device.


Can some example code be added to the RFC text for those who don't 
understand any French?


Best regards
Tim Düsterhus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] [PHP_DEV] [RFC] Add file_descriptor() function

2023-01-16 Thread Bob Weinand

> Am 16.01.2023 um 16:01 schrieb G. P. B. :
> 
> 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

[PHP-DEV] [PHP_DEV] [RFC] Add file_descriptor() function

2023-01-16 Thread G. P. B.
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