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
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)