Re: Should there be a `get_declared_enums()` function ?
| From: | Mike Schinkel | Date: | Mon, 19 Aug 2024 05:22:41 +0000 |
| Subject: | Re: Should there be a `get_declared_enums()` function ? | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-125044@lists.php.net to get a copy of this message | ||
> On Aug 18, 2024, at 4:59 AM, Rowan Tommins [IMSoP] <imsop.php@rwec.co.uk> wrote:
>
> On 18 August 2024 05:46:09 BST, Mike Schinkel <mike@newclarity.net> wrote:
>> I know that those functions can be called as a function and return a value like the
>> following:
>>
>> $return_value = include($path);
>
> You are right that it has a return value, but wrong to put its argument in parentheses. This
> will *not* do what you expect:
>
> $success = include($path) && somethingElse();
>
> Because include is not actually a function, what is evaluated is
$path
> && somethingElse(), then either include true
> or include false (which will of course fail).
>
> You instead need to write this:
>
> $success = (include $path) && somethingElse();
>
> I thought I'd added this example to the manual, but now can't find it.
>
> Consequently, we can't just define optional parameters like we would a normal function. We
> *could* extend the syntax to allow "include $path, $whatever;" but it probably
> wouldn't feel very natural. It would be a syntax error to write "include($path,
> $whatever)" just as "echo $foo, $bar" is valid, but "echo($foo, $bar)" is
> not.
Hi Rowan,
Thank you for confirming the nature of include, et. al.
So, if the functionality to be notified via a callback for all symbols loaded is a desired feature
by other than me and maybe Juliette then the best approach I've come up with is to add an
spl_autoload_callback() function that can both get and set the callback to be called
after include or its 3 other friends are called. Anyone (else?) disagree?
-Mike