Skip to content

Commit 15be98c

Browse files
committed
Declare true return types
1 parent 0ae6a67 commit 15be98c

File tree

6 files changed

+42
-70
lines changed

6 files changed

+42
-70
lines changed

Zend/Optimizer/zend_func_infos.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ static const func_info_t func_infos[] = {
77
F1("get_class_methods", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
88
F1("get_included_files", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
99
FN("set_error_handler", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_OBJECT|MAY_BE_NULL),
10-
F0("restore_error_handler", MAY_BE_TRUE),
1110
FN("set_exception_handler", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_OBJECT|MAY_BE_NULL),
12-
F0("restore_exception_handler", MAY_BE_TRUE),
1311
F1("get_declared_classes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
1412
F1("get_declared_traits", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
1513
F1("get_declared_interfaces", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
@@ -455,20 +453,9 @@ static const func_info_t func_infos[] = {
455453
F1("ob_get_clean", MAY_BE_STRING|MAY_BE_FALSE),
456454
F1("ob_list_handlers", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
457455
F1("ob_get_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY),
458-
F0("krsort", MAY_BE_TRUE),
459-
F0("ksort", MAY_BE_TRUE),
460-
F0("asort", MAY_BE_TRUE),
461-
F0("arsort", MAY_BE_TRUE),
462-
F0("sort", MAY_BE_TRUE),
463-
F0("usort", MAY_BE_TRUE),
464-
F0("uasort", MAY_BE_TRUE),
465-
F0("uksort", MAY_BE_TRUE),
466-
F0("array_walk", MAY_BE_TRUE),
467-
F0("array_walk_recursive", MAY_BE_TRUE),
468456
F1("compact", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
469457
FN("array_fill", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ANY),
470458
F1("array_fill_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
471-
F0("shuffle", MAY_BE_TRUE),
472459
F1("array_replace", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
473460
F1("array_replace_recursive", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
474461
FN("array_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
@@ -544,12 +531,6 @@ static const func_info_t func_infos[] = {
544531
F1("md5_file", MAY_BE_STRING|MAY_BE_FALSE),
545532
F1("sha1", MAY_BE_STRING),
546533
F1("sha1_file", MAY_BE_STRING|MAY_BE_FALSE),
547-
#if defined(HAVE_SYSLOG_H)
548-
F0("closelog", MAY_BE_TRUE),
549-
#endif
550-
#if defined(HAVE_SYSLOG_H)
551-
F0("syslog", MAY_BE_TRUE),
552-
#endif
553534
#if defined(HAVE_INET_NTOP)
554535
F1("inet_ntop", MAY_BE_STRING|MAY_BE_FALSE),
555536
#endif
@@ -639,9 +620,7 @@ static const func_info_t func_infos[] = {
639620
F1("image_type_to_extension", MAY_BE_STRING|MAY_BE_FALSE),
640621
F1("getimagesize", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
641622
F1("getimagesizefromstring", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
642-
F0("phpinfo", MAY_BE_TRUE),
643623
F1("phpversion", MAY_BE_STRING|MAY_BE_FALSE),
644-
F0("phpcredits", MAY_BE_TRUE),
645624
F1("php_sapi_name", MAY_BE_STRING|MAY_BE_FALSE),
646625
F1("php_uname", MAY_BE_STRING),
647626
F1("php_ini_scanned_files", MAY_BE_STRING|MAY_BE_FALSE),

Zend/zend_builtin_functions.stub.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,12 @@ function user_error(string $message, int $error_level = E_USER_NOTICE): bool {}
102102
/** @return callable|null */
103103
function set_error_handler(?callable $callback, int $error_levels = E_ALL) {}
104104

105-
/** @return true */
106-
function restore_error_handler(): bool {}
105+
function restore_error_handler(): true {}
107106

108107
/** @return callable|null */
109108
function set_exception_handler(?callable $callback) {}
110109

111-
/** @return true */
112-
function restore_exception_handler(): bool {}
110+
function restore_exception_handler(): true {}
113111

114112
/**
115113
* @return array<int, string>

Zend/zend_builtin_functions_arginfo.h

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/gen_stub.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ public function toTypeCode(): string {
380380
return "IS_NULL";
381381
case "false":
382382
return "IS_FALSE";
383+
case "true":
384+
return "IS_TRUE";
383385
default:
384386
throw new Exception("Not implemented: $this->name");
385387
}
@@ -393,6 +395,8 @@ public function toTypeMask(): string {
393395
return "MAY_BE_NULL";
394396
case "false":
395397
return "MAY_BE_FALSE";
398+
case "true":
399+
return "MAY_BE_TRUE";
396400
case "bool":
397401
return "MAY_BE_BOOL";
398402
case "int":
@@ -443,6 +447,8 @@ public function toOptimizerTypeMaskForArrayValue(): string {
443447
return "MAY_BE_ARRAY_OF_NULL";
444448
case "false":
445449
return "MAY_BE_ARRAY_OF_FALSE";
450+
case "true":
451+
return "MAY_BE_ARRAY_OF_TRUE";
446452
case "bool":
447453
return "MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE";
448454
case "int":
@@ -472,8 +478,6 @@ public function toOptimizerTypeMask(): string {
472478
}
473479

474480
switch ($this->name) {
475-
case "true":
476-
return "MAY_BE_TRUE";
477481
case "resource":
478482
return "MAY_BE_RESOURCE";
479483
case "callable":

ext/standard/basic_functions.stub.php

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ function stream_wrapper_restore(string $protocol): bool {}
8282

8383
function array_push(array &$array, mixed ...$values): int {}
8484

85-
/** @return true */
86-
function krsort(array &$array, int $flags = SORT_REGULAR): bool {}
85+
function krsort(array &$array, int $flags = SORT_REGULAR): true {}
8786

88-
/** @return true */
89-
function ksort(array &$array, int $flags = SORT_REGULAR): bool {}
87+
function ksort(array &$array, int $flags = SORT_REGULAR): true {}
9088

9189
/** @compile-time-eval */
9290
function count(Countable|array $value, int $mode = COUNT_NORMAL): int {}
@@ -98,25 +96,19 @@ function natsort(array &$array): bool {}
9896

9997
function natcasesort(array &$array): bool {}
10098

101-
/** @return true */
102-
function asort(array &$array, int $flags = SORT_REGULAR): bool {}
99+
function asort(array &$array, int $flags = SORT_REGULAR): true {}
103100

104-
/** @return true */
105-
function arsort(array &$array, int $flags = SORT_REGULAR): bool {}
101+
function arsort(array &$array, int $flags = SORT_REGULAR): true {}
106102

107-
/** @return true */
108-
function sort(array &$array, int $flags = SORT_REGULAR): bool {}
103+
function sort(array &$array, int $flags = SORT_REGULAR): true {}
109104

110105
function rsort(array &$array, int $flags = SORT_REGULAR): bool {}
111106

112-
/** @return true */
113-
function usort(array &$array, callable $callback): bool {}
107+
function usort(array &$array, callable $callback): true {}
114108

115-
/** @return true */
116-
function uasort(array &$array, callable $callback): bool {}
109+
function uasort(array &$array, callable $callback): true {}
117110

118-
/** @return true */
119-
function uksort(array &$array, callable $callback): bool {}
111+
function uksort(array &$array, callable $callback): true {}
120112

121113
function end(array|object &$array): mixed {}
122114

@@ -139,11 +131,9 @@ function min(mixed $value, mixed ...$values): mixed {}
139131
/** @compile-time-eval */
140132
function max(mixed $value, mixed ...$values): mixed {}
141133

142-
/** @return true */
143-
function array_walk(array|object &$array, callable $callback, mixed $arg = UNKNOWN): bool {}
134+
function array_walk(array|object &$array, callable $callback, mixed $arg = UNKNOWN): true {}
144135

145-
/** @return true */
146-
function array_walk_recursive(array|object &$array, callable $callback, mixed $arg = UNKNOWN): bool {}
136+
function array_walk_recursive(array|object &$array, callable $callback, mixed $arg = UNKNOWN): true {}
147137

148138
/**
149139
* @compile-time-eval
@@ -178,8 +168,7 @@ function array_fill_keys(array $keys, mixed $value): array {}
178168
*/
179169
function range($start, $end, int|float $step = 1): array {}
180170

181-
/** @return true */
182-
function shuffle(array &$array): bool {}
171+
function shuffle(array &$array): true {}
183172

184173
function array_pop(array &$array): mixed {}
185174

@@ -697,11 +686,9 @@ function sha1_file(string $filename, bool $binary = false): string|false {}
697686
#ifdef HAVE_SYSLOG_H
698687
function openlog(string $prefix, int $flags, int $facility): bool {}
699688

700-
/** @return true */
701-
function closelog(): bool {}
689+
function closelog(): true {}
702690

703-
/** @return true */
704-
function syslog(int $priority, string $message): bool {} // TODO make return type void
691+
function syslog(int $priority, string $message): true {} // TODO make return type void
705692
#endif
706693

707694
#ifdef HAVE_INET_NTOP
@@ -1424,17 +1411,15 @@ function getimagesizefromstring(string $string, &$image_info = null): array|fals
14241411

14251412
/* info.c */
14261413

1427-
/** @return true */
1428-
function phpinfo(int $flags = INFO_ALL): bool {} // make return type void
1414+
function phpinfo(int $flags = INFO_ALL): true {} // make return type void
14291415

14301416
/**
14311417
* @compile-time-eval
14321418
* @refcount 1
14331419
*/
14341420
function phpversion(?string $extension = null): string|false {}
14351421

1436-
/** @return true */
1437-
function phpcredits(int $flags = CREDITS_ALL): bool {}
1422+
function phpcredits(int $flags = CREDITS_ALL): true {}
14381423

14391424
/**
14401425
* @compile-time-eval

ext/standard/basic_functions_arginfo.h

Lines changed: 15 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)