Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122219 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24229 invoked from network); 22 Jan 2024 10:46:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jan 2024 10:46:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1705920411; bh=ozGoRBeRvKCQR9SwSTHnchnEO5O+Z3fKJ7gW/agsRwQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KgQ5wzkJxC7LKp9tgxnevROfIsrTonPa79qPyWPrT7gdYKK719n0oqnIm6l3QPOUw p++UWc/3TWp+S/DFMYJseVYkCt49AK1/IuXCOwKPVQiVCSi9xiyd1NuC8U9NeNuy0J FrbTmVGXwBhT5GIMsNuZlRxjDpGPJNis5hxX6Nxd79MGuT//v3mbkVFVXdoyzKZtEV HAPJmccdgHi50lelaHSQWhFN3EKIJ8xaD7vwPeJM1sLXhnaklqnHyPf6vWsSJc2A1g DGAU5TaJOt/PDqpP2N/HrGNaNLYj4Iu88ViSJlOCjyGvnwUHIG4oQAqoaVzdyykGbY qpnssFtqjfjFg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3D851180051 for ; Mon, 22 Jan 2024 02:46:47 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 22 Jan 2024 02:46:46 -0800 (PST) Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a28f66dc7ffso693142866b.0 for ; Mon, 22 Jan 2024 02:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705920362; x=1706525162; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cY+cT/Hi/+LGlt2SfUNLMUDhmg2o0JUbK34Y1A8DRBs=; b=Hz1aHHcBtLZvHobOHCpGNldxT2dRoOPStTOlTzOrUItzl63ocQbweHWl+2DBOx8FBP ltXelOtFci8AVaT9U68fLHHWMvbxpU0xgyZtIVnNLjRRAJocH/QDrYVPsu8I3Dt7XB5g qDUA1p7EKAEeVTMyVFMN1NK3PtHuR6JDQXhAJpqfWbJUL8yyWyJrlTE3yYMHWlV/aPD3 0j5qNBJqwitoYwP8/X4MLKSOhh5SqjWfYMInDfcKCc9/rbPDKm0mcJFJ4VAqzmgZKMUZ R9AT2wLjLiQwAL9vXrC5HR5oPJyZ747Gp9kW6Fpei4YjRFcIZQz6zJYZ6uKlxj6rcha8 4EUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705920362; x=1706525162; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cY+cT/Hi/+LGlt2SfUNLMUDhmg2o0JUbK34Y1A8DRBs=; b=Gb1x9gWuo0hVtiXbJQ4c8hVB3SOFlhyR7w0uuujE3II16rUldUp5Ca9hZH+dLAXjZ+ YzX7LA6JpKvuCncBYCU++1zTaq5cHA9k9wpOwem230joRzGmBk2/7MjmulSPvsOTICyR irOLtXo7b6nkDmrjyPeW6EAqhiUtsz+5J1die37fL7JdXDYi4G10J514H1qqlsPrWYgx buwxxHXDfi09HMnD6WA7j9hZXamN7/NcCc1K0JQlwzFIl9k1er+W/yaj8dbsHcuuUx/V dWErDbl5DujYLuO03DEhTSRexeJxYT50Dkky85y86m0ejYSfHg4KfSoVYCBnzRCZ15T1 jXdA== X-Gm-Message-State: AOJu0YynaS81Ib92ldg640Ro+T0BC68OjdsHMcnx2ddcIOo45dsz5Sq/ /t2e8ISi8vU8K88oAj19FtdkWTvZPRckLA1Sw8DAj+5Jzj+XN6dok+8YUcS4BhyQMGbahp+I77O KhQfxIXqV7Wk4UPlokcxt81Bc3YQ= X-Google-Smtp-Source: AGHT+IHhYJDg7P3fMjQInqVvKR8T4fq8cYJUbtjqfFvgULBvDeE8uqPuBN4efudYbr2nKbmQ56UBq1munBVT6HUQt5I= X-Received: by 2002:a17:906:318c:b0:a2c:d6f7:5fa1 with SMTP id 12-20020a170906318c00b00a2cd6f75fa1mr5103175ejy.8.1705920362292; Mon, 22 Jan 2024 02:46:02 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 22 Jan 2024 11:45:36 +0100 Message-ID: To: tag Knife Cc: "Gina P. Banyard" , PHP internals Content-Type: multipart/alternative; boundary="00000000000035adec060f868936" Subject: Re: [PHP-DEV] [RFC] Deprecate implicitly nullable parameter type From: kjarli@gmail.com (Lynn) --00000000000035adec060f868936 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jan 22, 2024 at 11:21=E2=80=AFAM tag Knife wr= ote: > On Mon, 22 Jan 2024 at 09:51, Gina P. Banyard wrote: > > > Hello internals, > > > > M=C3=A1t=C3=A9 Kocsis and myself would like to propose deprecating impl= icitly > > nullable parameter types. > > > > The RFC is available on the wiki at the following address: > > https://wiki.php.net/rfc/deprecate-implicitly-nullable-types > > > > > > Best regards, > > > > Gina P. Banyard > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: https://www.php.net/unsub.php > > > > > Also just did a quick test, and i don't believe this would be possible. I= t > would remove functionality from the language widely used. > As you are mistaking `iint $var =3D null` params as "nullable". Which the= y > are not, they are "optional default" parameters. The equals > can be succeeded by any value, to set the parameter to such variable wher= e > the parameter is not passed. `int ?$arg` is not provided as > an alternative, the directive `int ?$arg` simple allows the parameters to > be passed as null, it is still required to pass through the > parameter. > > To clarify > > `T ?$var` =3D Requires the parameter to be passed to the function, null > value allowed > `T $var =3D null` =3D Does not require the parameter to be passed to the > function, is set to null if not. > > https://3v4l.org/IWsqK Your example contains `int2` as type with a default value of `null`. This works because it implicitly marks the class `int2` as nullable. If you were to set this default value to `1` via `int2 $int2 =3D 1` it breaks with "Fat= al error: Cannot use int as default value for parameter $int2 of type int2" Anyhow, `=3D null` implicitly makes the parameter nullable even if the type doesn't specify it's nullable. The argument is that if the type isn't nullable, then the default value may not be null either. --00000000000035adec060f868936--