Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95659 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96893 invoked from network); 5 Sep 2016 16:46:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Sep 2016 16:46:53 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.84 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.84 mx103.easyname.com Received: from [77.244.243.84] ([77.244.243.84:38048] helo=mx202.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 96/64-45301-B71ADC75 for ; Mon, 05 Sep 2016 12:46:52 -0400 Received: from cable-81-173-132-21.netcologne.de ([81.173.132.21] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bgx2m-00011w-Fo for internals@lists.php.net; Mon, 05 Sep 2016 16:46:48 +0000 Reply-To: internals@lists.php.net References: To: internals@lists.php.net Message-ID: <7073471f-b97a-4829-7a37-cee395ffda6e@fleshgrinder.com> Date: Mon, 5 Sep 2016 18:46:40 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="iIsThbjPslvn8Pdhw4d5eXwNkk6EVAAS7" Subject: Re: [PHP-DEV] optionally return class name from gettype From: php@fleshgrinder.com (Fleshgrinder) --iIsThbjPslvn8Pdhw4d5eXwNkk6EVAAS7 Content-Type: multipart/mixed; boundary="QwAxKA9mmalpoOQXHe2uoGWDkUMvl9hAB"; protected-headers="v1" From: Fleshgrinder Reply-To: internals@lists.php.net To: internals@lists.php.net Message-ID: <7073471f-b97a-4829-7a37-cee395ffda6e@fleshgrinder.com> Subject: Re: [PHP-DEV] optionally return class name from gettype References: In-Reply-To: --QwAxKA9mmalpoOQXHe2uoGWDkUMvl9hAB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > commit: > https://github.com/abacaphiliac/php-src/commit/eca6f77bf2744c79671d1dfb= b641b753503d4a1a >=20 > build: > https://travis-ci.org/abacaphiliac/php-src/builds/157555638 >=20 > it mirrors gettype except that it returns a classname instead of the st= ring > "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 decou= pled > code better than code duplication in this scenario? >=20 > 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? >=20 > 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 classnam= e as > a part of the "object" string, e.g. "object (point)", "object (stdClass= )", > "object (Exception)", etc. >=20 > this would be similar to gettype's return on a closed resource: "resour= ce > (closed)": > https://github.com/php/php-src/blob/master/ext/standard/type.c#L71 >=20 > although, this could break consumer code. e.g. gettype($obj) =3D=3D=3D = "object". > maybe this option is not so good. >=20 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 --=20 Richard "Fleshgrinder" Fussenegger --QwAxKA9mmalpoOQXHe2uoGWDkUMvl9hAB-- --iIsThbjPslvn8Pdhw4d5eXwNkk6EVAAS7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXzaF0AAoJEOKkKcqFPVVr6I0P/jWUFu6z2UDxUEKaNyJa3PSY ooZhzVephF+ksaqLkDRBWFwTshoBN2YIeHMeEs5ePoFPbKXoLgfyKxPQuuTpkR8M imLm1b/5iPzWGwDlqQYpgFL39LUWHlYBvJjl19EdvffN/lZw8++L2DstgF3htXH3 K/pOm9pR1Xek4ck2REM1ThJF6c/KwhRGzVdSwHfg4c+Dj3PwDiw9y+KnCAqIhrZT EfdRrPXU6n3OwC+4DUF72dwU4fTlfg6JcuXL+SaoZNhDvueaQqv3/N005/0NOboL 8jOwSwXPEBYPMs9zd162dlhJBArhfoRBIjV8d1mJkRgY8yU0phnc5qK0js9sZ1Wl vt0cY5h0XpSPACQwgBxFLRgT3UrMFuKIh3t5SHEtGjor6MjXK9SNZYVyVCIHkzDZ /NEP3Q2XRAy/oTJwlOsOh27m1FeKhf13UioJc74Enk0p609VASg4HMfBjPoK1Dxo x2Aiir2j7LG0yg3a2sIg38yXYyp3rT2OJewUKLfs9C3c9F8QsIrGAG2Jg63toFHa 6Qf+LmFdZ+WAaFYFXvmGi8hdsmfiZFWRcu2FoLzn07ofMH83mQJqoNJRxoTrjC6W /O8H66uCgLkaITGYYaOxRBOZIrHrwPJ+5jTLrMVBRfn7cRWzAxVtC54j+7JOWAzV 0ahv8PXIy2uU35/VARHm =2dEM -----END PGP SIGNATURE----- --iIsThbjPslvn8Pdhw4d5eXwNkk6EVAAS7--