Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123670 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id A5F8C1A009C for ; Wed, 19 Jun 2024 08:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718785854; bh=gj/uw4xceuc/PiEEmAY3Cg8Sw10+G3IvygkrSmOYLoM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Otz1K2BefMOvKg+JJxogaig+llQtOKXXLGvSUOdWK16cAHq7RusYyvsTBeI7FzttD +hiWq/IXzPow2lS1CYSvPlRxwQL48Fq8G1rB5sMSXZmG+YbLM2cPNQ6WqC24kgUOXu aF0FngooQTLRXHRq5nqE3xqutywRknA0VrHOac+ieSfiG0ck1XOi7gPqvqS3CbLEa6 nnakEnBr3E2zAU1gGXJ7Z/nbTA4OsbkMcXAwkx8FuW5dMVy5/8lnKHXFNpVzRt+iIi qSpROwHsuEaZNQ2XWHGsFt5pjFFk7iiS1fOBZ+TG0WDnnOscOAOZXw/nU0IvDMrp1M uVA2ep2z9oOlA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B30E0180003 for ; Wed, 19 Jun 2024 08:30:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 19 Jun 2024 08:30:51 +0000 (UTC) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-52cc129c78fso2207735e87.2 for ; Wed, 19 Jun 2024 01:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718785777; x=1719390577; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gj/uw4xceuc/PiEEmAY3Cg8Sw10+G3IvygkrSmOYLoM=; b=kr4zQDC5MYrQxDGl+/QX38pZTA+k/K+GETR3qgqADzxQ3yEshMnB/OcqXgv1WDSSYd N11evLjdbH3IzxRNikAMRkjT6eO7fkiLVvw18BmpvrxMTe257AHfbwJMkgaIhopQ9mdl H3VVSrsC/q/KWLKpXuC0uCPvrescHYHrZmc2v7TwVhvpWORoRu8G8pOJm/fZg8fx/d3C vgIa8r/LBX72RVkX3sDivPu/iXUdMKJdgr5WsPqPfQiGq37sYBmDmqvFPwslzWqZvgBf kfAxIdKuBzsAKAIN368x4uQWRH7q0iaco0BLi+5+NMdY4zs5Z368VtYGw1S4+4NMEE4l ZyFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718785777; x=1719390577; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gj/uw4xceuc/PiEEmAY3Cg8Sw10+G3IvygkrSmOYLoM=; b=VNWZG3eM6MEwv8oUjZweeQtyYz1RFlwWmB4YhUOCPMY08tdCyGa6EMuM9LmyvuTAwb FfXeANbEq7Zs6PKy0S6kncBiW9/eGHmxwTREDMsF8dcM5lUXqt3xSq+tgMXkou7Qht3P SSt+GHu1XEHyA7r1fua7NVDsTrIGq1oG2pr9xb4ywc3Euz+ZJbqngzjWPD0cUDARYpfE MubkFUgxR2GxYJgZ5Y/+82lKvbzyGjLlznKExX7C8WnM/feWVrCTCNwMv+WjNJcs/vrf kTh4Ck8mxhsyoFsdvz9eDE11A6MuJvGrxBeMKmqgj8V8ACrwXp9Zq4LFFzeFz00KWue1 sR7Q== X-Gm-Message-State: AOJu0YxbzKCVDEE7vs9OjdDK9xmdJmqI3SxKv6JchVfUYFIQkx7h/eQK W3qh6F8LGpuCFgtAtLQk25HeeoJyht6QaGGj0nw1S7OeW5hZxKWHsU3FOF0aSVqy0pGFchDU1mf Lf1bXHi/YJHm/8faCwN+TQHftELbwQheDGWo= X-Google-Smtp-Source: AGHT+IHpxbbA2hQ7Zp0OKuy5CPHszF2KdZj7lwjWht4rw9X5RYBt2psOr5PTKPKdJvosYxTxAh00zEKip89AX+r6E8Y= X-Received: by 2002:a05:6512:3248:b0:52c:9846:3b8c with SMTP id 2adb3069b0e04-52ccaa6a01amr1115237e87.41.1718785776432; Wed, 19 Jun 2024 01:29:36 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 19 Jun 2024 10:29:23 +0200 Message-ID: Subject: Re: [PHP-DEV] Renaming "strict types" to "scalar type coercion" To: Claude Pache Cc: internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Tue, Jun 18, 2024 at 9:18=E2=80=AFPM Claude Pache wrote: > > Hi, > > > One thing is clear is that "strict types" may be a bit of poor word > > choice and gives people a false sense of security that it is "safe" or > > "more correct" when this obviously isn't true. Thus, I'd like to > > propose, for PHP 9, simply renaming it from strict_types to > > scalar_type_coercion and flipping the value: > > > > > > > to > > > > > This not better. Even with `declare(scalar_type_coercion=3D0)`, there wil= l be scalar type conversions between string and int/float when you add nume= ric strings or when you concatenate a string with an int. This is a really good point and worth thinking about. I kinda like Rowan's suggestion of scalar_args with a usage of string values instead of integers. > > IMO, the real problem with the current name, is that there is no clue tha= t this directive is specifically about arguments and return values in funct= ion/method calls. Yes. This is kinda what I was hoping to address, but like you said, the name I suggested didn't really capture the semantics either. :D > > > Perhaps it might even be worth adding a secondary vote to flip the > > default, such that if you want to "old" behavior back: > > > > > That would force to edit thousands of files, ... for exactly zero gain. H= ave you heard about the Red Queen's race? This is a pretty simple search-and-replace, so I don't think it would be hard to update. That being said, there still needs to be a deprecation strategy that makes sense. As to it being "zero gain," words have meaning and choosing the right ones (even if it is years later) can sometimes be completely worth it and even have monetary gains. > > Moreover, there are many places where it is not possible to add such a de= claration. For instance, `array_map(...)`, etc., always use `strict_types= =3D0` when invoking the callback. Changing that would also be a big BC brea= k. > > =E2=80=94Claude Robert Landers Software Engineer Utrecht NL