Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110853 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84872 invoked from network); 6 Jul 2020 20:59:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Jul 2020 20:59:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8BBA4180543 for ; Mon, 6 Jul 2020 12:50:24 -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 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-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 ; Mon, 6 Jul 2020 12:50:24 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id k17so10552222lfg.3 for ; Mon, 06 Jul 2020 12:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Ez9t6wt6aE3KpILTi+0jeZeHokWczsVQwkvozlXb/40=; b=bWFXgTai9ESqqjWhuT4tsFdesTbwuRma07/SqNa8MhXGls0V0QzuGkf5Ulcu2blXGj VVsTcQey3wk2WtNkSDHxcHFGfrPLMQRXfVBvf0mc2/8G4FuvZefwbDwsqAu12ajqJ73I E1ISJmcbPlX3yshhQkctHEuQYkyefo4F63eug3Wsiuw934lvzxEC/FBNW7gQIzVIO0Sp 3fGX51T5cBBDKA1vdnsFX7aFKGCFFbG7zl7/0T3BL4qs/5IKPZoHcvQvcODteeQxFoLf cwzSMpI+hvxE9+VP8yMcIKJWU5Iqcb3sMUEsi92CVye/EuHqvaB1NI1wtaCX7oiuloIm /fWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Ez9t6wt6aE3KpILTi+0jeZeHokWczsVQwkvozlXb/40=; b=oV3kBRgyvAuQFL17Coz46QsXYtnSVUob2zvfVVpuq80AUp+ewf8rPeqVRLt26kKiEp ZSk6DP2f0wbXD4gf3ew4DZ0Yl9YhM17UxnoxzAD21Y1Vc5bfZtSbZuud6MkO+MPz2d0k 8d9uEvcKbEX+geExfz7b9nzVBM+SASO0EIA3ykTj3BxeFRahHkxxLJHgav+8jh2lFsYz OxxZ6ijDT57n9ZivfDgzhDqk3WPqb3KAReTsukxW55p9Fq+yHvS0mrttxarlJgchhWPc doWt0BECZaNh3yEB44/0oiF6RWm2aoF9UATxI1BJeAb1WJgAHAPvUBflo56F7DsNBa/Z 9b5w== X-Gm-Message-State: AOAM5334JZLXOyAT/hly6xReJ9qnUGXq3j1+IJ0SWGVHqbO0TZnqZH7f 3hIkAXlyTtqBRGvwUWzHMqDj2MM5awkJ6W0IyGf1eJ9UKGY= X-Google-Smtp-Source: ABdhPJyFy+mfsn44b5PbnLSBFnuhfsDmDFiA7vEG+FBeNIls/32H1Yb9odb4EVnzp376DZmn4fLEUNlwV2Lgp1VqfNI= X-Received: by 2002:a05:6512:31d5:: with SMTP id j21mr20119032lfe.83.1594065020444; Mon, 06 Jul 2020 12:50:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 6 Jul 2020 21:50:09 +0200 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="0000000000004ae43c05a9cb2fec" Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Strict operators directive From: arnold.adaniels.nl@gmail.com (Arnold Daniels) --0000000000004ae43c05a9cb2fec Content-Type: text/plain; charset="UTF-8" On Mon, Jul 6, 2020 at 6:33 PM Benjamin Eberlei wrote: > > > On Mon, Jul 6, 2020 at 5:27 PM Arnold Daniels < > arnold.adaniels.nl@gmail.com> wrote: > >> Hi all, >> >> I'd like to start the discussion of the "Strict operators directive" RFC >> version 1.5. This RFC proposes a new directive strict_operators, which >> limits the type juggling done by operators to avoid unexpected results. >> >> https://wiki.php.net/rfc/strict_operators >> >> There are some significant changes from the previous version. >> strict_operators no longer has cases where it changes the outcome of an >> operation. To achieve this the following changes are made to the RFC >> >> * All comparison operators, besides `===` and `!==`, only accept `int` >> and `float` operands. For any other type a `TypeError` is thrown. This >> includes `==` and `!=`. >> > > what about DateTime and other objects overwriting comparison operators? > (GMP, ...) How would this proposal affect future proposals that expose > comparisons to userland (see for example the operator overloading RFC). > Custom compare handlers of objects (like DateTime and GMP) will be applied regardless of strict_operators. The ZEND_COMPARE_OBJECTS_FALLBACK macro will throw a TypeError if two objects are compared with different handlers. Converting an int to GMP is a widening primitive conversion and therefore allowed. I will modify the GMP compare handler as part of this RFC to throw a TypeError if the other operand isn't an 'int' or GMP object. Future proposals for userland custom comparisons should preferably adhere to the stricter rules for type conversion this RFC suggests, regardless of the strict_operators directive. In that case, it shouldn't be an issue to allow such objects as operands of overloaded operators. > > * The `switch` statement is not affected. >> > >> For frequently asked questions please see >> https://wiki.php.net/rfc/strict_operators/faq. >> > > Honestly PHP comparisons are already complex enough, introducing a second > set of rules that are just as complex seems like a risky proposal to me. > PHP comparisons are currently very complex. This RFC attempts to reduce/eliminate that complexity. Can you explain why the rules are still too complex and perhaps how they can be simplified more? >> [Arnold Daniels - Chat @ Spike]( >> https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=l1bam) >> [l1bam] > > --0000000000004ae43c05a9cb2fec--