File tree 1 file changed +33
-0
lines changed
ext/standard/tests/streams
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Casting a stream can lose data and needs to emit a warning
3
+ --FILE--
4
+ <?php
5
+
6
+ $ tempnam = tempnam (sys_get_temp_dir (), 'test ' );
7
+
8
+ $ stream = popen ('echo 1; echo 2; rm ' . escapeshellarg ($ tempnam ), 'r ' );
9
+
10
+ do {
11
+ usleep (10 );
12
+ clearstatcache ();
13
+ } while (file_exists ($ tempnam ));
14
+
15
+ // fills the read buffer with up to 8192 bytes
16
+ fgets ($ stream );
17
+
18
+ // cast $stream and read fd until eof. Print each line that was read, prefixed with "proc open stdin:"
19
+ $ process = proc_open (
20
+ 'sed "s/^/proc open stdin:/" ' ,
21
+ [
22
+ 0 => $ stream ,
23
+ 1 => ['pipe ' , 'w ' ],
24
+ ],
25
+ $ pipes ,
26
+ );
27
+
28
+ var_dump (stream_get_contents ($ pipes [1 ]));
29
+
30
+ ?>
31
+ --EXPECTF--
32
+ Warning: proc_open(): 2 bytes of buffered data lost during stream conversion! in %s on line %d
33
+ string(0) ""
You can’t perform that action at this time.
0 commit comments