Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:122238
Return-Path: <ayesh@php.watch>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 32145 invoked from network); 24 Jan 2024 05:16:44 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 24 Jan 2024 05:16:44 -0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
	t=1706073448; bh=03lnsmaj029NhQdBNV9aMkN/4GwaHLKl5PB8yyPDpKk=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc:From;
	b=No/LCHPJxGfk0nD4TuqLDbm+Ed6QyIRDlL/kv7++QvAscjweAxd9NbRAMjmvfFu9O
	 nneAkl6+RlNkWR2zBqvKpTGjyfHX3WPbNofFTzGgwphf0QnWB+BDCX8TMQdYDd9aOT
	 KFTWmolnhLBwzleZOcZzXyF/8jA9F5cpPgsI3q41MaAjaBkAkklgG0iRn2QMCvwoqm
	 mqKkLnEHtwKNbGfObi1Ki1b+AKsnjJzQFvobAUpB9LcdZ6qSjOphGgVsI6fSUkkKXH
	 7O2ibOsof8reCRpuX1e9/Vz5kcpS6yYjoFcDuyl1HN7aekJ3/3NuTysH50F4yyn8Fa
	 rSvnuplkYZuOg==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 50B4A180069
	for <internals@lists.php.net>; Tue, 23 Jan 2024 21:17:26 -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,RCVD_IN_DNSWL_NONE,
	RCVD_IN_MSPIKE_H4,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: <ayesh@php.watch>
Received: from forward502a.mail.yandex.net (forward502a.mail.yandex.net [178.154.239.82])
	(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 <internals@lists.php.net>; Tue, 23 Jan 2024 21:17:25 -0800 (PST)
Received: from mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net [IPv6:2a02:6b8:c18:4001:0:640:bc2:0])
	by forward502a.mail.yandex.net (Yandex) with ESMTP id 90939612A7
	for <internals@lists.php.net>; Wed, 24 Jan 2024 08:16:38 +0300 (MSK)
Received: by mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id bGLBTC4jD0U0-dkKRQiLH;
	Wed, 24 Jan 2024 08:16:38 +0300
X-Yandex-Fwd: 1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=php.watch; s=mail;
	t=1706073398; bh=EXlE2UceUTRbZhte8zDzJnqwWt78TZVPfvO/ErOW19k=;
	h=To:Subject:Message-ID:Date:References:From:Cc:In-Reply-To;
	b=CQCs3oRtLqVyO+Plock50CnrUsCTmgpIF9+RJD+p2bbPOqA5eplg0IRu/pz/4+bPE
	 Y86aReEzR2/Q3L9W5TZmF/CLHjNhCpqgxXWmHSCsK4cKEtEUEltDLu5ExWezIIqMUV
	 wYb+Bt+64HodQce6ztaNVZRGcfL4sUit8Mhuy64M=
Authentication-Results: mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net; dkim=pass header.i=@php.watch
Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2cdeb954640so59559071fa.3
        for <internals@lists.php.net>; Tue, 23 Jan 2024 21:16:37 -0800 (PST)
X-Gm-Message-State: AOJu0YxLoAX6uws4UR0ATQnJeyzMFXwbjyH0jIohnSITWmtkds8Qu4a3
	pprGfRySjVYoakp/n5L+ATa2akMyO95FxNXzlcbfyax0XEtp8c8GLNRTA95Gxr3rRUjFZRI9oLu
	gJmfxDQ8JIVWfyaJ6/0thKmQnXSk=
X-Google-Smtp-Source: AGHT+IFHrsKOgHpvm/GNDQ9ySWrf/lOKetHaYNoIDz4isH7TpjGg5WjvgQWFzC2qQpd+EinkAVv9TKowXJGPlG//2Ks=
X-Received: by 2002:a19:6755:0:b0:510:ac0:681c with SMTP id
 e21-20020a196755000000b005100ac0681cmr849177lfj.67.1706073397727; Tue, 23 Jan
 2024 21:16:37 -0800 (PST)
MIME-Version: 1.0
References: <kii8EchCRNKJRI1IgoTQGYbxr2d0_BNN6dm4QrEFnWNaWLaH68cG-GioF5j6ebhIJv5wAVKdHojWk5XJqk9z_yL4cA0Fmb1KD0P19VrCiXU=@gpb.moe>
 <CAF-mU4ydv5f7=GnXPM_BMkKOxr_UGScKAkrbTVJ0Z6+nCByu1g@mail.gmail.com>
In-Reply-To: <CAF-mU4ydv5f7=GnXPM_BMkKOxr_UGScKAkrbTVJ0Z6+nCByu1g@mail.gmail.com>
Date: Wed, 24 Jan 2024 12:16:11 +0700
X-Gmail-Original-Message-ID: <CANLbj-pKB32nn0TgSOghzgqJP_QWLhFh1T51E+B1HzNLm_CRQg@mail.gmail.com>
Message-ID: <CANLbj-pKB32nn0TgSOghzgqJP_QWLhFh1T51E+B1HzNLm_CRQg@mail.gmail.com>
To: =?UTF-8?Q?Rokas_=C5=A0leinius?= <rokas.sleinius@gmail.com>
Cc: "Gina P. Banyard" <internals@gpb.moe>, PHP internals <internals@lists.php.net>
Content-Type: text/plain; charset="UTF-8"
Subject: Re: [PHP-DEV] [RFC] Deprecate implicitly nullable parameter type
From: ayesh@php.watch (Ayesh Karunaratne)

>
> I just encountered this language inconsistency when trying to remove
> nullable from a constructor-promoted property:
>
> ```
> class MyClass
> {
>     public function __construct(
>         public ?string $title = null // removing "?" here causes "Fatal
> error: Cannot use null as default value"
>     ) {
>        $this->title = $title ?: resolveTitle();
>     }
> }
> ```
>
> Which is fine, there's a simple workaround, it was just surprising.

Property types don't infer nullability from the default value being
null, so constructor properties don't allow it either. I'd say this is
not an inconsistency, but rather a *consistency* with what this RFC
proposes to deprecate and remove.

Highly supportive of this RFC :)