[php-src] Issue #19525: Inconsistent result stream with or without a function wrapper

From: Date: Wed, 20 Aug 2025 07:47:21 +0000
Subject: [php-src] Issue #19525: Inconsistent result stream with or without a function wrapper
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250582@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/19525 Author: YuanchengJiang ### Description The following code: ```php <?php class Loader { public $context; private $position; private $data; public function stream_open($path, $mode, $options, &$opened_path) { $this->data = '<' . "?php \n\"\";ll l\n ?" . '>'; $this->position = 0; return true; } function stream_read($count) { $ret = substr($this->data, $this->position, $count); $this->position += strlen($ret); return $ret; } function stream_eof() { return $this->position >= strlen($this->data); } function stream_flush() { var_dump("flush!"); } function stream_close() { @unlink(__DIR__."/bug38779.txt"); var_dump("close!"); } } stream_wrapper_register('Loader', 'Loader'); $fp = fopen ('Loader://qqq.php', 'r'); $filename = __DIR__."/bug38779.txt"; $fp1 = fopen($filename, "w"); fwrite($fp1, "<"."?php blah blah?".">"); fclose($fp1); include $filename; ``` Resulted in this output: ``` Parse error: syntax error, unexpected identifier "blah" in /tmp/bug38779.txt on line 1 string(6) "close!" ``` The following code: ```php <?php function foo() { class Loader { public $context; private $position; private $data; public function stream_open($path, $mode, $options, &$opened_path) { $this->data = '<' . "?php \n\"\";ll l\n ?" . '>'; $this->position = 0; return true; } function stream_read($count) { $ret = substr($this->data, $this->position, $count); $this->position += strlen($ret); return $ret; } function stream_eof() { return $this->position >= strlen($this->data); } function stream_flush() { var_dump("flush!"); } function stream_close() { @unlink(__DIR__."/bug38779.txt"); var_dump("close!"); } } stream_wrapper_register('Loader', 'Loader'); $fp = fopen ('Loader://qqq.php', 'r'); $filename = __DIR__."/bug38779.txt"; $fp1 = fopen($filename, "w"); fwrite($fp1, "<"."?php blah blah?".">"); fclose($fp1); include $filename; } foo(); ``` Resulted in this output: ``` Parse error: syntax error, unexpected identifier "blah" in /tmp/bug38779.txt on line 1 ``` ### PHP Version ```plain nightly ``` ### Operating System _No response_

« previous php.bugs (#250582) next »