Skip to content

Commit 48981f4

Browse files
authored
Declare tentative return types for ext/standard (php#7065)
1 parent 0b01d58 commit 48981f4

29 files changed

+81
-72
lines changed

Zend/tests/bug21478.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bug #21478 (Zend/zend_alloc.c :: shutdown_memory_manager produces segfault)
33
--FILE--
44
<?php
55
class debugfilter extends php_user_filter {
6-
function filter($in, $out, &$consumed, $closing) {
6+
function filter($in, $out, &$consumed, $closing): int {
77
while ($bucket = stream_bucket_make_writeable($in)) {
88
$bucket->data = strtoupper($bucket->data);
99
stream_bucket_append($out, $bucket);

Zend/tests/bug78406.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (!class_exists(SampleFilter::class)) {
1010
{
1111
private $data = '';
1212

13-
public function filter($in, $out, &$consumed, $closing)
13+
public function filter($in, $out, &$consumed, $closing): int
1414
{
1515
while ($bucket = stream_bucket_make_writeable($in))
1616
{

ext/opcache/tests/bug64353.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ opcache
99
--FILE--
1010
<?php
1111
class BugLoader extends php_user_filter {
12-
public function filter($in, $out, &$consumed, $closing) {
12+
public function filter($in, $out, &$consumed, $closing): int {
1313
if (!class_exists("Test")) {
1414
eval("class Test extends ArrayObject {}");
1515
}

ext/opcache/tests/bug74596.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ file_put_contents(__DIR__ . "/bug74596_2.php", "ok\n");
3232

3333
class ufilter extends php_user_filter
3434
{
35-
function filter($in, $out, &$consumed, $closing)
35+
function filter($in, $out, &$consumed, $closing): int
3636
{
3737
include_once __DIR__ . "/bug74596_1.php";
3838
while ($bucket = stream_bucket_make_writeable($in)) {

ext/opcache/tests/jit/reg_alloc_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Caster
1616
const EXCLUDE_PRIVATE = 32;
1717
const EXCLUDE_STRICT = 512;
1818

19-
public static function filter(array $a, $filter)
19+
public static function filter(array $a, $filter): int
2020
{
2121
foreach ($a as $k => $v) {
2222
if (!isset($k[1])) {

ext/standard/dir.stub.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
class Directory
66
{
77
/**
8-
* @return void
8+
* @tentative-return-type
99
* @implementation-alias closedir
1010
*/
11-
public function close() {}
11+
public function close(): void {}
1212

1313
/**
14-
* @return void
14+
* @tentative-return-type
1515
* @implementation-alias rewinddir
1616
*/
17-
public function rewind() {}
17+
public function rewind(): void {}
1818

1919
/**
20-
* @return string|false
20+
* @tentative-return-type
2121
* @implementation-alias readdir
2222
*/
23-
public function read() {}
23+
public function read(): string|false {}
2424
}

ext/standard/dir_arginfo.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 1fd5cc5147c7272006e59d63d68c12caec84589f */
2+
* Stub hash: e3d46788bb18dc90a0922e5738442b2932dd53f6 */
33

4-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Directory_close, 0, 0, 0)
4+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Directory_close, 0, 0, IS_VOID, 0)
55
ZEND_END_ARG_INFO()
66

77
#define arginfo_class_Directory_rewind arginfo_class_Directory_close
88

9-
#define arginfo_class_Directory_read arginfo_class_Directory_close
9+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_Directory_read, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
10+
ZEND_END_ARG_INFO()
1011

1112

1213
ZEND_FUNCTION(closedir);

ext/standard/tests/directory/DirectoryClass_basic_001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,21 @@ Class [ <internal%s> class Directory ] {
4343

4444
- Parameters [0] {
4545
}
46+
- Tentative return [ void ]
4647
}
4748

4849
Method [ <internal:standard> public method rewind ] {
4950

5051
- Parameters [0] {
5152
}
53+
- Tentative return [ void ]
5254
}
5355

5456
Method [ <internal:standard> public method read ] {
5557

5658
- Parameters [0] {
5759
}
60+
- Tentative return [ string|false ]
5861
}
5962
}
6063
}

ext/standard/tests/file/bug39551.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Bug #39551 (Segfault with stream_bucket_new in user filter)
66
$bucket = stream_bucket_new(fopen('php://temp', 'w+'), '');
77

88
class bucketFilter {
9-
public function filter($in, $out, &$consumed, $closing ){
9+
public function filter($in, $out, &$consumed, $closing ): int {
1010

1111
$bucket = stream_bucket_new(fopen('php://temp', 'w+'), '');
1212
stream_bucket_append($out, $bucket);

ext/standard/tests/file/userfilters.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ stream userfilter test
44
<?php
55

66
class testfilter extends php_user_filter {
7-
function filter($in, $out, &$consumed, $closing) {
7+
function filter($in, $out, &$consumed, $closing): int {
88
while ($bucket = stream_bucket_make_writeable($in)) {
99
$bucket->data = strtoupper($bucket->data);
1010
$consumed += strlen($bucket->data);
@@ -13,8 +13,9 @@ class testfilter extends php_user_filter {
1313
return PSFS_PASS_ON;
1414
}
1515

16-
function oncreate() {
16+
function oncreate(): bool {
1717
echo "params: {$this->params}\n";
18+
return true;
1819
}
1920
}
2021

0 commit comments

Comments
 (0)