Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105213 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 30038 invoked from network); 10 Apr 2019 19:18:48 -0000 Received: from unknown (HELO mail-it1-f182.google.com) (209.85.166.182) by pb1.pair.com with SMTP; 10 Apr 2019 19:18:48 -0000 Received: by mail-it1-f182.google.com with SMTP id x132so4392231itf.2 for ; Wed, 10 Apr 2019 09:15:58 -0700 (PDT) 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 :cc; bh=Ar/aeqBCTqL0DEAtSh1Oqwa+KbbZ9EMrQn5990YW/7s=; b=UE1qAC/Tn4iW9tQEZpxN7F0AbDsb8vcFymEJjlfRsENF5UYO/gN13eDTDnjr1RNqOx KfPW6u3N7m+1slwd1pFqR36iI7+0FKVwlBnDGMklsydIGFq7mAf42OcL1Rmf/8MTA395 wFFFZ/gTHQKyopWCD1AT377j9iy7u2dJBWQkk8q2rDHg5Ibi5j7/1iy2ovwezpeKE6QY TxQWx8lrAFB4i3AbYlcBYQy2mz0SgIZTNF0cp2GwU0byetqy47VONs+48tS88vncd1iz 5Gf9eo+qZKhzCYY7unatpi1Sqh/XvfOZ4LwtGLIUHnKdcznt2l4PtKVAiY6Igx2GLcmS KR9w== 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:cc; bh=Ar/aeqBCTqL0DEAtSh1Oqwa+KbbZ9EMrQn5990YW/7s=; b=OWSUO242ffMo29J6xhLCLGB8o7sM9iCEGF+UjbqTfsxFup9fvv1bCjqLEIl0WvHbD1 0tZV4fxFJfjPpdynsXqiA2N2aYUQ9ym9lxPxrsTMhRw9n/d9UJcSpGOOrZ2DrZ5Xu9Bv cApHwBdkwFU7kAEpQN6GQsv0lteWhAQeqVOILYZnamF97JVjJ07bLOrGx5A+FN2EmgI1 wM5HXeEZLXS5ibRIa1wXhIrX7/sncth403s38tu1lUJdej3mGowNUEZnOVSOUbGYKI4H C5i0zveq+i4xJvz/rltx51YRItmpJCxYf9jTVrYgQAl7uikkUUsUBzvdvyP0j1SAOruq PkBA== X-Gm-Message-State: APjAAAVmJTWJoeIMRlavuUimAoSOps3MuM3Wnhs1iEHl7zINFOY6kiF6 fJXsZZRGk2ra49Zx+FEN5stkBevuqOzkZ2PE5xQ= X-Google-Smtp-Source: APXvYqw9Ui2KL+AV/vp2moG5ngM1fLp4xFv0nUWSL139cau2yiLFMdDSaR0NuJwMd4u5OJr0NhToaUUyrdxoNq9+biY= X-Received: by 2002:a24:52c2:: with SMTP id d185mr3807425itb.94.1554912958031; Wed, 10 Apr 2019 09:15:58 -0700 (PDT) MIME-Version: 1.0 References: <5cadfed8.1c69fb81.31f7d.1c49SMTPIN_ADDED_MISSING@mx.google.com> <5cae100d.1c69fb81.548c.48a4SMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <5cae100d.1c69fb81.548c.48a4SMTPIN_ADDED_MISSING@mx.google.com> Date: Wed, 10 Apr 2019 18:15:46 +0200 Message-ID: To: Mark Randall Cc: PHP Internals Content-Type: multipart/alternative; boundary="00000000000085323005862f6258" Subject: Re: [PHP-DEV] [RFC] Nullable Casting From: benjamin.morel@gmail.com (Benjamin Morel) --00000000000085323005862f6258 Content-Type: text/plain; charset="UTF-8" > > I believe returning null in those situations makes the most intuative > sense, yes. No offense, but how can casting semantics different from those already used in implicit casting be intuitive? function a(int $x) { var_export($x); } function b(?int $x) { var_export($x); } a("123"); // 123 a(null); // TypeError a("abc"); // TypeError b("123"); // 123 b(null); // NULL b("abc"); // TypeError IMO, the only reasonable choice is therefore: (int) "123"; // 123 (int) null; // TypeError (int) "abc"; // TypeError (?int) "123"; // 123 (?int) null; // NULL (?int) "abc"; // TypeError At least, if we want to fix the current behaviour, and not introduce another inconsistency. In other words, *strictly apply to explicit casting the rules of implicit casting when strict_types is disabled*. -- Ben --00000000000085323005862f6258--