Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119496 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63188 invoked from network); 8 Feb 2023 18:49:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Feb 2023 18:49:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5A85B18033A for ; Wed, 8 Feb 2023 10:49:51 -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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 8 Feb 2023 10:49:50 -0800 (PST) Received: by mail-yb1-f174.google.com with SMTP id x8so14853631ybt.13 for ; Wed, 08 Feb 2023 10:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=kkzLlq1GGewsd2/EKUhFCofsBixa0WNIuz3rbbVyGso=; b=JBqw2g1XaFluNU1jlvcFpW8uZzJs1gSZCaVnmpCDr86uzAcMhlgXqmnfvO0p24J2hY U90M+HWvbFzWevkv5oa1qI2zBv0cwwnjCrGxbkFBgBuOG6lQowziESowZzoc22uBCsTw /FJ/AyFAeQO8c7jvibatV+TfU6zr1OocfYJdVfjGu7gyrXEEhXgrEDlDhYMZnj1JShCY R5+3dq8nymg2SK71/IYe8H6LW64z7wNmp5kYXpRoXNlsxQZUpP16TacA7LcK58lgtY2B 3I9qFTx+GyZFePCiIX5UOsqaL1xsUDaymiPKmdhKFycONPSFOIw0jzcsJE1p4482hJEe fsBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=kkzLlq1GGewsd2/EKUhFCofsBixa0WNIuz3rbbVyGso=; b=bIrMtNjoUxF9nBzjC+06uEPp33GQ6P1FV5qS+wiP+6z7/4GlWfUU4taB4+D/3eYjW8 faC7VWjZxhTK8IAPubZ4V9GZ+hu2RWOaIuk3t4pKgtE+6Jye7jmOyF77evzGxvEZSVtN zYv87Q26EJmQUAr+Gtj/vAqKWBw+o0simWLGMJQPiRmKiIVGNRQ9vJBHpF3qn+mKnwvi OTgHeZGgJeP/rCF51N2BvueKhHKyQvXrVZiypU6NWQVuDbVssFzdqBIwQgf/hNZ4S+6j Z8n4Hv3q/Cg65ymZrp4iJ8DzCRUjqP3ur4F0/ISItvroaWqGSl6ysDIrXG2QwUELinB+ KXRw== X-Gm-Message-State: AO0yUKVZ9q3ez4b9uYJEQiwJvaOHzVE2WY2VZyu3Vr//h7Y3+DuXMJNa 104n8Vwy7uQhsSLFZ9RDkeMgBM4EWTIfcYCS67c= X-Google-Smtp-Source: AK7set8e5rJH7b+m0ltp6yFFCirrid/C8jklK6f+KkvmLXl5QjUQzPdAUnH6TgxatKD6b4L8umx3l1k0Wk39TloBp3M= X-Received: by 2002:a5b:3ca:0:b0:896:4210:736d with SMTP id t10-20020a5b03ca000000b008964210736dmr773670ybp.106.1675882190209; Wed, 08 Feb 2023 10:49:50 -0800 (PST) MIME-Version: 1.0 References: <18627e9c82d.1185ba82a2669697.6762525826203739336@wendelladriel.com> <8c3fb742-4367-0e4a-b96e-142657ac902c@gmail.com> <5edaa45e-08ff-9529-3a1b-42f655a68497@gmail.com> In-Reply-To: Date: Wed, 8 Feb 2023 19:49:38 +0100 Message-ID: To: Wendell Adriel Cc: PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC Proposal - Types for Inline Variables From: landers.robert@gmail.com (Robert Landers) On Wed, Feb 8, 2023 at 6:23 PM Wendell Adriel wrote: > > Hello everyone. > I created the Draft for this RFC: > https://wiki.php.net/rfc/local_variable_types > I'd love to hear your thoughts on this before proceeding further. > If anything should be changed or updated just let me know. > I'll be happy to help with anything related to this. > > *---* > *Best Regards,* > *Wendell Adriel.* > *Software Engineer **| Investor | Amateur Photographer | Musician | INFP* > *https://wendelladriel.com * > > > Em qua., 8 de fev. de 2023 =C3=A0s 15:54, Alexandru P=C4=83tr=C4=83nescu = < > drealecs@gmail.com> escreveu: > > > On Tue, Feb 7, 2023 at 10:21 PM Mark Baker wrote: > > > > > On 07/02/2023 20:53, Olle H=C3=A4rstedt wrote: > > > > No not really. I'd expect it behave similar to function argument > > > > type-hinting in PHP, that is, runtime checks, but where the notatio= n > > > > can be used by external tools. > > > > > > The big difference is that the current checking for function argument= s > > > is only necessary when a function is called; but that checking for > > > local-scoped variables would be required on every assignment to a > > > variable, or operation that can change a variable value; and that > > > becomes more problematic with the potential need for union types. > > > > > > > > Hi Mark, > > > > I saw that you and Olle were discussing that type checking should be > > similar with functions typed parameters . > > But in reality, it should be implemented more like typed properties. > > > > Actually that's already possible with something like > > https://3v4l.org/T6GFS > > function &declare_int(int $value) { > > static $references =3D []; > > > > $valueWrapper =3D new class(5) { > > public function __construct(public int $value) { > > } > > }; > > $references[] =3D $valueWrapper; > > > > return $valueWrapper->value; > > } > > > > $intVariable =3D &declare_int(0); > > > > $intVariable =3D 42; // works > > $intVariable =3D 'test'; // fails > > > > > > Even the PHP_INT_MAX works (it fails). > > > > To give credit, I saw it discussed few years ago on twitter and here yo= u > > can see a nice playground implementation: https://github.com/azjezz/typ= ed/ > > I don't see a bug technical performance downside, other than the wrappe= r > > class references that you need to have a management for. > > I think an implementation in C would be not less performant than how > > properties types are checked. > > > > Regards, > > Alex > > For `array` why not just use `list`? Robert Landers Software Engineer Utrecht NL