Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124652 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 521971A00B7 for ; Sat, 27 Jul 2024 19:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722109943; bh=DEngUZmOrEm/rbh/GhY+MFNPJdP9XofOLDqv+QUU1fw=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=JzgIWQrFGphYeTzxzPPB9vq9deTiXaYkVWig3UVmeVhBHldFcfYjucPr0+K0qxvgr W4L+y+Yd0PhO+jYOK8RDu1nYb2o60WYEyNac35I8stZPlmTxQNU4AR+uypljLNiWjq sN1rs8pa13vtEILCLERr6FzWJEW62KbYNOJLt5ZoCYx5L4NvUGp39pUsxysjH6zELu uKUQeumAAnaucPDYHys9+SsFJT6CqW1LsxEfXdoD0x9R4UJmTiA9xeOBgqw5c35Qng H/gs3eliyRo6nU/KOPOWZX9bO2draXniQ49Wncuq/M29bBSH0d+d8R9OTTiyuWQzdv mUMpdAy8lrC7w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3F81A18003E for ; Sat, 27 Jul 2024 19:52:22 +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, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 ; Sat, 27 Jul 2024 19:52:21 +0000 (UTC) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-428141be2ddso5577905e9.2 for ; Sat, 27 Jul 2024 12:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722109844; x=1722714644; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=1eepeCV4Ty9k8SP7bLr8rlTofrRp9BbSgU/mLU1Q3cE=; b=hzwH6OBc4jFVDqzyrGCviZFm/fdueQ9UNInEf5Q1k333bqdfJdrc3GmlTo/IKVn9Iq 9/ArYnwET/zZZ0V9Cfhm+a4SrLOLdywCQIaMkQyewaLgrUW6O1RYM+I3c6KgPQvz65UE uFUuIv9ufyzm4W8RqM5j7z3nOmFW7zkJ4gmt5nrBVOCSHy9dXr8kd8muSToDwgeF4eoz VRoEcYLQ89WWSN0TOfkwB0/iuKfrPiz9kExGRmC/iWMAp6KVFzdPw6GFjp/eotA+r7Zz w4KspOSjix0h6mteuugKl0rkgBmaDKXdjnZWJRwPM2ClORlxxpd8TFzfEkcZl0hRlSYS 2UYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722109844; x=1722714644; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1eepeCV4Ty9k8SP7bLr8rlTofrRp9BbSgU/mLU1Q3cE=; b=k52oMx9BPhNPo68wH8JCw6fQCmb2HstnFnRij862LdzpafwyTUa8qLpy5beYjR43SS vwKvvSrpE/zH4XDBgLN8DSk0+bESQQmLwixEptNcsr21XuUpU/tewXKIVoVfFcZJQjHp BnIgLYHm8YQ6Pw0Et9tAZsc0mqHbyYkeptDgpGUStsoJM7vhtTqfHx9ibJ+J/mcnyb5x UxzW5AA02tU6KUKO+7zQRFz6F5Qip/XnjTnNzkPVky0v8P+yNZHcci8fsUoBxBJRl0kF qr9AqzgCA68q3YipCb6cULwHdU+Mf/BON9sDJSTYSeYAMSqCEZzN57+/q1iKd0TR1M9+ 50pw== X-Gm-Message-State: AOJu0Yxfw9LRj2tTuJYHe39+zWexwAX7f3K1Do/KxoXA8kR6YzLYIWE7 ttD1Ne1sIMKT+oYTu5kFreSoPPE40hXBJToF+eewJA0itBAtSSmal0MUxg== X-Google-Smtp-Source: AGHT+IHpSySSd+FYKk8ynJ4K6JLm1oNwO3wqTogacx1OrYIeiortVWBjqFfLuxQe89gpXw6pAleP2A== X-Received: by 2002:a05:600c:46c6:b0:426:63b4:73b0 with SMTP id 5b1f17b1804b1-42811df6c02mr21281615e9.34.1722109844115; Sat, 27 Jul 2024 12:50:44 -0700 (PDT) Received: from smtpclient.apple ([178.197.194.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42805730d92sm124454505e9.3.2024.07.27.12.50.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jul 2024 12:50:43 -0700 (PDT) Message-ID: <1718C77D-BF28-424E-B972-5E86B79CAC37@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_A1F85A9C-743B-454F-A4A6-C55991A7D651" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] [RFC] Improve language coherence for the behaviour of offsets and containers Date: Sat, 27 Jul 2024 21:50:31 +0200 In-Reply-To: Cc: PHP internals To: "Gina P. Banyard" References: X-Mailer: Apple Mail (2.3774.600.62) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_A1F85A9C-743B-454F-A4A6-C55991A7D651 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 4 juil. 2024 =C3=A0 15:52, Gina P. Banyard a = =C3=A9crit : >=20 > Hello internals, >=20 > I would like to formally open the discussion on an RFC I've been = working on for the past year: > https://wiki.php.net/rfc/container-offset-behaviour >=20 > As DokuWiki is a bit of a faff at times, the Markdown sources are = available on GitHub: > = https://github.com/Girgias/php-rfcs/blob/master/container-offset-behaviour= .md >=20 > The implementation is basically done, other than some mysterious JIT = issues that I haven't been able to pinpoint yet. >=20 >=20 > Best regards, >=20 > Gina P. Banyard Hi, Thanks for the RFC. Some small remarks: 1. In =C2=A7 Add granular interfaces: `DimensionUnsetable` : I would = have written =E2=80=9Cunsettable=E2=80=9D with 2 t=E2=80=99s (like = =E2=80=9Csettable=E2=80=9D, =E2=80=9Cunforgettable=E2=80=9D, = =E2=80=9Cregrettable=E2=80=9D, and like =E2=80=9Cunsetting=E2=80=9D). 2. You propose to emit warnings in 8.4 for `$array[null]`, = `$array[true]` and `$array[false]`. I argue that it should be = deprecation notices instead. The reason is that currently no notice is = emitted, and that there may be valid code that (implicitly or not) rely = on the current behaviour. For example: ```php function foo(?int $x): string { static $cache =3D [ ]; return $cache[$x] ??=3D heavyCalculationForFoo($x); } ``` and: ```php $total_by_type =3D [ ]; foreach ($list as $row) { assert($row['type'] =3D=3D=3D null || is_string($row['type']) && = $row['type'] !=3D=3D ''); $total_by_type[$row['type']] ??=3D 0; $total_by_type[$row['type']] +=3D $row['amount']; } ``` The case of `$array[null]` is similar to `strlen(null)`, deprecated in: = https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg 3. Given the new semantics, `array_key_exists()` should be amended in = order to support objects implementing `DimensionReadable`. =E2=80=94Claude --Apple-Mail=_A1F85A9C-743B-454F-A4A6-C55991A7D651 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 4 juil. 2024 =C3=A0 15:52, Gina P. Banyard = <internals@gpb.moe> a =C3=A9crit :

Hello internals,

I = would like to formally open the discussion on an RFC I've been working = on for the past = year:
https://wiki.php.net/rfc/container-offset-behaviour

As = DokuWiki is a bit of a faff at times, the Markdown sources are available = on = GitHub:
https://github.com/Girgias/php-rfcs/blob/master/container-offse= t-behaviour.md

The implementation is basically done, other than = some mysterious JIT issues that I haven't been able to pinpoint = yet.


Best regards,

Gina P. = Banyard

Hi,

Thanks for the RFC. Some small = remarks:


1. In =C2=A7 Add = granular interfaces: `DimensionUnsetable` : I would have written = =E2=80=9Cunsettable=E2=80=9D with 2 t=E2=80=99s (like =E2=80=9Csettable=E2= =80=9D, =E2=80=9Cunforgettable=E2=80=9D, =E2=80=9Cregrettable=E2=80=9D, = and like =E2=80=9Cunsetting=E2=80=9D).


=
2. You propose to emit warnings in 8.4 for `$array[null]`, = `$array[true]` and `$array[false]`. I argue that it should be = deprecation notices instead. The reason is that currently no notice is = emitted, and that there may be valid code that (implicitly or not) rely = on the current behaviour. For = example:

```php
function foo(?int = $x): string {
    static $cache =3D [ = ];
    return $cache[$x] ??=3D = heavyCalculationForFoo($x);
}
```

=
and:

```php
$total_by_type =3D [ = ];
foreach ($list as $row) {
    = assert($row['type'] =3D=3D=3D null || is_string($row['type']) && = $row['type'] !=3D=3D '');
    = $total_by_type[$row['type']] ??=3D 0;
    = $total_by_type[$row['type']] +=3D = $row['amount'];
}
```

The = case of `$array[null]` is similar to `strlen(null)`, deprecated = in: ht= tps://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg


3. Given the new semantics, = `array_key_exists()` should be amended in order to support objects = implementing = `DimensionReadable`.


=E2=80=94Clau= de




= --Apple-Mail=_A1F85A9C-743B-454F-A4A6-C55991A7D651--