Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113081 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65291 invoked from network); 4 Feb 2021 19:22:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2021 19:22:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 33C9F1804E1 for ; Thu, 4 Feb 2021 11:06:44 -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,NICE_REPLY_A, 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-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 ; Thu, 4 Feb 2021 11:06:43 -0800 (PST) Received: by mail-wm1-f41.google.com with SMTP id o10so6512922wmc.1 for ; Thu, 04 Feb 2021 11:06:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=gsLmX8EbY79qmA6SnPGpwgH2JXTyElwTayrmyX8wHOE=; b=XS9hIWGRqL9jy0hqVIDQqh7MDntzRJefA3JAS8agd8PBVdgbsiz6Ux9YeC9Z6KEtrD KCqynMlbGc1gapQkSj6cYDxvg5zWb4Xy+421licp21xt0GcitChjxt1+qaJUoLawdtzC fjtmgOinGLkrCbwALRjQAGt+kuXttTc6eyQ5j0q0wKawcOjb+vuOlImxKz2mN2NMDL7N PxSoYX4yvUG6BxYvEVzYj7FzEdCzOr3tmBiXPLi8lYfQLd0x7vrBsq2HrKDQEFkwzY5R 3Dw4ejsXQggMrFBaoOARToWzG1s9l7jvklF3sxXWeFcVqiXlVoiKjE5DZ51zV2+MgKEz 6ntg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=gsLmX8EbY79qmA6SnPGpwgH2JXTyElwTayrmyX8wHOE=; b=gFccPiz9STv7X76or41wuZdHO/0kU1aZDKyyyAwYOuzXNUks+WvfMg4R9TtBHZNlLu 04Sm9m7sA2jQCvj6xDS/fxyMmmMGlEycJ9TWepp1n1/MgNKdcMmA8/YaBGi8oVvBJ31/ h9HkABzhOh281GGcLGzqAoN1E/TUcDEIW2Y+2oH7TUY+wkWfN/X8TKIhO7O8AHOIxbGo zRtcFv3KJCILLWhdYqs56K5jG+OKBwtVpdL9nHvqKRQPnkyZnxUR5m0Nf2OvmZ9E5Mu+ /R2bfwdxm2+HCAGk7gUV+DKdfheY69ouB15/knEZQRpAVIJ42dl7nCKoeh3Q0KYc+xjO cH5Q== X-Gm-Message-State: AOAM532WFCjZ1HR5IqWf7EYAXWlhX1+EfjpMHyzZg4WjU9k3C18sNStY t9wP55DpCVapaAfU4Pzxbant/m8ARBo= X-Google-Smtp-Source: ABdhPJyn+wsmC6+p0Yvq4QF8hZhJDYJrCcfBAiT+wCFaD4t7lJLU99kwrl7XZ6A81W8NkjPyvw+6hg== X-Received: by 2002:a1c:99d1:: with SMTP id b200mr541566wme.37.1612465602229; Thu, 04 Feb 2021 11:06:42 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id l1sm9392270wrp.40.2021.02.04.11.06.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Feb 2021 11:06:41 -0800 (PST) To: internals@lists.php.net References: Message-ID: Date: Thu, 4 Feb 2021 19:06:40 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Warning for implicit float to int conversions From: rowan.collins@gmail.com (Rowan Tommins) On 04/02/2021 17:54, Benjamin Morel wrote: > $age = $_GET['age']; // '25.75' > $x = (int) $foo; // I'd expect a warning, not a silent conversion to 25 If we want to make explicit casts "fussy", that would be a much bigger change. Right now, the following are all valid, with no warnings, even though they are all lossy conversions:     (int)25.75,     (int)"25.75",     (int)"hello",     (int)"99 red balloons",     (bool)2,     (bool)"yes",     (float)"3.1415 is not pi",     (string)M_PI, // calling this "lossy" is a bit of a stretch, but it will retain decimal rather than binary precision There's a case to be made for "strict casts" - I've pointed out before that so-called "strict types" mode encourages users to write code that is actually *less* strict, because explicit casts are very forgiving. However, they should probably be a new syntax, because there will be an ENORMOUS amount of code using deliberately using the existing casts in lossy situations. Regards, -- Rowan Tommins [IMSoP]