On 9/5/2016 9:02 AM, Timothy Younger wrote:
> thank you all for your feedback. it seems this thread is split between an
> optional param and a new function, so i created a new function called
> var_type for comparison.
> 
> commit:
> https://github.com/abacaphiliac/php-src/commit/eca6f77bf2744c79671d1dfbb641b753503d4a1a
> 
> build:
> https://travis-ci.org/abacaphiliac/php-src/builds/157555638
> 
> it mirrors gettype except that it returns a classname instead of the string
> "object". i'm not a fan of the code duplication, so i'm looking into a
> couple of ways to address that. the result will likely couple var_type to
> gettype, but that is no worse than my optional param solution. is decoupled
> code better than code duplication in this scenario?
> 
> does comparing my commits help? how can i proceed? should i open merge
> requests that reference each other to see if either one is acceptable, or
> if they need work? should i submit an RFC that includes both commits so
> that there can be a vote?
> 
> thanks for your time and honest feedback.

You need to create a PR and an RFC. I include some links for you from my
original attempt to create such functionality:

- https://github.com/php/php-src/pull/1932
- https://github.com/php/php-src/pull/1935
- https://github.com/php/php-src/pull/1957

You see that I always create tasks for myself in the PR messages of what
needs to be done. You will also see that the RFCs were all negative,
however, you can count on my support for a second attempt of creating
var_type if you really want to go forward with this.

My personal opinion is of course to fix the issues that gettype
currently has altogether with the new var_type function, as explained in
detail in my original RFC.

Have a look at my implementation of var_type which has smaller tests
that are more useful and how it uses interned strings for better
performance. (The class name functionality is found in the var_info PR.)

On 9/5/2016 9:35 AM, Timothy Younger wrote:
> i just thought of another option. what if gettype returned the classname as
> a part of the "object" string, e.g. "object (point)", "object (stdClass)",
> "object (Exception)", etc.
> 
> this would be similar to gettype's return on a closed resource: "resource
> (closed)":
> https://github.com/php/php-src/blob/master/ext/standard/type.c#L71
> 
> although, this could break consumer code. e.g. gettype($obj) === "object".
> maybe this option is not so good.
> 

Touching the output of gettype() is a bad idea. Although it will
actually be broken in 7.2 the decision to do so was not voted on, it was
simply done. :(

https://github.com/php/php-src/pull/2022

-- 
Richard "Fleshgrinder" Fussenegger

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to