Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Linux is addictive, I'm hooked! -- MaDsen Wikholm's .sig


devel / comp.lang.php / phpdoc: function return type

SubjectAuthor
* phpdoc: function return typeTommy
`* Re: phpdoc: function return typeJ.O. Aho
 `- Re: phpdoc: function return typeTommy

1
phpdoc: function return type

<tapfta$1cl9$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=632&group=comp.lang.php#632

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!y/zf3gUsVB1ibu6gO1+poA.user.46.165.242.91.POSTED!not-for-mail
From: ba@ve.net (Tommy)
Newsgroups: comp.lang.php
Subject: phpdoc: function return type
Date: Thu, 14 Jul 2022 18:23:06 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tapfta$1cl9$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="45737"; posting-host="y/zf3gUsVB1ibu6gO1+poA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: Tommy - Thu, 14 Jul 2022 16:23 UTC

/**
* @return int|exit
*/
function err($message, $exitCode) {
$int = fwrite(STDERR, $message);

if (null !== $exitCode) {
exit($exitCode);
}

return $int;
}

In your opinion, int|exit is good as a type for @return tag?
Or it would be better int|null?
Or it would be better simply int?

Re: phpdoc: function return type

<jjb0ktFepdqU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=633&group=comp.lang.php#633

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: user@example.net (J.O. Aho)
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>
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>
 by: J.O. Aho - Thu, 14 Jul 2022 17:04 UTC

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

Re: phpdoc: function return type

<tarrfo$1nr6$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=634&group=comp.lang.php#634

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!y/zf3gUsVB1ibu6gO1+poA.user.46.165.242.91.POSTED!not-for-mail
From: ba@ve.net (Tommy)
Newsgroups: comp.lang.php
Subject: Re: phpdoc: function return type
Date: Fri, 15 Jul 2022 15:52:56 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tarrfo$1nr6$1@gioia.aioe.org>
References: <tapfta$1cl9$1@gioia.aioe.org> <jjb0ktFepdqU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="57190"; posting-host="y/zf3gUsVB1ibu6gO1+poA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: Tommy - Fri, 15 Jul 2022 13:52 UTC

Il 14/07/22 19:04, J.O. Aho ha scritto:
>...

thanks

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor