Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110095 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56441 invoked from network); 8 May 2020 23:04:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 May 2020 23:04:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0CC591804FD for ; Fri, 8 May 2020 14:40:30 -0700 (PDT) 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,RCVD_IN_MSPIKE_H2,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-oln040092075090.outbound.protection.outlook.com [40.92.75.90]) (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 ; Fri, 8 May 2020 14:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lo8BoLDfRLmRpulvEa++zVIpUATAv57d6jKU0NRc5e6kyk6hbCuSATIaFjoCjpoOyRVvUI5R9YXmDHle+MO7znLMaS/HCYy2YIs4DyFcvnUvyGtaDSN3+H/JIhupLEPF/ruRoUoUed2HCWbnm+H7C3vCJOLerzhTycYZPLT4Bb5Z50sgCxfGuCM9xoCPtCvvcE+xrZDleA88MBxHKhVKThSPSJhwtZquZGjKNDIZtNuJgk/LSce49Hs6YyybZ9BA0OOcZlpLiCbhkKIB6Mol8hEYK6cGTcFNnOAD77VBM9k4O0Z7QrjGGsJm70pu9+Ioco/Ge3BbBHqfBVfF14drZg== 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=0phyRXm8fd/v4qPFNADVZcnoSaDjC77lX42o/MQ8G8I=; b=dv03QTz8lDc3zOa/rwqz3VGtwcy6gKggCDLILZMZVGPWxL3qNMhqQKeW9ADKqnkicRLRQdieXbyyoct1e3FD8U6GARDRGFx2k40thyWz/QpujeLSRr8Nd0E9yEZs0oOgf1u4qQzWlz6U+ul9LPBoz05aKmm/K1kH1Tsy/31mvBt1qAZRoyWPOfS3d0nUksk43+AimDsCIMUdOJL2Yu+2x09T6K7fjCYJCQekMCpB/2zbHq2F7zbeumxnUQKlNI3cS2Zhs1CJKCIKw12flzV3scf0aWrwLb3z2L4gs9Yn3zLz4Snw6yFeJ+rWOU3yQ/1iTy2OA1q41sgM/HyUNLHg6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.com; dmarc=pass action=none header.from=hotmail.com; dkim=pass header.d=hotmail.com; 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=0phyRXm8fd/v4qPFNADVZcnoSaDjC77lX42o/MQ8G8I=; b=slb0XzPsiDISFLpbtgZvOXPYjFQ/ixr3l/ggsdoQT22MkNf+oChOQq7vrekfeiNTffryQdemUxlpiJ2geY3CquvBh6eSc0kF1qM+TaWAu4kNpuk0qF0qiZpcqBMwLSVmOMLu3Sa4DT1Rl/jT7emQVDlfT5grBVOVIgaF7sRVwft1HJYDXNLBExrNqSh6s7xF/vm1F6ovX5/tt/qFcGXWqeYDL9mW0yG4evlV5hbzZWGCwHhfRKStbLDst7K45RpIUruBXNUbAc/Z1mB0MAo7gZ+PJw0Yecihaw4YJnmFTDOLxDhblRQp8LCSTJHKh2GTC6r1S7Z7A9QEzfhqcIsV1g== Received: from HE1EUR04FT034.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::49) by HE1EUR04HT175.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::387) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27; Fri, 8 May 2020 21:40:27 +0000 Received: from VI1PR02MB4703.eurprd02.prod.outlook.com (2a01:111:e400:7e0d::49) by HE1EUR04FT034.mail.protection.outlook.com (2a01:111:e400:7e0d::293) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Fri, 8 May 2020 21:40:27 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:5F06B6DDCA0062231F4A559303AE8487606BAD64B27B8547DD0DF5D06E0CB069;UpperCasedChecksum:EE33D3865CD9A52DAFD213EC4C87C853D9E5A7AAA7D29550B557DB76EBF3DDA0;SizeAsReceived:7750;Count:50 Received: from VI1PR02MB4703.eurprd02.prod.outlook.com ([fe80::61d8:9f5e:4baf:492d]) by VI1PR02MB4703.eurprd02.prod.outlook.com ([fe80::61d8:9f5e:4baf:492d%7]) with mapi id 15.20.2958.030; Fri, 8 May 2020 21:40:26 +0000 Content-Type: text/plain; charset=us-ascii In-Reply-To: <171dee3baf3.bef5753260554.3262181919550021853@manuelcanga.dev> Date: Fri, 8 May 2020 23:40:22 +0200 Cc: Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <171dee3baf3.bef5753260554.3262181919550021853@manuelcanga.dev> To: Manuel Canga X-Mailer: Apple Mail (2.3445.104.11) X-ClientProxiedBy: PR3P191CA0040.EURP191.PROD.OUTLOOK.COM (2603:10a6:102:55::15) To VI1PR02MB4703.eurprd02.prod.outlook.com (2603:10a6:803:8f::13) X-Microsoft-Original-Message-ID: <36A0BD75-9A0F-4C89-8172-84943746F4FB@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2001:7e8:cb47:6400:7457:1108:e8c:f12b] (2001:7e8:cb47:6400:7457:1108:e8c:f12b) by PR3P191CA0040.EURP191.PROD.OUTLOOK.COM (2603:10a6:102:55::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Fri, 8 May 2020 21:40:24 +0000 X-Mailer: Apple Mail (2.3445.104.11) X-Microsoft-Original-Message-ID: <36A0BD75-9A0F-4C89-8172-84943746F4FB@hotmail.com> X-TMN: [xknXYw/CIxRQENRbxjQSM5OM4ADKvj8P0yyTY7ZrpqvAHeRVO3drJxGxSnlSZVA7] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3fd38c87-c51e-46ae-9e7b-08d7f3986aec X-MS-TrafficTypeDiagnostic: HE1EUR04HT175: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Utu86hbgN44OSE8b/drFiQQS4bFl7H4bqME9r5dLO0nE0TknqM7L7pVV/BOm0IARTQn+bekZZIK4jWse3VpXyWdgsGW1IGJ7VCMAVDemrPRrI+9oSJE4tRxU82U1hueiwrXQnewTCQTwH71YTd+1Fpc4qzsYx3NHRsUtPEs39qqF0wbJNCf65Eam7ASiEHN3LX9/IUiolFPTWO/4Fe4vhQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR02MB4703.eurprd02.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: mtAbIyrHxC7lrM6LyV/kuH3ItY291m5Vl94+LH/bAjMD5tCk0TTgIN0oq8TGJjV5XuP09tLwX6OGDiF9tnpMW4No3xv27TIX1ouRfrLblEHFaWgABTo9Gpf/hI5qxJPd425RWMcWF1qpbsbJgglx5LBah6BDBIuI0VHj/VfI/EV4IKF4PrdY/gaPK7/qBCTKoTUhSfwqeU05uGpyIJjU0Q== X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fd38c87-c51e-46ae-9e7b-08d7f3986aec X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2020 21:40:26.8172 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT175 Subject: Re: [PHP-DEV] [RFC] Keep type of reference params From: bobwei9@hotmail.com (Bob Weinand) > Am 04.05.2020 um 10:53 schrieb Manuel Canga : >=20 > Hi internals, >=20 >=20 >=20 > I would like to present a possible new RFC( "keep type of reference param= s" ) for your >=20 > consideration. >=20 >=20 >=20 > Firstly, an example: >=20 >=20 >=20 > ``` >=20 > =20 >=20 >=20 > function my_array_shift( array & $array ) { >=20 > $array =3D "string"; >=20 > } >=20 >=20 >=20 > $array =3D [ 0, 1, 2, 3, 4 ]; >=20 >=20 >=20 > my_array_shift($array); >=20 >=20 >=20 > count( $array ); >=20 > ``` >=20 >=20 >=20 > The result of this code is a warning( in count line ) because of $array i= s a string.=20 >=20 > However, I think it should be an error or exception when a string is assi= gned to $array var.=20 >=20 > In my opinion, $array var would have to keep its type when function ends. >=20 >=20 >=20 > What is your opinion ? Do you see it useful ? >=20 > Thanks and I'm sorry for my English( I'm a Spanish ). >=20 > Regards >=20 > -- >=20 > Manuel Canga Hey Manuel, the primary issue (apart from the BC break) here is leaking the reference a= cross the function boundary. function a(array &$a) { $GLOBALS["globalA"] =3D &$a; } funcition b() { $GLOBALS["globalA"] =3D 10; } $a =3D 1; a($a); b(); // $a is magically changed to 10 Yes, you can here verify, that $a is an array at the function boundaries, b= ut you cannot afterwards. If we had proper inout parameters (which do not leak a reference, but assig= n the value of the variable (in callee scope) back to the passed variable f= rom caller), then we could easily enforce it. But as it stands now, this is not an option. (Especially due to the false p= romise this seems to make.) Bob=