Re: How to get the 'return type' of a function?
| From: | Bruno Fajardo | Date: | Tue, 23 Feb 2010 14:22:46 +0000 |
| Subject: | Re: How to get the 'return type' of a function? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302310@lists.php.net to get a copy of this message | ||
2010/2/23 Daniel Egeberg <degeberg@php.net>
>
> 2010/2/23 Dasn <dasn@lavabit.com>:
> > Hello guys, I try to use 'ReflectionFunction' to retrieve the info of a
> > function.
> > For example:
> > <?php
> >
> > $rf = new ReflectionFunction('strstr');
> > echo $rf;
> > ?>
> > =============== output ==================
> >
> > Function [ <internal:standard> function strstr ] {
> >
> > - Parameters [3] {
> > Parameter #0 [ <required> $haystack ]
> > Parameter #1 [ <required> $needle ]
> > Parameter #2 [ <optional> $part ]
> > }
> > }
> >
> > The problem is there's no 'return type' (i.e. 'string' in this
> > example)
> > info about the function.
> >
> > Could you tell me how to retrieve the 'return type'?
> > Thanks.
> >
> >
> > --
> > Dasn
>
> That's not possible. Consider this function:
>
> function foo()
> {
> switch (rand(0, 1)) {
> case 0: return 42;
> case 1: return 'bar';
> }
> }
>
> What should the return type be?
Mixed? http://www.php.net/manual/en/language.pseudo-types.php#language.types.mixed
>
> --
> Daniel Egeberg
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php