Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105150 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66446 invoked from network); 8 Apr 2019 18:44:44 -0000 Received: from unknown (HELO mail-ed1-f54.google.com) (209.85.208.54) by pb1.pair.com with SMTP; 8 Apr 2019 18:44:44 -0000 Received: by mail-ed1-f54.google.com with SMTP id d11so12104979edp.11 for ; Mon, 08 Apr 2019 08:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=eUe+M4NKy0L5idkbOctQW2hqG2MfPai+1rVxQL9D7VM=; b=UZKeBNJEJOJa+yy4cdlFUvlsz8z30bs5XC8+bPoQ5UUpfqF1BN4hJxRYQrtOVwtsBR AbwAUGS/Lp/HvGdpCoZgaIYzxGYY85PPxOcm+cCDNf82NjnKugxUjAU3wahVKCY7rody o6cc0OjSL3Y3SgVqoZ9jI6AEVyB8cTFe1xRcB6UUB4lac3T/R0dWDmay1BtEd/GyoTY9 SDMulagWuJulPMY5HNnEagip0kRfc8x1P4s5e2dyPCYLjsgIn0w7cTBVt4erExlAzIBV 9WE2mTaGWti4lVOBxeKMw0nwajPO+dRDS5ERbxpbtYArPsQKy7RwLVIRzXAomUHRv/2f IkGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=eUe+M4NKy0L5idkbOctQW2hqG2MfPai+1rVxQL9D7VM=; b=MH8jBddF8d6jPYuS2y94gJT+DNSEClwiQX4MXWl1Cj5Z37bWlWcDwT+Brp50xNlIuu TThCUP8A3sRYdBD5bCF75R70205ZCEjuPNlJpTnjKojNGcHYEbAbJVr454dYpOmXQVv5 LcWaFktXTxcTkhNd59nqeJ3soWIe1iaReLWBge7+/VdJswH/N1U9qgiO8lYtxJc+9L0A ApOr/oVsoll1JDZ6Jo21RkuQcrfiHP41pJapJZ6rbCAFO5fxxSq8KryqzMR82xkZC5eC kRJrGg7hwE0gQL7yrggTZ7gON9XD8B+WOQ9nVqetvhlXHC4qikeffqFKAiyGSm6lBSCv 17sg== X-Gm-Message-State: APjAAAVJHCTpa6R5NOcAGGy00FILXVB1/UMT1OWQf9uhw0RJlIMTrx/q u80Y3KHh9nMVythO3pK+/m5Nt586APkrhQ== X-Google-Smtp-Source: APXvYqzZJmiwJ56lhPY3dj9qw9BcX1pgcjeQ2tbontDVWVrRrUrgcYQsxBXEEOmU+flumpzB7feIyg== X-Received: by 2002:aa7:c258:: with SMTP id y24mr19277989edo.68.1554738084215; Mon, 08 Apr 2019 08:41:24 -0700 (PDT) Received: from [192.168.0.63] (84-75-30-51.dclient.hispeed.ch. [84.75.30.51]) by smtp.gmail.com with ESMTPSA id d13sm320546edl.77.2019.04.08.08.41.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 08:41:23 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) In-Reply-To: <5F014F9A-5BBD-4DED-B490-05FC681DE2BF@koalephant.com> Date: Mon, 8 Apr 2019 17:41:22 +0200 Cc: Benjamin Morel , Dan Ackroyd , Guilliam Xavier , PHP internals , David Rodrigues Content-Transfer-Encoding: quoted-printable Message-ID: References: <5F014F9A-5BBD-4DED-B490-05FC681DE2BF@koalephant.com> To: Stephen Reay X-Mailer: Apple Mail (2.3445.104.8) Subject: Re: [PHP-DEV] [RFC] Nullable Casting From: claude.pache@gmail.com (Claude Pache) > Le 8 avr. 2019 =C3=A0 12:24, Stephen Reay a = =C3=A9crit : >=20 > if your target =E2=80=99type=E2=80=99 is `?int` and you pass an empty = string, wouldn=E2=80=99t you expect to get `null` rather than `0` ?=20 You should get the same value than you get in: ```php declare(strict_types=3D0); function foo(?int $x) { return $x; } foo(""); ``` BTW, this is an argument to the have nullable casting functionality in = core, rather than leave each developer to craft their own solution. = Because PHP does already such nullable castings in several occasions = (typed parameters, typed return values, and soon typed class properties, = when you are in strict_types=3D0 mode), we should offer the programmers = a built-in evident way to do the same type of casting, with the same = semantics in occasion they want to do it manually. Otherwise, one = developer will decide to map the empty string to null, the other to 0 = and the third to NAN, and they get problems when they refactor the code = in a way that a manual casting is replaced by an automatic implicit = casting or vice versa, and the semantics differs on some cases. =E2=80=94Claude=