Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108054 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55562 invoked from network); 9 Jan 2020 15:36:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jan 2020 15:36:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0196C1804AC for ; Thu, 9 Jan 2020 05:41:42 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075019.outbound.protection.outlook.com [40.92.75.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 9 Jan 2020 05:41:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jPhbSPBMPpX7fwpKk9l+kbMD+/ExRoBmctbD5vf+3D2vGd3lIqrITkemFZXS786k2zU5Cb6F/wPwbrYP0Teo2SP7UhPF7WpQXRqBoAoAY5oxF9tXAXgzqsYsZFCeORhhKVcuZoe5rYjtc9YpBkwkKcY7hhPJZ9NEQNQUqXu9XcY08yncwTC/QuEu2VlkyMZzRgGfZtO2G5lCJFXA4ZWDRG0nkRc09l9O+C3daE3i3XdV6i93C7O7vxPPZ/Ye1uDYyqv7xnNsoi6w34T0WypO+wUnXoicw3aYRZkdPUgbKg9sRvDljkXIoPgsdo/lXU/96+mWKSvpG6kJyERnOr6Dhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QOVmA8Q/eb0662JHErj2RAMSfFhsqCAucEFNAdLm32o=; b=oadMo4RnAnjwhSEbm+ssVf2249NI7ToJNen5wRUCRh+q2lglLpQoULQn3GKczA17HHf72Kb4/FT8q9rq7tpen6hiXih2XcCNqaDaGNU9TEt6IC2r0wFJoadyky9m17nh1enN3D91aWv9wlOAkoJrJypLmLWRwnWFdvZ5GBJcVTqkfDYPgfIhygFj8pVLNyojfb0QFIkaOdz/y7QBNbZ0a+ToQ7NyFUWQ+3oe2e4RR6ns/jdnwx58Llzj6hy35dY4LeKZvHZa7NG4uNmD1hBHSdJAPacq7xMwggdR12gN1AhNLrDYy6V4gciLH00ZSN/MGs1ROkloZl3PMaBYQ2Iv9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QOVmA8Q/eb0662JHErj2RAMSfFhsqCAucEFNAdLm32o=; b=c+Csc8VnuJdW5BDEY4Nt4SKndl2c/jwZgPej3Q+58Jt8pZtl0CLeSc6Xg2nJl7cb/gIXhJD117Z1Ls+V3Y+Q9wMsNyvDQ8Q1zKs5hsfNpp8rtxXfCnHFRlephJq8YgIsH//k0o6cUI2+ASHN30zOaMMqo90EQPhcUDdFDY58eHlqBBIFnzCfGUKi4ITP9SnHfy8N7xqSdgWeqME6yO9sOLembMmPdYEtYUcgqeSE3WZ6rT2osheEN9JWuNtK0VeXKg87Rn0azPBqk1k7M9v+VxpY78m9lGtQV4dyP30VZcbotekbGJoSZSESImW/ZZfgxZ5N6Ez3MYz5O2mxKeGPJw== Received: from VI1EUR04FT015.eop-eur04.prod.protection.outlook.com (10.152.28.53) by VI1EUR04HT088.eop-eur04.prod.protection.outlook.com (10.152.29.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9; Thu, 9 Jan 2020 13:41:35 +0000 Received: from AM6PR09MB3317.eurprd09.prod.outlook.com (10.152.28.56) by VI1EUR04FT015.mail.protection.outlook.com (10.152.28.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9 via Frontend Transport; Thu, 9 Jan 2020 13:41:35 +0000 Received: from AM6PR09MB3317.eurprd09.prod.outlook.com ([fe80::99ea:a6ef:3f41:d535]) by AM6PR09MB3317.eurprd09.prod.outlook.com ([fe80::99ea:a6ef:3f41:d535%4]) with mapi id 15.20.2623.010; Thu, 9 Jan 2020 13:41:35 +0000 To: Nikita Popov CC: PHP internals Thread-Topic: [PHP-DEV] Warn when declaring required parameter after optional one Thread-Index: AQHVxugivIx6PvkvEEu7H61CW7TTaafiVzJp Date: Thu, 9 Jan 2020 13:41:34 +0000 Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:9C4C1383F0B64E4C3D535BC77EA7A9C064DC20CB459B02439031A5C401DDCDCB;UpperCasedChecksum:21BE4B7C16A631F334CB1F5C8EB0728CB3B3DD40EBE41C8D4EBCAFCA813076C7;SizeAsReceived:7008;Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [FBjJP+wXrCCCSyoyObmOObsV0cavI0k9] x-ms-publictraffictype: Email x-incomingheadercount: 46 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: c6811219-5f8f-4bd7-c005-08d79509a4e7 x-ms-traffictypediagnostic: VI1EUR04HT088: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kZ0H+ZT3M1xl/AwfT6VT7TRd9OgavT4QWA1VLi5YJMRndrmf8Eu98YU5FBK/16PlNwqGo6Kh2kc2MHX/dSChJ+qHl+XkoZTn6y1kFzjY7QAIo7rgnBIi/rr/ViGut/vsmE0lTsLDFH7TpU77KOeCvcS1OcYqQGr3QuGVv0sXdlBDx9FnP9t7Sh7dDhB/lFgKPBrnrpyLXQ9RB6Blc2OyK1P4ZMDoiP+6mNdyQBl5bwY= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: c6811219-5f8f-4bd7-c005-08d79509a4e7 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jan 2020 13:41:34.8601 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR04HT088 Subject: Re: [PHP-DEV] Warn when declaring required parameter after optional one From: bobwei9@hotmail.com (Bob Weinand) Hey, While I generally agree that it likely is a bug in new code, I would rather= deprecate it than warn or even error: the change would make it impossible = to retain a type without warning while preserving compatibility with an old= PHP version and making incremental migrations harder (would then not be po= ssible to write warning-free code running on 7.0 and 8.0 at the same time w= hile retaining type information). I would like to see it deprecated and then removed in 4+ years. Bob > Am 09.01.2020 um 13:27 schrieb Nikita Popov : >=20 > Hi internals, >=20 > I've created https://github.com/php/php-src/pull/5067 to make code like >=20 > function test($foo =3D null, $bar) {} >=20 > throw a warning: >=20 > Warning: Required parameter $bar follows optional parameter >=20 > Historically, having an "optional" parameter before a required one was > useful for poor man's nullable types. That is, one could write >=20 > function test(FooBar $param =3D null, $param2) >=20 > to get an effective >=20 > function test(?FooBar $param, $param2) >=20 > signature on old PHP versions that did not have native support for nullab= le > types. >=20 > Since nullable types have been available since PHP 7.1, having a required > parameter after an optional one is increasingly likely a bug rather than = an > intentional workaround, so I think it would be good to throw a warning fo= r > this case. >=20 > What do you think? >=20 > Nikita