Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103897 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38272 invoked from network); 30 Jan 2019 18:58:55 -0000 Received: from unknown (HELO hos109.unaxus.net) (195.191.240.18) by pb1.pair.com with SMTP; 30 Jan 2019 18:58:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=heigl.org; s=default; h=Mime-Version:Content-Type:References:In-Reply-To:Date:To:From: Subject:Message-ID:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OGFdqfDQ9s6QsbNBd9mXTu+TmeGHhpoMCUdQxFXEVyE=; b=Wkv10Ig7I96QIVv7qruIuc5L9g hvmPDg0dezG2zdRXG/cHGKZJSDby0UiHvJ/4U3+uYtjQ1jmBmBHG0qv4HZgFU6ZxgD8EdGbnRvXQz wufGssPBqHW0xOyqjKnimJ0MqO+pBIrUzn0q95qKEVYMMyU0llYjLdtlBbayrupwHJDbp5YOzTthC QQakXJ2JV/wFFhGYLzdvuh3y70dbuyeT5EOgoYSN+sjG1BrWHfSpacpJ9nKdzf129AgDMQuLNXe7K Aw0bPVJjM7mY5/TI0tWScBXqObzXgG8FqxdshqxEcN/JAfY4gycF2k0lYQmj0vFiAVLRVNI0nafkd C4ACn7TA==; Received: from heigl.gw.tgnet.de ([80.72.250.242]:46616 helo=[172.16.1.152]) by hos109.unaxus.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gorwg-00FQK1-2e; Wed, 30 Jan 2019 16:38:34 +0100 Message-ID: To: Larry Garfield , internals@lists.php.net Date: Wed, 30 Jan 2019 16:38:33 +0100 In-Reply-To: <3837033.kzX6na9RhK@vulcan> References: <3837033.kzX6na9RhK@vulcan> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-sczzobXTZPehVgReZLPi" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hos109.unaxus.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - heigl.org X-Get-Message-Sender-Via: hos109.unaxus.net: authenticated_id: a.heigl@heigl.org X-Authenticated-Sender: hos109.unaxus.net: a.heigl@heigl.org Subject: Re: [PHP-DEV] Old style constructors in PHP-8 From: andreas@heigl.org (Andreas Heigl) --=-sczzobXTZPehVgReZLPi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Am Mittwoch, den 30.01.2019, 09:30 -0600 schrieb Larry Garfield: > On Wednesday, January 30, 2019 5:41:45 AM CST Nikita Popov wrote: > > On Wed, Jan 30, 2019 at 12:11 PM Dmitry Stogov > > wrote: > > > Hi, > > >=20 > > >=20 > > > I've just noticed that Wordpress-4.1 on PHP master started > > > silently > > > produce different output. > > >=20 > > > The problem that PHP master started to ignore old-style > > > constructors. > > >=20 > > > They were deprecated in PHP-7 and PHP produced the following > > > warning > > >=20 > > >=20 > > > Deprecated: Methods with the same name as their class will not be > > > constructors in a future version of PHP; ... has a deprecated > > > constructor > > >=20 > > >=20 > > > PHP master doesn't produce any warnings and just constructs a > > > class > > > without constructor. > > >=20 > > > This silent behavior change may become a problem for porting > > > legacy code > > > to PHP-8, > > >=20 > > > May be, it makes sense to emit fatal error in case of old-style > > > constructor. > > >=20 > > >=20 > > > Thanks. Dmitry. > >=20 > > First of all, it is probably important to note that the RFC for > > this ( > > https://wiki.php.net/rfc/remove_php4_constructors) explicitly > > specifies > > that in PHP 8 methods with the same name as the class are > > interpreted as > > ordinary methods and no warning or error is thrown. I've CC'd Levi > > and > > Andrea, who authored this RFC. > >=20 > > I think as an end goal, what the RFC specifies is preferable for a > > number > > of reasons: > >=20 > > * You should be able to call your methods whatever you like. PHP > > only > > reserves the __ prefix for itself. > > * The behavior is consistent with classes inside namespaces, where > > methods > > with the same name as the class are treated as normal methods for a > > long > > time already. > > * The fact that a method has the same name as the class may be > > completely > > incidental if it comes from a trait (see > > https://bugs.php.net/bug.php?id=3D77470). The trait does not control > > in which > > classes it may be used and which names those classes may have. >=20 > Every Drupal 7 or 8 site includes classes that have a method name the > same as=20 > the class name, on the assumption that it's safe to do for a normal > method in=20 > current PHP versions. Making that suddenly a Fatal would be, er, > bad. :-) >=20 > As others have noted, this is easily solved with static analysis > tools. =20 > There's been discussion of WP moving to a PHP 7-based version of PHP > sometime=20 > this year (no promises, but that's the scuttlebutt), which would let > them=20 > convert to __construct() universally and safely well before PHP 8 > becomes an=20 > issue. AFAIK WP requires PHP5 already as the minimum PHP-Version. And AFAIK __construct worked with that as well. So there should be no need to wait for PHP7 readiness in WordPress to tackle this issue.=20 Replacing the function-name-as-class-name constructors with __construct should be possible without a BC-break already. Even with PHP 5.0 as a min-requirement. Or am I missing something? Cheers Andreas ,,, =20 (o o) +-------- -------------------------------------------------ooO-(_)-Ooo-+ | Andreas Heigl | | mailto: andreas@heigl.org N 50=C2=B022'59.5" E 08=C2=B023'58" | |=20 http://andreas.heigl.org http://hei.gl/wiFKy7 | +- --------------------------------------------------------------------+ |=20 http://hei.gl/root-ca | +- --------------------------------------------------------------------+ --=-sczzobXTZPehVgReZLPi Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQJGBAABCgAwFiEENHMr85T+FLwCJRBgjNqPc6i4Q/AFAlxRxPkSHGFuZHJlYXNA aGVpZ2wub3JnAAoJEIzaj3OouEPwOwsP/iRhUEN+xDKRyMs29H1yjwwZU17UxWPZ TMPg9fBKDkoIMlmaI+P6HVwiyy0/B1an1MTFwZvP3AkOLR5urWMIE0HqbryNSEDu vSYTbwby3yRyYY+7u3+qHyVTPH+ny4Q2RHvBeDF+tCyW/QdzKjHrMe6ChHIUb3iI WbQKcsIQgbMkrCVW1J+0OzDS+s2pe4NbjU3tnRssnZaKlsBwWyzq4IoNCKg9eDtw kyED9oFa4oXPz9DGtLQs1jqqsqdTO/cq+GYjNXvUZyBGOug7X4bhaqbKXyymwdz8 Ss7PEQbbNQchSILrHKOlFQVt1CgXqATjkn0ckeNzsL+mMPFgPsVmNBP0BvLpFH5K AjMUYxKijyQTX26eW4on3D19if6rao3g4zzjqJgEUQMrXUkoKN3DcgFfubGyAiZE 4FL7Cco7q7kZe2L2gqZ/n+dkadxm5AtiTt+v2OvIvSTMyMvXm/Kw89exgDwh0haA zvZftpnfU/EsHosqhUXoGggI6wteuwaWIDRCiV5kyrQCSue3d6FJ2ncSsztktIZ2 tV1BBlCi1rTlE+F07yseFovNdlFfANtH8+Ovy9YoAT0d8nhVX99DftrWr7qm3LUj BXesc/ikrr6zbTZJKJ0+wgxdmAC52rpEkAWfOVR5y1L+dMmDYQkl/2tzjkvyLkrC FObKi2FRcGHC =DqHz -----END PGP SIGNATURE----- --=-sczzobXTZPehVgReZLPi--