Skip to content

Commit 55d168e

Browse files
committed
Align PHPDoc @return annotations with PHP 8.0 and 8.1 behavior, updating descriptions for consistency with official documentation.
1 parent cc16dbb commit 55d168e

11 files changed

Lines changed: 40 additions & 34 deletions

File tree

Core/Core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function str_increment(string $string): string {}
215215
* @removed 8.0
216216
*/
217217
#[Deprecated(reason: "Use a foreach loop instead", since: "7.2")]
218-
function each(&$array): array {}
218+
function each(&$array): array|false {}
219219

220220
/**
221221
* Sets which PHP errors are reported

Phar/Phar.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,6 @@ public function isCRCChecked(): bool {}
22782278
* </p>
22792279
* @return void No value is returned.
22802280
*/
2281-
#[LanguageLevelTypeAware(['8.0' => 'static|null'], default: '')]
22822281
#[TentativeType]
22832282
public function setMetadata(#[LanguageLevelTypeAware(['8.0' => 'mixed'], default: '')] $metadata): void {}
22842283
}

Reflection/ReflectionFunction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ public function invokeArgs(array $args): mixed {}
9999
* Returns a dynamically created closure for the function
100100
*
101101
* @link https://php.net/manual/en/reflectionfunction.getclosure.php
102-
* @return Closure|null Returns {@see Closure} or {@see null} in case of an error.
102+
* @return Closure Returns a {@see Closure}.
103+
* Prior to PHP 8.1, {@see null} was returned in case of an error.
103104
*/
104105
#[Pure]
105106
#[TentativeType]

Reflection/ReflectionParameter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public function isPassedByReference(): bool {}
8181
* Returns whether this parameter can be passed by value
8282
*
8383
* @link https://php.net/manual/en/reflectionparameter.canbepassedbyvalue.php
84-
* @return bool|null {@see true} if the parameter can be passed by value, {@see false} otherwise.
85-
* Returns {@see null} in case of an error.
84+
* @return bool {@see true} if the parameter can be passed by value, {@see false} otherwise.
85+
* Prior to PHP 8.1, {@see null} was returned in case of an error.
8686
* @since 5.4
8787
*/
8888
#[TentativeType]
@@ -168,8 +168,8 @@ public function isArray(): bool {}
168168
* Returns whether parameter MUST be callable
169169
*
170170
* @link https://php.net/manual/en/reflectionparameter.iscallable.php
171-
* @return bool|null Returns {@see true} if the parameter is callable, {@see false}
172-
* if it is not or {@see null} on failure.
171+
* @return bool Returns {@see true} if the parameter is callable, {@see false} if it is not.
172+
* Prior to PHP 8.1, {@see null} was returned on failure.
173173
* @since 5.4
174174
* @see ReflectionParameter::getType()
175175
*/

SPL/SPL_c1.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ public function fscanf(
918918
public function fwrite(
919919
#[LanguageLevelTypeAware(['8.0' => 'string'], default: '')] $data,
920920
#[LanguageLevelTypeAware(['8.0' => 'int', '8.5' => 'int|null'], default: '')] $length = null
921-
): int|false {}
921+
) {}
922922

923923
/**
924924
* Gets information about the file
@@ -1275,7 +1275,7 @@ public function current(): mixed {}
12751275
/**
12761276
* Return current node index
12771277
* @link https://php.net/manual/en/spldoublylinkedlist.key.php
1278-
* @return string|float|int|bool|null The current node index.
1278+
* @return int The current node index.
12791279
*/
12801280
#[TentativeType]
12811281
public function key(): int {}

curl/curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2618,7 +2618,7 @@ function curl_close(#[LanguageLevelTypeAware(['8.0' => 'CurlHandle'], default: '
26182618
* @return resource|CurlMultiHandle a cURL multi handle resource or object depends on the php version
26192619
*/
26202620
#[LanguageLevelTypeAware(['8.0' => 'CurlMultiHandle'], default: 'resource')]
2621-
function curl_multi_init(): CurlMultiHandle {}
2621+
function curl_multi_init() {}
26222622

26232623
/**
26242624
* Add a normal cURL handle to a cURL multi handle

date/date_c.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public function diff(
119119
* Format accepted by {@link https://php.net/manual/en/function.date.php date()}.
120120
* </p>
121121
* @return string
122-
* Returns the formatted date string on success or <b>FALSE</b> on failure.
123-
* Since PHP8, it always returns <b>STRING</b>.
122+
* Returns the formatted date string on success.
123+
* Prior to PHP 8.1, <b>FALSE</b> was returned on failure.
124124
*/
125125
#[Pure(true)]
126126
#[TentativeType]
@@ -131,12 +131,12 @@ public function format(#[LanguageLevelTypeAware(['8.0' => 'string'], default: ''
131131
* Returns the timezone offset
132132
* @link https://php.net/manual/en/datetime.getoffset.php
133133
* @return int|false
134-
* Returns the timezone offset in seconds from UTC on success
135-
* or <b>FALSE</b> on failure. Since PHP8, it always returns <b>INT</b>.
134+
* Returns the timezone offset in seconds from UTC on success.
135+
* Prior to PHP 8.0, <b>FALSE</b> was returned on failure.
136136
*/
137137
#[LanguageLevelTypeAware(["8.0" => "int"], default: "int|false")]
138138
#[TentativeType]
139-
public function getOffset(): int;
139+
public function getOffset();
140140

141141
/**
142142
* (PHP 5 &gt;=5.5.0)<br/>
@@ -448,8 +448,9 @@ public static function __set_state(array $array): static {}
448448
* @param int $year <p>Year of the date.</p>
449449
* @param int $month <p>Month of the date.</p>
450450
* @param int $day <p>Day of the date.</p>
451-
* @return static|false
452-
* Returns the {@link https://php.net/manual/en/class.datetimeimmutable.php DateTimeImmutable} object for method chaining or <b>FALSE</b> on failure.
451+
* @return static
452+
* Returns the {@link https://php.net/manual/en/class.datetimeimmutable.php DateTimeImmutable} object for method chaining.
453+
* Prior to PHP 8.1, <b>FALSE</b> was returned on failure.
453454
*/
454455
#[TentativeType]
455456
#[\NoDiscard(message: "as DateTimeImmutable::setDate() does not modify the object itself")]
@@ -466,8 +467,9 @@ public function setDate(
466467
* @param int $year <p>Year of the date.</p>
467468
* @param int $week <p>Week of the date.</p>
468469
* @param int $dayOfWeek [optional] <p>Offset from the first day of the week.</p>
469-
* @return static|false
470-
* Returns the {@link https://php.net/manual/en/class.datetimeimmutable.php DateTimeImmutable} object for method chaining or <b>FALSE</b> on failure.
470+
* @return static
471+
* Returns the {@link https://php.net/manual/en/class.datetimeimmutable.php DateTimeImmutable} object for method chaining.
472+
* Prior to PHP 8.1, <b>FALSE</b> was returned on failure.
471473
*/
472474
#[TentativeType]
473475
#[\NoDiscard(message: "as DateTimeImmutable::setISODate() does not modify the object itself")]
@@ -485,8 +487,9 @@ public function setISODate(
485487
* @param int $minute <p> Minute of the time. </p>
486488
* @param int $second [optional] <p> Second of the time. </p>
487489
* @param int $microsecond [optional] <p> Microseconds of the time. Added since 7.1</p>
488-
* @return static|false
489-
* Returns the {@link https://php.net/manual/en/class.datetimeimmutable.php DateTimeImmutable} object for method chaining or <b>FALSE</b> on failure.
490+
* @return static
491+
* Returns the {@link https://php.net/manual/en/class.datetimeimmutable.php DateTimeImmutable} object for method chaining.
492+
* Prior to PHP 8.1, <b>FALSE</b> was returned on failure.
490493
*/
491494
#[TentativeType]
492495
#[\NoDiscard(message: "as DateTimeImmutable::setTime() does not modify the object itself")]
@@ -505,7 +508,7 @@ public function setTime(
505508
* @param int $timestamp <p>Unix timestamp representing the date.</p>
506509
* @return static
507510
* Returns the {@link https://php.net/manual/en/class.datetimeimmutable.php DateTimeImmutable} object for method chaining.
508-
* Prior to PHP 8.0, <b>FALSE</b> was returned on failure.
511+
* Prior to PHP 8.1, <b>FALSE</b> was returned on failure.
509512
*/
510513
#[TentativeType]
511514
#[\NoDiscard(message: "as DateTimeImmutable::setTimestamp() does not modify the object itself")]
@@ -521,7 +524,7 @@ public function setTimestamp(#[LanguageLevelTypeAware(['8.0' => 'int'], default:
521524
* </p>
522525
* @return static
523526
* Returns the {@link https://php.net/manual/en/class.datetimeimmutable.php DateTimeImmutable} object for method chaining.
524-
* Prior to PHP 8.0, <b>FALSE</b> was returned on failure.
527+
* Prior to PHP 8.1, <b>FALSE</b> was returned on failure.
525528
*/
526529
#[TentativeType]
527530
#[\NoDiscard(message: "as DateTimeImmutable::setTimezone() does not modify the object itself")]
@@ -567,7 +570,7 @@ public function diff(
567570
* </p>
568571
* @return string
569572
* Returns the formatted date string on success.
570-
* Prior to PHP 8.0, <b>FALSE</b> was returned on failure.
573+
* Prior to PHP 8.1, <b>FALSE</b> was returned on failure.
571574
*/
572575
#[Pure(true)]
573576
#[TentativeType]
@@ -579,7 +582,7 @@ public function format(#[LanguageLevelTypeAware(['8.0' => 'string'], default: ''
579582
* @link https://php.net/manual/en/datetime.getoffset.php
580583
* @return int
581584
* Returns the timezone offset in seconds from UTC on success.
582-
* Prior to PHP 8.0, <b>FALSE</b> was returned on failure.
585+
* Prior to PHP 8.1, <b>FALSE</b> was returned on failure.
583586
*/
584587
#[TentativeType]
585588
public function getOffset(): int {}

dom/dom_c.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,8 @@ public function createElement(
945945
/**
946946
* Create new document fragment
947947
* @link https://php.net/manual/en/domdocument.createdocumentfragment.php
948-
* @return DOMDocumentFragment|false The new DOMDocumentFragment or false if an error occurred.
948+
* @return DOMDocumentFragment The new DOMDocumentFragment.
949+
* Prior to PHP 8.1, false was returned if an error occurred.
949950
*/
950951
#[TentativeType]
951952
public function createDocumentFragment(): DOMDocumentFragment {}
@@ -956,7 +957,8 @@ public function createDocumentFragment(): DOMDocumentFragment {}
956957
* @param string $data <p>
957958
* The content of the text.
958959
* </p>
959-
* @return DOMText|false The new DOMText or false if an error occurred.
960+
* @return DOMText The new DOMText.
961+
* Prior to PHP 8.1, false was returned if an error occurred.
960962
*/
961963
#[TentativeType]
962964
public function createTextNode(#[LanguageLevelTypeAware(['8.0' => 'string'], default: '')] $data): DOMText {}
@@ -967,7 +969,8 @@ public function createTextNode(#[LanguageLevelTypeAware(['8.0' => 'string'], def
967969
* @param string $data <p>
968970
* The content of the comment.
969971
* </p>
970-
* @return DOMComment|false The new DOMComment or false if an error occurred.
972+
* @return DOMComment The new DOMComment.
973+
* Prior to PHP 8.1, false was returned if an error occurred.
971974
*/
972975
#[TentativeType]
973976
public function createComment(#[LanguageLevelTypeAware(['8.0' => 'string'], default: '')] $data): DOMComment {}

gmp/gmp.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function gmp_intval(GMP|string|int $num): int {}
5151
* @throws \ValueError Throws a ValueError if seed is invalid.
5252
*/
5353
#[LanguageLevelTypeAware(['8.0' => 'void'], default: 'void|false')]
54-
function gmp_random_seed(GMP|string|int $seed): void {}
54+
function gmp_random_seed(GMP|string|int $seed) {}
5555
/**
5656
* Convert GMP number to string
5757
* @link https://php.net/manual/en/function.gmp-strval.php
@@ -682,7 +682,7 @@ function gmp_hamdist(GMP|string|int $num1, GMP|string|int $num2): int {}
682682
*/
683683
#[Pure]
684684
#[LanguageLevelTypeAware(['8.0' => 'GMP'], default: 'GMP|false')]
685-
function gmp_import(string $data, int $word_size = 1, int $flags = GMP_MSW_FIRST|GMP_NATIVE_ENDIAN): GMP {}
685+
function gmp_import(string $data, int $word_size = 1, int $flags = GMP_MSW_FIRST|GMP_NATIVE_ENDIAN) {}
686686

687687
/**
688688
* Export to a binary string
@@ -696,7 +696,7 @@ function gmp_import(string $data, int $word_size = 1, int $flags = GMP_MSW_FIRST
696696
*/
697697
#[Pure]
698698
#[LanguageLevelTypeAware(['8.0' => 'string'], default: 'string|false')]
699-
function gmp_export(GMP|string|int $num, int $word_size = 1, int $flags = GMP_MSW_FIRST|GMP_NATIVE_ENDIAN): string {}
699+
function gmp_export(GMP|string|int $num, int $word_size = 1, int $flags = GMP_MSW_FIRST|GMP_NATIVE_ENDIAN) {}
700700

701701
/**
702702
* Takes the nth root of a and returns the integer component of the result.
@@ -750,7 +750,7 @@ function gmp_nextprime(GMP|string|int $num): GMP {}
750750
*/
751751
#[Pure]
752752
#[LanguageLevelTypeAware(['8.0' => 'GMP'], default: 'GMP|false')]
753-
function gmp_binomial(GMP|string|int $n, int $k): GMP {}
753+
function gmp_binomial(GMP|string|int $n, int $k) {}
754754

755755
/**
756756
* Computes the Kronecker symbol

mbstring/mbstring.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ function mb_ereg(string $pattern, string $string, &$matches = null): bool {}
10191019
*/
10201020
#[LanguageLevelTypeAware(["8.0" => "bool"], default: "false|int")]
10211021
#[Deprecated(since: '8.6')]
1022-
function mb_eregi(string $pattern, string $string, &$matches = null): bool {}
1022+
function mb_eregi(string $pattern, string $string, &$matches = null) {}
10231023

10241024
/**
10251025
* Replace regular expression with multibyte support

0 commit comments

Comments
 (0)