Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95632 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63916 invoked from network); 5 Sep 2016 07:35:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Sep 2016 07:35:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=abacaphiliac@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=abacaphiliac@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.52 as permitted sender) X-PHP-List-Original-Sender: abacaphiliac@gmail.com X-Host-Fingerprint: 209.85.214.52 mail-it0-f52.google.com Received: from [209.85.214.52] ([209.85.214.52:36357] helo=mail-it0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/B8-45301-3502DC75 for ; Mon, 05 Sep 2016 03:35:48 -0400 Received: by mail-it0-f52.google.com with SMTP id i184so134381696itf.1 for ; Mon, 05 Sep 2016 00:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cnqbV2WJSiOKsnibLl+h9rozeL/P9BiWXfFLsQfb36s=; b=obJe6WXWl5h2cD3bEB3put+cNt05uTXnVrafjExrWc2+hhxK96+8mpZz2OgHM4NdZG w7vyPEm/n/RlJIPQnzM2HdoVMlM602WYhE6zREsrSHsKUlc/2Y4mykfnCH02i4HWN9VY hK41XYtOemfDCHtnJ9j2o70gWWow1+BscrowgZdYoh4nLPb73yCo9dffb6V018i7Xghg 3SVAy60334PJxeKqxH9DvjqrzVsTaGlbK3wnactRbl1c6qEI1j7EDgYozAPtUJGLDYjX QM0KDvE2YPbtEjxOs3d9XqmKcsTnB/Ot5xqosFmTkefnky4ZhscJgTBcpWjrUfaIOfRm mjPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cnqbV2WJSiOKsnibLl+h9rozeL/P9BiWXfFLsQfb36s=; b=X+5zf29RcmuzSNZoeBTC0m6SqF0C398MFFahyFQ3GlCTCM5G+gRQ9+Ck8G6D9gRd0i HzMuKJ3V+T1DitI63gSBnFeNvVAcw91/4GgmDIAgt5US6ej+Jj/corbALKygKd53GdVk UwuqYJ7PCcTOg3Zsir2oanvv84Xy+aVWPK6ohwqDcxNRsq+a417XB3QC9Lf/hndLtjp0 FaCwc4GFPeYRYNajTlzme5sxmwWXv//qbFCEpBUxPhQ70W3UiMkHDnlOPWnn/ylM4eoY TKX9+J8ogyVS7eIERDh0ZiphV3MF6DI57saFTSdVpiynEuIRlk9SChctHZFLphfxmkem qixQ== X-Gm-Message-State: AE9vXwPY6IRiInLvKeaMGtJD0g8/vW2R278iiyAnnX5KaOGSLi0yoMtUV5w0by9ZgaLCmdDtGIX7EkX9CATpKQ== X-Received: by 10.36.87.212 with SMTP id u203mr21554803ita.7.1473060945028; Mon, 05 Sep 2016 00:35:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.137.130 with HTTP; Mon, 5 Sep 2016 00:35:39 -0700 (PDT) In-Reply-To: References: Date: Mon, 5 Sep 2016 00:35:39 -0700 Message-ID: To: Rasmus Schultz Cc: Niklas Keller , David Rodrigues , Ryan Pallas , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1143ad4e5c783d053bbdbac3 Subject: Re: [PHP-DEV] optionally return class name from gettype From: abacaphiliac@gmail.com (Timothy Younger) --001a1143ad4e5c783d053bbdbac3 Content-Type: text/plain; charset=UTF-8 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. On Mon, Sep 5, 2016 at 12: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. > > On Sat, Jul 30, 2016 at 5:46 AM, Rasmus Schultz > wrote: > >> I agree, an argument that essentially turns it into a different function >> is not a good practice. >> >> Suggestions for a function-name? >> >> typeof() or vartype() maybe? >> >> >> On Fri, Jul 29, 2016 at 8:17 PM, Niklas Keller wrote: >> >>> > >>> > Niklas Keller wrote: >>> > > I'm not sure on the boolean through, I think a new function might be >>> > better. >>> > >>> > In this point I desagree. >>> > I think that boolean is the best way, mainly to avoid a new function >>> > on userland. >>> > It's like an "extension" for gettype(), and make senses just extend it. >>> >>> >>> The issue is that it's not clear what this boolean means just from >>> reading >>> the code. >>> If you follow Clean Code, you shouldn't have something like that, only in >>> very, very rare cases. >>> >> >> > --001a1143ad4e5c783d053bbdbac3--