Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107903 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16064 invoked from network); 8 Dec 2019 07:05:28 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 8 Dec 2019 07:05:28 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id CD1922CEEF7 for ; Sat, 7 Dec 2019 21:03:02 -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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) (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 21:03:02 -0800 (PST) Received: by mail-yb1-xb2c.google.com with SMTP id i3so4777109ybe.12 for ; Sat, 07 Dec 2019 21:03:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=keUvnikv2fU+HWn6Q+W4eeek0dfJyYNVPtI3OK++XrY=; b=gM81m85mFd9tQzaRk/X6kgs80+kPNhosiPY3NHZDJ5n8xNr4jZ2pWivZXZuYVtMEc/ +M32uo+mNjCAXgnuWoSKo2J5BWRo1ZB1BqB7UIYaY/CNDL88I+i+cwSXyRz3EtuDKnqX fqPCyji96/UD6Z+WEO2caSPqtOucCKfhS4uTYDGk3F5OqAd/ozt04E2i04jOyvv4AxjR zHGAfsHrN+6KnYOcdNnm59cDbM06IbC3GPP3WyOieK8W+9Ux+NIgUhAW4inXGix2fAd8 EwZPmUFt/PYxAYf09gF5HZNGTHwaMJqxads85eiDaENsXc0RQ3BNpVItbKjkNA5sl1tg kLeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=keUvnikv2fU+HWn6Q+W4eeek0dfJyYNVPtI3OK++XrY=; b=U8JXmj/uvQEr51K9vxGYeGYHJKkOlTZdhkhgHtqsL8rKxsbUL7EmNurMuBMlbpZ5zr JN5u3c1cb5XrffdDV1cMq8XPAM+ryfGQ2dZ7OX32DC/4Vwlteskt2qkRt0mjjT87WoVw Qfm9fz1tBHxMIs7RO5CgrfKl/IYldlsfwbY9FOWKfB/XDsY6PPrwiq5XvpAixP3d6Ze/ tlewg42oRFmqqoimOBn5O6JP3jC8v5JXlGQAwlwV0J+WQkYKoVmuy/bH6hjwkiRrdSTd Ezsh/oBxq6rR4klnRJQYLU0JdsNdWcmSBbELtBFr8qTKfUPu228rNGqdLkuJwmWw8ouR zL6Q== X-Gm-Message-State: APjAAAX2NlhkI2iLYeNyDk7PL7ZwimZxZxZuc/ieripaljGHginlFS6i SJHSInC0Yd3MBDAXQtsgflEbUUcCkdjFkg== X-Google-Smtp-Source: APXvYqxXC1pDrGz3Fr+STqiGiu2Noa3Qo6IQkDBCtxPLbGW80/NOvMKR+hibTBAR/sXmxOdAnOEARg== X-Received: by 2002:a25:5788:: with SMTP id l130mr15046711ybb.334.1575781381713; Sat, 07 Dec 2019 21:03:01 -0800 (PST) Received: from ?IPv6:2601:c0:c680:5cc0:14bf:e310:19f8:dab3? ([2601:c0:c680:5cc0:14bf:e310:19f8:dab3]) by smtp.gmail.com with ESMTPSA id l6sm8646897ywe.26.2019.12.07.21.03.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Dec 2019 21:03:00 -0800 (PST) Message-ID: <4C8A8CB1-1259-439A-B213-D10D098010A6@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_B34488C8-16E8-462A-9985-91C5DBDABEDD" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Sun, 8 Dec 2019 00:03:00 -0500 In-Reply-To: Cc: php internals To: Larry Garfield References: X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] Inconsistent class behavior and undocumented(?) BC change From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_B34488C8-16E8-462A-9985-91C5DBDABEDD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Larry, > I am not clear on why __construct() is special in this case; I believe that is the Liskok substitution principle at work, and that = fact the principle does not apply to constructors. For reference: - https://softwareengineering.stackexchange.com/a/302477/9114 - = https://www.sitepoint.com/constructors-and-the-myth-of-breaking-the-lsp/ -Mike > On Dec 7, 2019, at 7:27 PM, Larry Garfield = wrote: >=20 > 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. >=20 > Consider the following: >=20 > class Ancestor { > public function __construct(int $a, string $b) { } > } >=20 > class Child extends Ancestor { > public function __construct(...$args) { > parent::__construct(...$args); > } > } >=20 > This works with no compile errors. For any other method however: >=20 > class Ancestor { > public function doStuff(int $a, string $b) { } > } >=20 > class Child extends Ancestor { > public function doStuff(...$args) { > parent::doStuff(...$args); > } > } >=20 > I get: >=20 > Warning: Declaration of Child::doStuff(...$args) should be compatible = with Ancestor::doStuff(int $a, string $b) >=20 > 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). >=20 > 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.) >=20 > Additionally, according to 3v4l.org at least, the error message has = changed. On 7.1-7.3, the exact error message is: >=20 > Warning: Declaration of Child::doStuff(int ...$args) should be = compatible with Ancestor::doStuff($a, $b) in /in/6NthP on line 15 >=20 > On 7.4, it reports on a different line: >=20 > Warning: Declaration of Child::doStuff(int ...$args) should be = compatible with Ancestor::doStuff($a, $b) in /in/6NthP on line 11 >=20 > 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. >=20 > 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? >=20 > https://www.php.net/manual/en/migration74.incompatible.php >=20 > --=20 > Larry Garfield > larry@garfieldtech.com >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 --Apple-Mail=_B34488C8-16E8-462A-9985-91C5DBDABEDD--