Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103780 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40463 invoked from network); 23 Jan 2019 00:10:55 -0000 Received: from unknown (HELO mail1.25mail.st) (206.123.115.54) by pb1.pair.com with SMTP; 23 Jan 2019 00:10:55 -0000 Received: from [10.0.1.70] (unknown [49.48.243.172]) by mail1.25mail.st (Postfix) with ESMTPSA id A71CB6048B; Tue, 22 Jan 2019 20:48:32 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) In-Reply-To: Date: Wed, 23 Jan 2019 03:48:28 +0700 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <0243D3A4-2C15-4B31-81A8-C2E5892913F9@koalephant.com> References: To: Girgias X-Mailer: Apple Mail (2.3445.102.3) Subject: Re: [PHP-DEV] Deprecation ideas for PHP 8 From: php-lists@koalephant.com (Stephen Reay) > On 23 Jan 2019, at 03:34, Girgias wrote: >=20 > Greetings PHP internals, > After skimming through the PHP documentation, I came up with a list of > functions which seem > reasonable to deprecate as of PHP 8 and I would like to gather some > opinions from Internals. > If this seems like it's too early or should be in an RFC draft please = let > me know and in case it > needs an RFC may I have Karma to do so. > Without further ado here is the list I compiled: >=20 > PHP Info/Option functions: >=20 > - php_sapi_name (use PHP_SAPI constant) > - phpversion (use PHP_VERSION constant) > - php_uname (use PHP_OS constant) >=20 > Classes/Objects functions: >=20 > - is_a (use instanceof operator) > - is_subclass_of (not exactly what it's purpose is but the = instanceof > operator SHOULD be a valid equivalence with another condition if the = same > class must not be used) >=20 > Function handling functions: >=20 > - call_user_func (invoke directly) > - call_user_func_array (arguments can be provided with the splat > operator (...) as of PHP 5.6 > - forward_static_call (same reason as call_user_func) > - forward_static_cal_array (same reason as call_user_func_array) > - func_get_arg (seems unnecessary as of PHP 5.6 with variadic = functions > (splat operator)) > - func_get_args (same reason as func_get_arg) > - func_num_args (same reason as func_get_arg) >=20 > Variable handling functions: > Aliases: >=20 > - is_double > - is_integer > - is_long > - is_real (already in the deprecation draft for PHP 7.4) >=20 > Setting var type (can use variable casting nowadays): >=20 > - boolval > - doubleval > - floatval > - intval (for arbitrary base change there exists the math function > base_convert) > - settype > - strval > - gettype (more on this later [1]) >=20 > String functions aliases: >=20 > - chop (alias of rtrim) > - join (alias of implode) > - strchr (alias of strstr) >=20 > Maths functions aliases: >=20 > - getrandmax > - rand (use mt_rand instead) > - srand (alias of mt_srand as of PHP 7.1) >=20 > Filesystem aliases: >=20 > - diskfreespace =E2=80=94 Alias of disk_free_space > - fputs =E2=80=94 Alias of fwrite > - is_writeable =E2=80=94 Alias of is_writable > - set_file_buffer =E2=80=94 Alias of stream_set_write_buffer >=20 > Old signatures: >=20 > - implode (historical signature) >=20 > Controversial idea: >=20 > - deprecate array function creation (array()) >=20 >=20 > [1] About gettype: > The gettype function is really convenient as it can easily provide the = type > of a variable without > needed to use a bunch of conditional checks, it can even as of PHP 7.2 > signal if a resource > has been closed. > However, it still returns "double" for a float due to historical = reasons > and it seems quite > complicated to change how it operates currently. > I have thought of two possible ideas which would allow PHP to return = float > instead of double: >=20 > First, create a new reflection class ReflectionVar: > This feels even to me like a bit of an overkill more so that something > simple (a unique function > call) would require an object instantiation. But it can allow some > extensions such as the > Reflection for Reference RFC proposed by nikic (c.f. > https://wiki.php.net/rfc/reference_reflection) >=20 > Second, create a new function get_var_type($mixed): > This would behave exactly the same as the current implementation with = the > one difference that > it would return 'float' instead of 'double'. This new function name = would > be more consistent with how the other functions are named (namely > get_resource_type). > This implementation has the benefit of keeping it simple but will = probably > duplicate code within the engine. >=20 >=20 > Just to remind these are only ideas and feedback is wholeheartedly > welcomed. I also probably > missed some more functions which could be deprecated as of PHP 8 but I = feel > this covers > already a large portion. >=20 >=20 > Best regards >=20 > George P. Banyard is_subclass_of allows checking string class names, instanceof (AFAIK) = does not.