Skip to content

main: refactor userstream method calling #19312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Zend/tests/arginfo_zpp_mismatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function skipFunction($function): bool {
/* terminates script */
|| $function === 'exit'
|| $function === 'die'
|| $function === 'zend_trigger_bailout'
/* intentionally violate invariants */
|| $function === 'zend_create_unterminated_string'
|| $function === 'zend_test_array_return'
Expand Down
21 changes: 9 additions & 12 deletions Zend/tests/bug41421.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ class wrapper {
return true;
}
function stream_eof() {
throw new exception();
throw new Exception('cannot eof');
}
}

stream_wrapper_register("wrap", "wrapper");
$fp = fopen("wrap://...", "r");
feof($fp);

echo "Done\n";
?>
--EXPECTF--
Warning: feof(): wrapper::stream_eof is not implemented! Assuming EOF in %s on line %d
try {
feof($fp);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

Fatal error: Uncaught Exception in %s:%d
Stack trace:
#0 [internal function]: wrapper->stream_eof()
#1 %s(%d): feof(Resource id #%d)
#2 {main}
thrown in %s on line %d
?>
--EXPECT--
Exception: cannot eof
2 changes: 1 addition & 1 deletion ext/standard/tests/file/userstreams_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ ftruncate(): Argument #2 ($size) must be greater than or equal to 0
------ stream_truncate bad return: -------
truncation with new_size=0

Warning: ftruncate(): test_wrapper_bad::stream_truncate did not return a boolean! in %s on line %d
Warning: ftruncate(): test_wrapper_bad::stream_truncate value must be of type bool, string given in %s on line %d
bool(false)
19 changes: 19 additions & 0 deletions ext/standard/tests/streams/user-stream-dir-open-bailout.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Bailout (E_ERROR) during UserStream Dir Open
--EXTENSIONS--
zend_test
--FILE--
<?php

class FailStream {
public $context;
public function dir_opendir(string $url, int $options) {
zend_trigger_bailout();
}
}
stream_wrapper_register('mystream', 'FailStream');
opendir('mystream://foo');
echo 'Done';
?>
--EXPECTF--
Fatal error: Bailout in %s on line %d
22 changes: 0 additions & 22 deletions ext/standard/tests/streams/user-stream-error.phpt

This file was deleted.

19 changes: 19 additions & 0 deletions ext/standard/tests/streams/user-stream-open-bailout.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Bailout (E_ERROR) during UserStream Open
--EXTENSIONS--
zend_test
--FILE--
<?php

class FailStream {
public $context;
public function stream_open($path, $mode, $options, &$opened_path) {
zend_trigger_bailout();
}
}
stream_wrapper_register('mystream', 'FailStream');
fopen('mystream://foo', 'r');
echo 'Done';
?>
--EXPECTF--
Fatal error: Bailout in %s on line %d
7 changes: 7 additions & 0 deletions ext/zend_test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ static ZEND_FUNCTION(zend_test_func)
EX(func) = NULL;
}

static ZEND_FUNCTION(zend_trigger_bailout)
{
ZEND_PARSE_PARAMETERS_NONE();

zend_error(E_ERROR, "Bailout");
}

static ZEND_FUNCTION(zend_test_array_return)
{
ZEND_PARSE_PARAMETERS_NONE();
Expand Down
2 changes: 2 additions & 0 deletions ext/zend_test/test.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ enum ZendTestIntEnum: int {
case Baz = -1;
}

function zend_trigger_bailout(): never {}

function zend_test_array_return(): array {}

/** @genstubs-expose-comment-block
Expand Down
7 changes: 6 additions & 1 deletion ext/zend_test/test_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/zip/tests/bug53603.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ $a = $zip->extractTo('teststream://test');
var_dump($a);
?>
--EXPECTF--
Warning: ZipArchive::extractTo(teststream://test/foo): Failed to open stream: "TestStream::stream_open" call failed in %s on line %d
Warning: ZipArchive::extractTo(teststream://test/foo): Failed to open stream: "TestStream::stream_open" is not implemented in %s on line %d
bool(false)
Loading