Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118958 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10973 invoked from network); 4 Nov 2022 05:37:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Nov 2022 05:37:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4C0521804F7 for ; Thu, 3 Nov 2022 22:37:53 -0700 (PDT) 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,HTML_MESSAGE, 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-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (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 ; Thu, 3 Nov 2022 22:37:52 -0700 (PDT) Received: by mail-il1-f173.google.com with SMTP id d3so106971ils.1 for ; Thu, 03 Nov 2022 22:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=F+a3LNfxXd+pdYwBIBbbhhi9zq2q3IUZgdELG7P4kjY=; b=Z4fBfYYStBdv8b+HUcKSM2cdUdFuNGD3uuLbQXiECT9kZR/6obYPLT+yFN17eRVITP ZcMzZtwliWiMeuM/8UiMR6ImhLY4IzdZaCk77XAHeRfwICTGr6/jWOvqWuwOOS7uOyuC mHMxZ+vwILvYTUenOO4njBUgGCbiu0wwaAhip04IsXqrWcRG1YpWqo7LozJZ6/AEdlUX pYL4stHUvlsDCAdWn4KrefTvX2zGU3AOyTPQpAtl/zS5tW68/jebul69doGWvm+3ilEV P6W6FCY7mbtbdKz9P0dQ4jxWwqyJTG8qUANtWog09r2DjwiMIJ/2VjhIVYMGEy/JE0Ef FDcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=F+a3LNfxXd+pdYwBIBbbhhi9zq2q3IUZgdELG7P4kjY=; b=koyqN2vkpwsC9QMh2lPDPa0+6uhHvmlSeRLTk7BGoZz89E5LoeqCjbgYqPqb5yVPDM g8KeBXQM6GLyuGVeGQKr1sk9fDJaqwVKkS9eKjiWeTLIdmlDBxbBRUPuzEbltTgNXZ78 kbT8C7FUYisHlawUtf60s2dyq836ErucrUP4fBsV58NcaixuWdqw/17R2VcbyCcxJhvZ Qy2tAgXH/lHVPwfPmz5WZ4hTWRwc3AnJlyGrwQBD4JR0+luU+YFofCESbwJ3jGdMf3Kd E5zVyoGowMGWQsNDYRe/4SRzs8tvcKDtPtr2cr8LDLGaP6G917Zq5ydwUk3qxfk+J/E7 VTGA== X-Gm-Message-State: ACrzQf2kLbZter2SkP+SOpm6NhtipauUZ7qYPemIpoQyzBFlTtW/4p4n pCsLmSdea333Evfw9EsTyxXVWU8rcJEX7+EJ4oo= X-Google-Smtp-Source: AMsMyM7XddBNNkUgU24XaN7LnJgv/oUtSbMcgcIwMjorl6Jdts28dMvgEylEXZYsMyrf5I4MObVO5kguj5jAYRRQZl8= X-Received: by 2002:a05:6e02:19ce:b0:2fc:3a29:f89f with SMTP id r14-20020a056e0219ce00b002fc3a29f89fmr19890256ill.219.1667540271975; Thu, 03 Nov 2022 22:37:51 -0700 (PDT) MIME-Version: 1.0 References: <21C5073D-3F39-49DA-8686-E027AE780793@joshbruce.dev> <1bc7759a-63b8-4b96-bb69-97b50f851307@www.fastmail.com> <94DC0839-E43B-4F3A-9105-8F3CB9D7BBC1@joshbruce.dev> <9AE33306-ED89-4FE4-86A5-89B4EDC81545@gmail.com> <13A9249B-C3B2-46E3-AB50-D46FAA2A301E@joshbruce.dev> In-Reply-To: Date: Fri, 4 Nov 2022 06:37:40 +0100 Message-ID: To: Josh Bruce Cc: Claude Pache , Marco Pivetta , php internals Content-Type: multipart/alternative; boundary="0000000000008f52d305ec9e7946" Subject: Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --0000000000008f52d305ec9e7946 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > if ($response->getStatusCode() > 199 and $response->getStatusCode() < 300= ) > { > // do something with =E2=80=9Ctrue=E2=80=9D - which has a range of 100 = possibilities at > a granular level, which we could respond to differently - possible to > interact with $response > > } > // do something with =E2=80=9Cfalse=E2=80=9D - which has a range of more = than 100 > possibilities at a granular level, which we could respond to differently = - > possible to interact with $response > > We might wrap response to create an isOk() method to move the conditional > logic somewhere within the object itself and make the call site more > readable. > > If ($response->isOk()) { > // do something with =E2=80=9Ctrue=E2=80=9D - still able to interact wi= th $response > > } > // do something with =E2=80=9Cfalse=E2=80=9D - still able to interact wit= h $response > This looks way much cleaner and is easy to read and understand. While I understand the proposed feature is opt-int it introduces more magic that can be solved using more verbose and IMO cleaner solutions. > With the RFC: > > if (new MyType($config)) { > // do something with =E2=80=9Ctrue=E2=80=9D - can=E2=80=99t use MyType = because not assigned > > } > // reachable because possible to resolve to false - if implements > Falsifiable and __toBool can resolve to false - can=E2=80=99t use MyType = because > not assigned > > if ($response =3D new MyType($config)) { > // do something with =E2=80=9Ctrue=E2=80=9D - with the option of using = $response > > } > // reachable - can=E2=80=99t use MyType because may not be assigned > > $response =3D new MyType($config); > If ($response) { > // do something with =E2=80=9Ctrue=E2=80=9D - with the option of using = $response > > } > // do something with =E2=80=9Cfalse=E2=80=9D - with the option of using $= response > This is somehow confusing, why is the $response storing object ref is ok while inclining the new object creation is not? This requires more attention while reading and debugging. Cheers, Micha=C5=82 Marcin Brzuchalski --0000000000008f52d305ec9e7946--