Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105136 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2355 invoked from network); 8 Apr 2019 05:58:25 -0000 Received: from unknown (HELO mail-pg1-f174.google.com) (209.85.215.174) by pb1.pair.com with SMTP; 8 Apr 2019 05:58:25 -0000 Received: by mail-pg1-f174.google.com with SMTP id j26so6426543pgl.5 for ; Sun, 07 Apr 2019 19:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7eBtIyXEkgD8elmJgkdfuawytSFNquhkq2AcJ8JJnTg=; b=k/GNmlfn/PtlmY7iXipfdXDKNiLngwv+nFQ7iIHlMLXwt6HnTlVsvt9O7n4eO+E15a InfCx8wWPofFyJ5LsMHqG6vvHU/mxb2AsP/m4gL5OOFxGeCjSu/VVJEinXzUg+IqUcwK cH0WAHVeRdiIQG7GVMmLAciCrK5HajIusX+REeomJPLEHdRvTpaMXpELko8k3rhIdSgQ qIXMQwTzbMhS4Cg2K50MqZuuCJQmlalUniS04FszlYI79JDQC2RLV64QFURQixJZuKN1 aKULaW/SJn2i6qmcJh3uaB60A7rEQxQEeW3009vx4b96FWPxdszY7xRdw7d68bJvPTIk 6XtA== 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=7eBtIyXEkgD8elmJgkdfuawytSFNquhkq2AcJ8JJnTg=; b=qeXUm+bIqostCkln6pWz10AY7bqLMz67onmI4FwCHAZ7NrpuCJkYN2cgxX6Tvr7P83 T3JashLn4YTMVJYkjcPM06QWzIOrhpmH7K0KdbC+ElJRFDFPhfl0pYhfy/IGsuL60nL3 bZoemHthguFGxwe0dftgadCvE3w2AOM2KmkyERwtlnf1bbvG3EYDQyrVkBnnc2CO0GpA 5wD5Z69pyv6rok+x8m/O/kZnSdpBCddOKaQa3yIG/XeG2/QHFiMPc8kPlFYEAJVeTG7v L6s3ohXJkXQ99sc198XPScruAk4+1VUsimomOLLGKeMR7t9JpZVBchUJpd2lXGlWZryi fzxQ== X-Gm-Message-State: APjAAAXGx1yGg/W/F5f9qH0yqYU+vZoKomP4eROB4pafzW45voaCvBJA fFBHM4PRGgIetOgHPNb1iB1TrRuKYNAIqHl4F68l/g== X-Google-Smtp-Source: APXvYqxdqDU9gT51LGEjexuTZNHJiAoROXUvIGiIMHu4vNmMxuOaQLwXBaNuJZvaxcMvX4xbGICqDRZKzZj5C0adyyc= X-Received: by 2002:aa7:8252:: with SMTP id e18mr26940925pfn.105.1554692096306; Sun, 07 Apr 2019 19:54:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 8 Apr 2019 03:54:44 +0100 Message-ID: To: Guilliam Xavier Cc: PHP internals , David Rodrigues Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Nullable Casting From: Danack@basereality.com (Dan Ackroyd) On Sat, 6 Apr 2019 at 08:53, Guilliam Xavier wrote: > > Hello internals, > > David and I would like to open the discussion on our joint RFC: > > https://wiki.php.net/rfc/nullable-casting > > Mainly, it would enable to use e.g. `(?int)$x` besides `(int)$x`. > I'm guessing you don't actually have ths function getIntOrNull() in your code-base? To help me understand where this would be useful, could you provide some 'real-world' code where this would be useful? By the way, this RFC is a special case of something that could be far more generic. If it was possible to register callbacks to be used when casting, people could do something like this: function castToIntOrNull($value) { if ($value === null) { return null; } return (int)$int; } register_cast_function('?int', 'castToIntOrNull'); $x = (?int)getIntOrNull(); > Additionally, it was requested on the mailing list to consider adding > support of nullable types to the settype() function, > e.g. settype($variable, "?int") Someone probably needs to make an argument for it to be in core, rather than just saying that it's something that could be done. cheers Dan Ack