Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112166 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29032 invoked from network); 3 Nov 2020 19:58:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Nov 2020 19:58:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C3332180533 for ; Tue, 3 Nov 2020 11:19:11 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 3 Nov 2020 11:19:11 -0800 (PST) Received: by mail-lf1-f49.google.com with SMTP id 126so23725935lfi.8 for ; Tue, 03 Nov 2020 11:19:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=76s1E4K3Vw8n7BX1QvyH+Ef+NLC0JjAM2iD0xGSVbM4=; b=A90aHltXZI0i71FlVDZlRZx5JWeWiR3riLWGgLf05dxoIlfECO4Kil+d6HzemDp6WM J+r8UnX895UtKi7MOcY+eXW7ymnh85HWjzKkMVmTCT3JMRkOzF52ZzqV+OapDQg3LztZ cAXR84C+1QLLkL1AthhCPV9szsdTno4eu3GWyffG+tPo6XmEvYSmt5jqHhXMub2syE5a 8VpGxnwD9sbQbIoek1TX5RmdAo05QkfElerNq5IGVRjbv6MAozSLGTqNWHf/jtUlygc8 lldxfLmKwG6xRmDzJjxfdAANKdlXjcmZwfwVoW1eR9wjq05ledqujbzYu73nTPLYKFjB RvHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=76s1E4K3Vw8n7BX1QvyH+Ef+NLC0JjAM2iD0xGSVbM4=; b=ssp26DDdJkdlL4vfxFpreVuflFmmQrIjH2yUZoeIUGTV9dQzMxs870lqgKxvAS1YSF SIUgqm7IYm87oMN3+5UmbTpRraPrhJG1HCaUyE2g4pB/vBYOFfDVBh2hL5vCSvRB3HzG k6duOb3SPz5OA3LCFC3rne3aUpVG1Z5WBTvBHCk82cvFM7tbg/w3vU8hDypsSzxhF0La ccUAeIRKh/85u4Etw+y75pm7G16CKphgEml13qLlMQNF+cIm3zSb89rfVUgbUbO31FYr ZBy/qNsqojEYwpMOzkS7NWPTkiWPGtw0Yojl+2hPyevo5p3C/96znd0afoSqGet7DpIZ 0H+g== X-Gm-Message-State: AOAM5319iIWOK3VdMkWpdEvib/uR5RPNCG2OcSevE9GVm/uqLnzo4kVN VFO5TvZxmqA9ZEoRHzH8GMbn5o94NZVVe5HmYF9uAXuT0QQ= X-Google-Smtp-Source: ABdhPJxTM0CbdMYm/r5A8waYcZebUNg1YAq0Hajwr3zYPvIT8pFU3bnFwWGbho/7Q4XUW/GYNifyM+QWj2I5M3DBtII= X-Received: by 2002:ac2:4d12:: with SMTP id r18mr3657906lfi.354.1604431149438; Tue, 03 Nov 2020 11:19:09 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 3 Nov 2020 21:18:57 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000ba9bbf05b338bc8a" Subject: Fwd: [PHP-DEV] Nullsafe From: zsidelnik@gmail.com (Eugene Sidelnyk) --000000000000ba9bbf05b338bc8a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ---------- Forwarded message --------- From: Eugene Sidelnyk Date: Tue, Nov 3, 2020 at 8:11 PM Subject: Re: [PHP-DEV] Nullsafe To: Benjamin Morel When trying call a method, php falls with fatal error: https://3v4l.org/jk5Fp With nullsafe it silently returns null: https://3v4l.org/MhXtM Are there cases when we would like to use ordinary operator rather then nullsafe? In my opinion by default it should be safe On Tue, Nov 3, 2020, 7:58 PM Benjamin Morel wrote: > Hi, > > It currently returns null but issues a warning (which can be, and often > is, converted to an exception by frameworks / custom error handlers): > https://3v4l.org/1ZkVC > > The new operator returns null with no warning: > https://3v4l.org/Wmun4 > > Benjamin > > On Tue, 3 Nov 2020 at 18:09, Eugene Sidelnyk wrote: > >> But currently working code doesn't fail with NullPointerException? >> Otherwise it would not be a working code. >> Early fail will be when we try return / pass anywhere this value >> >> On Tue, Nov 3, 2020, 6:48 PM Benjamin Morel >> wrote: >> >>> On Tue, 3 Nov 2020 at 17:38, Eugene Sidelnyk >>> wrote: >>> >>>> I am wondering why don't we use ordinary `->` operator with safe null >>>> handling? >>> >>> >>> Hi, >>> >>> - changing the current behaviour of `->` would be a huge BC break >>> - and if we need another reason, there are many situations where you do >>> want to fail early if the left operand is null, so the current operator= is >>> a good fit >>> >>> =E2=80=94 Benjamin >>> >> --000000000000ba9bbf05b338bc8a--