Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116635 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87617 invoked from network); 13 Dec 2021 09:51:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Dec 2021 09:51:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9ECE21804AA for ; Mon, 13 Dec 2021 02:52:57 -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=0.6 required=5.0 tests=BAYES_50,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-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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, 13 Dec 2021 02:52:57 -0800 (PST) Received: by mail-io1-f45.google.com with SMTP id y16so17965750ioc.8 for ; Mon, 13 Dec 2021 02:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=+ZkFg6USvxaq2Zner/oXWbuKH/SIpNIZEcS5jm9o4H8=; b=oZR2v+vB6NummpkQN64lbSQ2YgWfb+XuZvRmXH0wTbTyIl7pS3HDLSE/A9oxocbNaX LuJswgZAHHjraaMf3BVaJDObYjety6qG8by2R4D+E8NSsv8hCMh8CfqS3bv7N7py2NMQ pEMJnu6nqWRtMwVRbdXJETgVrpN++JOlewwnK3Fe8SZxVO0XsRlOE6ToWxxA5hPepTf1 pUqTBzHVNyQguDNVXXjb3fogKbi4jhuxl7aff446JQ7STcXzGRoeTWFn8WIV6Lofurk3 jzKwCC6/8nQaMO+Ld3jDwgl7RZ9Dyn+5lx9IszhF+e7ByToB3zK6vl9wLMAqWmrFx8Es Yf9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+ZkFg6USvxaq2Zner/oXWbuKH/SIpNIZEcS5jm9o4H8=; b=Jh7rqZW3hU27quNhLzqQw1pKXndoipNRTlE7/w5gkuCpShH0XTodawDgKhZYs3jz4J DJr33m8TzRRSrN/9hcst8VNkKom8AaUXiW93nBe01JXil8TVrzBwOl06gY/LDr5BTyeV qfucHMUwDPEDsXWsMIX2a2denBgtk0iVgMhbOb8EUgDlxD3Uvs7TZpQZ0s8pKXQnm3Gq LIeEqTx4WsJ0iZljkjCRGXQGpPf+lPdPg53QfTjgtUuPi3yFsYMaPCa2Z94pxgrHiiDg kw2f2DmN8aDtPcgfXdYk155mn9YSoBrzO8CwluRugrHiRSpqJO/YPmU0Xl8d6ZO0Jv2T KgBQ== X-Gm-Message-State: AOAM530fqzhP5oGk/jjbQ6QGDinDy5tjkCujtgTdmPXMPviXNLz1+MuM ZmFha2x0U5YZsnn0iUEcRle6mcnhIiYGoZMsGDuOhiFzb2o= X-Google-Smtp-Source: ABdhPJx6YWcHkZ0R6aRxlg/oL1rErBztbcNfFQMFoo0ksZVJXoAeool/CT9uFsoh3G/0hTvhgEmwQCHUukD365hU0Nk= X-Received: by 2002:a05:6638:140c:: with SMTP id k12mr32213201jad.89.1639392776778; Mon, 13 Dec 2021 02:52:56 -0800 (PST) MIME-Version: 1.0 Date: Mon, 13 Dec 2021 11:52:42 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000001b7a3005d304e01b" Subject: [RFC] !instanceof operator - reaction measuremen From: olivernybroe@gmail.com (Oliver Nybroe) --0000000000001b7a3005d304e01b Content-Type: text/plain; charset="UTF-8" I would like to create my first RFC proposing adding a new operator `!instanceof` named `T_NOT_INSTANCEOF`. The purpose of this RFC is to add syntactic sugar for checking if an object is not an instance of something else. The current syntax for checking not instance of looks the following way ```php !$object instanceof MyClass ``` When I read this I read it as: Negate the `$object` variable and check if that is an instance of `MyClass`. My proposed operator would allow for the following syntax ```php $object !instanceof MyClass ``` This is for me and people I have spoken to a much clearer syntax. Some arguments on other ways the not instance of can currently be written ```php !($object instanceof MyClass) // Wrapping in parenthesis ! $object instanceof MyClass // Simply adding spacing ``` My main problem with these alternative syntaxes is the readability when added inside an `if` condition ```php if(!($object instanceof MyClass)) { ... if(! $object instanceof MyClass) { ... ``` compared to ```php if($object !instanceof MyClass) { ... ``` In regards to implementing the feature, I wouldn't mind trying to do that myself. I believe this change is relatively simple in the parser and AST and something I should be able to figure out. What do people think about this? Would love to clarify if needed. Best regards Oliver Nybroe (he/him) --0000000000001b7a3005d304e01b--