@@ -1384,6 +1384,8 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
1384
1384
php_stream * intstream = NULL ;
1385
1385
int call_result ;
1386
1386
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 ;
1387
1389
1388
1390
ZVAL_STRINGL (& func_name , USERSTREAM_CAST , sizeof (USERSTREAM_CAST )- 1 );
1389
1391
@@ -1400,22 +1402,28 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
1400
1402
1401
1403
do {
1402
1404
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
+ }
1405
1409
break ;
1406
1410
}
1407
1411
if (!zend_is_true (& retval )) {
1408
1412
break ;
1409
1413
}
1410
1414
php_stream_from_zval_no_verify (intstream , & retval );
1411
1415
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
+ }
1414
1420
break ;
1415
1421
}
1416
1422
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
+ }
1419
1427
intstream = NULL ;
1420
1428
break ;
1421
1429
}
0 commit comments