1--TEST--
2Casting a stream can lose data and needs to emit a warning
3--SKIPIF--
4<?php
5if (PHP_OS_FAMILY === "Windows") die("skip non-Windows tests (popen cannot delete file as open in cmd.exe)");
6?>
7--FILE--
8<?php
9
10$tempnam = tempnam(sys_get_temp_dir(), 'test');
11
12$stream = popen('echo 1; echo 2; rm ' . escapeshellarg($tempnam), 'r');
13
14do {
15    usleep(10);
16    clearstatcache();
17} while (file_exists($tempnam));
18
19// fills the read buffer with up to 8192 bytes
20fgets($stream);
21
22// cast $stream and read fd until eof. Print each line that was read, prefixed with "proc open stdin:"
23$process = proc_open(
24    'sed "s/^/proc open stdin:/"',
25    [
26        0 => $stream,
27        1 => ['pipe', 'w'],
28    ],
29    $pipes,
30);
31
32var_dump(stream_get_contents($pipes[1]));
33
34?>
35--EXPECTF--
36Warning: proc_open(): 2 bytes of buffered data lost during stream conversion! in %s on line %d
37string(0) ""
38