[PHP-DEV] [RFC] get_debug_type

2020-02-15 Thread Mark Randall
Greetings, I offer a short RFC to add a new function, get_debug_type, which would return the type name of a variable, automatically resolving the class name in the event of it being an object. Unlike gettype, this function will return the true name of scalar types, rather than their aliases, thus

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-15 Thread Nikita Popov
On Sat, Feb 15, 2020 at 3:33 PM Mark Randall wrote: > Greetings, > > I offer a short RFC to add a new function, get_debug_type, which would > return the type name of a variable, automatically resolving the class > name in the event of it being an object. > > Unlike gettype, this function will ret

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-16 Thread Mike Schinkel
> On Feb 15, 2020, at 9:32 AM, Mark Randall wrote: > > Greetings, > > I offer a short RFC to add a new function, get_debug_type, which would > return the type name of a variable, automatically resolving the class > name in the event of it being an object. > > Unlike gettype, this function will

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-16 Thread Mark Randall
On 16/02/2020 10:16, Mike Schinkel wrote: Why "debug" type? I would imagine because it is only really useful in the context of debugging. There is no reason to ever expose such information to userland. The name is up for debate. -- Mark Randall marand...@php.net -- PHP Internals - PHP Runt

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-16 Thread Mike Schinkel
> On Feb 16, 2020, at 8:15 AM, Mark Randall wrote: > > On 16/02/2020 10:16, Mike Schinkel wrote: >> Why "debug" type? > > I would imagine because it is only really useful in the context of debugging. JMTCW but I generally think names should describe what something is, not what it can be used

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-16 Thread G. P. B.
On Mon, 17 Feb 2020 at 00:25, Mike Schinkel wrote: > > On Feb 16, 2020, at 8:15 AM, Mark Randall wrote: > > The name is up for debate. > > Cool. > > Though still not exactly sure where you are headed with it since there are > few detailed and no code examples the first name that comes to mind fo

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-16 Thread Mike Schinkel
> On Feb 16, 2020, at 6:28 PM, G. P. B. wrote: > > Erf pls no, I'd rather have something like `get_canonical_type()` That works fine too. -Mike P.S. But not sure what "Erf" means, though. '-) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-16 Thread tyson andre
I'd definitely agree on returning `int` instead of `integer`. PHP allows both `class integer` and `class resource`, so `int` (plus documenting exact return values for examples, as Nikita mentioned) would be useful to prevent ambiguity. Also, it'd be nice to have `null` return the lowercase stri

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-17 Thread Tom Gerrits
Hi Mark Thanks for this proposal. After the proposal by Nikita to allow ::class on object variables, would it be opportune to add ::type for any variable, with this behavior? It could behave like ::class on objects and return a string indicator of the type for other types, such as scalar on

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-17 Thread Nikita Popov
On Sat, Feb 15, 2020 at 4:07 PM Nikita Popov wrote: > On Sat, Feb 15, 2020 at 3:33 PM Mark Randall wrote: > >> Greetings, >> >> I offer a short RFC to add a new function, get_debug_type, which would >> return the type name of a variable, automatically resolving the class >> name in the event of

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-17 Thread Mark Randall
On 17/02/2020 08:42, Nikita Popov wrote: Can you please add some examples for the behavior? Preferably the precise output for all primitive types, for classes and for anonymous classes. Added to RFC -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.n

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-17 Thread Nikita Popov
On Mon, Feb 17, 2020 at 10:47 AM Mark Randall wrote: > On 17/02/2020 08:42, Nikita Popov wrote: > >> Can you please add some examples for the behavior? Preferably the > precise > >> output for all primitive types, for classes and for anonymous classes. > > Added to RFC > Thanks! I've taken the l

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-17 Thread Kalle Sommer Nielsen
Den man. 17. feb. 2020 kl. 01.25 skrev Mike Schinkel : > Though still not exactly sure where you are headed with it since there are > few detailed and no code examples the first name that comes to mind for me > would be get_real_type(). "real" is a type in PHP (tho we are phasing that out, see i

Re: [PHP-DEV] [RFC] get_debug_type

2020-02-17 Thread Mike Schinkel
> On Feb 17, 2020, at 6:42 AM, Kalle Sommer Nielsen wrote: > > Den man. 17. feb. 2020 kl. 01.25 skrev Mike Schinkel : >> Though still not exactly sure where you are headed with it since there are >> few detailed and no code examples the first name that comes to mind for me >> would be get_real_