Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #19063
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "J.O. Aho" <user@example.net> |
| Newsgroups | comp.lang.php |
| Subject | Re: phpdoc: function return type |
| Date | Thu, 14 Jul 2022 19:04:29 +0200 |
| Lines | 40 |
| Message-ID | <jjb0ktFepdqU1@mid.individual.net> (permalink) |
| References | <tapfta$1cl9$1@gioia.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net PJX8JufWErGSRahec3IowwT8UJU80Lnr+44Pfjdhz4BcVIvH+4 |
| Cancel-Lock | sha1:kCG0qQs0/kNVtm9nAYwsAxXp6qA= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 |
| Content-Language | en-US-large |
| In-Reply-To | <tapfta$1cl9$1@gioia.aioe.org> |
| Xref | csiph.com comp.lang.php:19063 |
Show key headers only | View raw
On 14/07/2022 18.23, Tommy wrote:
> /**
> * @return int|exit
> */
> function err($message, $exitCode) {
> $int = fwrite(STDERR, $message);
>
> if (null !== $exitCode) {
if(!is_null($exitCode)) {
> exit($exitCode);
> }
>
> return $int;
> }
>
> In your opinion, int|exit is good as a type for @return tag?
No, as exit do not return anything and also it will break the execution
here. you should write it in the description that the function will stop
the execution if the $exitCode ain't null. Maybe you should test that
the exitCode ain't 0, as it's normally an exit code for something that
went well.
> Or it would be better int|null?
No, the function will return int or false
> Or it would be better simply int?
As you are returning the return value from fwrite(), then it's int or
false.
https://www.php.net/manual/en/function.fwrite.php
--
//Aho
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
phpdoc: function return type Tommy <ba@ve.net> - 2022-07-14 18:23 +0200
Re: phpdoc: function return type "J.O. Aho" <user@example.net> - 2022-07-14 19:04 +0200
Re: phpdoc: function return type Tommy <ba@ve.net> - 2022-07-15 15:52 +0200
csiph-web