@@ -74,14 +74,14 @@ PHP_FUNCTION(stream_socket_pair)
7474 close (pair [0 ]);
7575 close (pair [1 ]);
7676 php_error_docref (NULL , E_WARNING , "Failed to open stream from socketpair" );
77- RETURN_FALSE ;
77+ RETURN_FALSE ;
7878 }
7979 s2 = php_stream_sock_open_from_socket (pair [1 ], 0 );
8080 if (s2 == NULL ) {
8181 php_stream_free (s1 , PHP_STREAM_FREE_CLOSE );
8282 close (pair [1 ]);
8383 php_error_docref (NULL , E_WARNING , "Failed to open stream from socketpair" );
84- RETURN_FALSE ;
84+ RETURN_FALSE ;
8585 }
8686
8787 array_init (return_value );
@@ -1645,10 +1645,14 @@ PHP_FUNCTION(stream_isatty)
16451645
16461646 php_stream_from_zval (stream , zsrc );
16471647
1648- if (php_stream_can_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT ) == SUCCESS ) {
1649- php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT , (void * )& fileno , 0 );
1650- } else if (php_stream_can_cast (stream , PHP_STREAM_AS_FD ) == SUCCESS ) {
1651- php_stream_cast (stream , PHP_STREAM_AS_FD , (void * )& fileno , 0 );
1648+ /* get the fd.
1649+ * NB: Most other code will NOT use the PHP_STREAM_CAST_INTERNAL flag when casting.
1650+ * It is only used here so that the buffered data warning is not displayed.
1651+ */
1652+ if (php_stream_can_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL ) == SUCCESS ) {
1653+ php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * )& fileno , 0 );
1654+ } else if (php_stream_can_cast (stream , PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL ) == SUCCESS ) {
1655+ php_stream_cast (stream , PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL , (void * )& fileno , 0 );
16521656 } else {
16531657 RETURN_FALSE ;
16541658 }
@@ -1686,13 +1690,15 @@ PHP_FUNCTION(sapi_windows_vt100_support)
16861690
16871691 php_stream_from_zval (stream , zsrc );
16881692
1689- if (php_stream_can_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT ) == SUCCESS ) {
1690- php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT , (void * )& fileno , 0 );
1691- }
1692- else if (php_stream_can_cast (stream , PHP_STREAM_AS_FD ) == SUCCESS ) {
1693- php_stream_cast (stream , PHP_STREAM_AS_FD , (void * )& fileno , 0 );
1694- }
1695- else {
1693+ /* get the fd.
1694+ * NB: Most other code will NOT use the PHP_STREAM_CAST_INTERNAL flag when casting.
1695+ * It is only used here so that the buffered data warning is not displayed.
1696+ */
1697+ if (php_stream_can_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL ) == SUCCESS ) {
1698+ php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * )& fileno , 0 );
1699+ } else if (php_stream_can_cast (stream , PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL ) == SUCCESS ) {
1700+ php_stream_cast (stream , PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL , (void * )& fileno , 0 );
1701+ } else {
16961702 if (!enable_is_null ) {
16971703 php_error_docref (
16981704 NULL ,
0 commit comments