@@ -1384,6 +1384,8 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
13841384 php_stream * intstream = NULL ;
13851385 int call_result ;
13861386 int ret = FAILURE ;
1387+ /* If we are checking if the stream can cast, no return pointer is provided, so do not emit errors */
1388+ bool report_errors = retptr ;
13871389
13881390 ZVAL_STRINGL (& func_name , USERSTREAM_CAST , sizeof (USERSTREAM_CAST )- 1 );
13891391
@@ -1400,22 +1402,28 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
14001402
14011403 do {
14021404 if (call_result == FAILURE ) {
1403- php_error_docref (NULL , E_WARNING , "%s::" USERSTREAM_CAST " is not implemented!" ,
1404- ZSTR_VAL (us -> wrapper -> ce -> name ));
1405+ if (report_errors ) {
1406+ php_error_docref (NULL , E_WARNING , "%s::" USERSTREAM_CAST " is not implemented!" ,
1407+ ZSTR_VAL (us -> wrapper -> ce -> name ));
1408+ }
14051409 break ;
14061410 }
14071411 if (!zend_is_true (& retval )) {
14081412 break ;
14091413 }
14101414 php_stream_from_zval_no_verify (intstream , & retval );
14111415 if (!intstream ) {
1412- php_error_docref (NULL , E_WARNING , "%s::" USERSTREAM_CAST " must return a stream resource" ,
1413- ZSTR_VAL (us -> wrapper -> ce -> name ));
1416+ if (report_errors ) {
1417+ php_error_docref (NULL , E_WARNING , "%s::" USERSTREAM_CAST " must return a stream resource" ,
1418+ ZSTR_VAL (us -> wrapper -> ce -> name ));
1419+ }
14141420 break ;
14151421 }
14161422 if (intstream == stream ) {
1417- php_error_docref (NULL , E_WARNING , "%s::" USERSTREAM_CAST " must not return itself" ,
1418- ZSTR_VAL (us -> wrapper -> ce -> name ));
1423+ if (report_errors ) {
1424+ php_error_docref (NULL , E_WARNING , "%s::" USERSTREAM_CAST " must not return itself" ,
1425+ ZSTR_VAL (us -> wrapper -> ce -> name ));
1426+ }
14191427 intstream = NULL ;
14201428 break ;
14211429 }
0 commit comments