1--TEST--
2Test trampoline for curl option CURLOPT_READFUNCTION
3--EXTENSIONS--
4curl
5--FILE--
6<?php
7
8class TrampolineTest {
9    public function __call(string $name, array $arguments) {
10        echo 'Trampoline for ', $name, PHP_EOL;
11	    return 0;
12    }
13}
14$o = new TrampolineTest();
15$callback = [$o, 'trampoline'];
16
17$sFileBase  = __DIR__.DIRECTORY_SEPARATOR.'curl_read_trampoline';
18$sReadFile  = $sFileBase.'_in.tmp';
19$sWriteFile = $sFileBase.'_out.tmp';
20$sWriteUrl  = 'file://'.$sWriteFile;
21
22file_put_contents($sReadFile,'contents of tempfile');
23$hReadHandle = fopen($sReadFile, 'r');
24
25$oCurl = curl_init();
26curl_setopt($oCurl, CURLOPT_URL,          $sWriteUrl);
27curl_setopt($oCurl, CURLOPT_UPLOAD,       1);
28curl_setopt($oCurl, CURLOPT_READFUNCTION, $callback);
29curl_setopt($oCurl, CURLOPT_INFILE,       $hReadHandle );
30curl_exec($oCurl);
31curl_close($oCurl);
32
33fclose ($hReadHandle);
34
35$sOutput = file_get_contents($sWriteFile);
36var_dump($sOutput);
37
38?>
39--CLEAN--
40<?php
41$sFileBase  = __DIR__.DIRECTORY_SEPARATOR.'curl_read_trampoline';
42$sReadFile  = $sFileBase.'_in.tmp';
43$sWriteFile = $sFileBase.'_out.tmp';
44@unlink($sReadFile);
45@unlink($sWriteFile);
46?>
47--EXPECT--
48Trampoline for trampoline
49string(0) ""
50