Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107902 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74602 invoked from network); 8 Dec 2019 02:31:11 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 8 Dec 2019 02:31:11 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 008542CA62A for ; Sat, 7 Dec 2019 16:28:42 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 64.147.123.0/24 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Sat, 7 Dec 2019 16:28:41 -0800 (PST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 0E43C5CE for ; Sat, 7 Dec 2019 19:28:39 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Sat, 07 Dec 2019 19:28:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=OgFd0wA+iiEl0d31tJYrxXTHzQ5/k ezjxX4jfgw8udI=; b=EYzsnMxCZ0GGPiI/DoMNZ0DJrik0o+eZwZ13EJ7+3Aon2 oogoNn5IoIMSPLFzh/mb02xLHBoT370coZvqvHY6IERQR2NUlr6N5A+kgd7lSaS2 kFEua531JMbKM6+Q44mdlqQANz+xsb3piTZK7u2v/ptYl0Q9mi06PWS4DsBmfwaj yBrk6sFpvOrk56qIFSan0VOWjJQbVs/61cPx4AaJhaCGoOns7cR8Hr3/ksVXAB+J K3WSIye6qJ1sMGwLqQnU+wwbciT6kzAUh9Enc4ylADPAS5uU3dHXnS/d6+fxrkUG 2xLUpQOqovrxafkZmiprQQeXEfDQkRxK0HhTplTkg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudekiedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkfffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucffohhmrghinhepfehvgehlrdhorhhgpdhphhhprdhnvghtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhenucevlhhush htvghrufhiiigvpedt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6665F14200A1; Sat, 7 Dec 2019 19:28:39 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-612-g13027cc-fmstable-20191203v1 Mime-Version: 1.0 Message-ID: Date: Sat, 07 Dec 2019 18:27:06 -0600 To: "php internals" Content-Type: text/plain X-Envelope-From: Subject: Inconsistent class behavior and undocumented(?) BC change From: larry@garfieldtech.com ("Larry Garfield") I am not sure if this is a bug, a feature behaving in a desired but confusing way, or a feature behaving in a confusing and thus undesireable way. I am therefore reporting it here in order to defer to those who know the answer to such questions better. Consider the following: class Ancestor { public function __construct(int $a, string $b) { } } class Child extends Ancestor { public function __construct(...$args) { parent::__construct(...$args); } } This works with no compile errors. For any other method however: class Ancestor { public function doStuff(int $a, string $b) { } } class Child extends Ancestor { public function doStuff(...$args) { parent::doStuff(...$args); } } I get: Warning: Declaration of Child::doStuff(...$args) should be compatible with Ancestor::doStuff(int $a, string $b) I am not clear on why __construct() is special in this case; I know __construct() is special where interfaces are concerned, but I didn't realize it was special with regards to basic inheritance. It seems to happen regardless of the type information presented (or not). Is this intentional? Is there a logical way it could be made to work? Are constructors actually wrong here? (I hope not, because it's a neat trick.) Additionally, according to 3v4l.org at least, the error message has changed. On 7.1-7.3, the exact error message is: Warning: Declaration of Child::doStuff(int ...$args) should be compatible with Ancestor::doStuff($a, $b) in /in/6NthP on line 15 On 7.4, it reports on a different line: Warning: Declaration of Child::doStuff(int ...$args) should be compatible with Ancestor::doStuff($a, $b) in /in/6NthP on line 11 Specifically, prior to 7.4, it reports on the LAST line of the class (the closing brace). As of 7.4 it reports on the line of the method that is inconsistent. I don't think this is a bad change, per se. It's actually a good change for debugging, IMO. But I don't see it listed in the migration guide. Should it be, in case some failure-mode tests or other automated error systems care? https://www.php.net/manual/en/migration74.incompatible.php -- Larry Garfield larry@garfieldtech.com