Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126294 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 AFEF11A00BC for ; Wed, 5 Feb 2025 12:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738757090; bh=dUnxPN/Vf8RtKIBTz0Le0J4lCPFrlg1CXUYw3t2E1rY=; h=References:In-Reply-To:From:Date:Subject:To:From; b=JoneutWsN2H7zZ94+LC5AWo0q0fp8mK4oULkyDi5lTT4FoIDuX2+AsXz6lhQK8hK5 ddGzZH3+hu9GBNy3KkyuRKfMBrimVU3DcdOWW4AoMcsqGXdQwOYt+oDZPoZzs72kT/ QNi1yidZ/7KQTAnq6zqOZ6H/97bcgBceO+OjH6eMC8metngo5oZjBXAauWQfI1ocKj QRpUZjXYL36A0o0KMMy+qnCsUuLT04NJbaUo7ydAYmyzTfwc46ik84Hj0aHoMKCNj0 99uiS1knQXBnrqIQuKGII2bTPC6HDKsHphdHuQsYroanz8RvyUGkaPMQwWyQR3c3nR 3gG80JgBiv4Og== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3AA97180083 for ; Wed, 5 Feb 2025 12:04:50 +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=-1.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, 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-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (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 ; Wed, 5 Feb 2025 12:04:49 +0000 (UTC) Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-6e436ada20eso1147906d6.2 for ; Wed, 05 Feb 2025 04:07:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738757254; x=1739362054; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dUnxPN/Vf8RtKIBTz0Le0J4lCPFrlg1CXUYw3t2E1rY=; b=gX6NngFe3M1+Tt5VMlTvHfimNv+AYaJjGXetjIhKW1AUAoYkepIQIL/LBByWaQzzyd Riwrph0NuskDDjCRlKPO+LUEsQM25H1ZEbqYtuBvtFxWphj5wMYWVCLWaRFrAkxFEYgb 7L8Lz1ofIVgQNaKYq3B9MbYAIerXK03pNZPDQSBEpWZtXDvzj3W6n69ljIXwN/yROn/Y KZsocpeVLIHUhkxCjeMWaTlkl3AwIxe30tDBMH0UVaxesSxO1tYR24iaZ0V4WedmV08U YHasgytTANol/jGbYQR8Cf+wGMkP0lzDIzlSjxnieInJK9csoJqNjaQVo1gDzEkwTesn egeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738757254; x=1739362054; h=content-transfer-encoding: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=dUnxPN/Vf8RtKIBTz0Le0J4lCPFrlg1CXUYw3t2E1rY=; b=uLEETWuRmhW5/b/J8ytiHNIzXOCr8iM34eLYEprLluGqoAG7Au2/ixdfJDoVu6DhvS 9HhAc0qsh4xSKp3OnSgHkI5mkTUFVlCbATAt03ZHBDsnfl6IpLwrE2k/4C9aL7x29pcM h4JtQ/nXHTGOEMZa9O6NFvoh4uGiwk/+qEm+I4FF5e7Z+QjvOmLll2QJCNN97P21mtUk H3t7VdIAGmxiWCD2OGpzT36lRlrQUQi8AqbHqSalCzGhP0N44UpFIAy23HTEbWzNLKUZ jl4DoVM0lsseb3apE0VJL7oTRxRDtHyPYdBRdBCeqXWWz1+PqCBvhdwB81I97xMDyW6N fgrg== X-Gm-Message-State: AOJu0YwIXWcuasUswok6kG97SeBX3VBuxmHYCqcmGi0NVFu3mhBD/LIU S8ZUL/pGv/euWuU9F6kBcyDFIr42IqFNnp/3t7+RDzBbn2q40bb3Z/iWqGXBOr2FJgxHIMhxhUe Mot2KbPzmET5EpELUgClm5KTLg6gOTVvS6YH+fg== X-Gm-Gg: ASbGncsF/eIdl1PV0905Ho7h3qj+fSabbCM92T1duSkPUaPmEHkxm8Cox+BKkwoMuy7 u6jXkiRQfrWDkGRboiasliXyrfanzHk43hZVL/bMtjZmQJ83B/jWXGxszJe/SJrvhvcrKKFsod6 QswnmM4QMBbOlalK1nOJneuJK3bTwEKg== X-Google-Smtp-Source: AGHT+IHx1uOF6YVhkcSBZPbnp/0oP+UA16935sZx6LskZ5otod+9KMiL0JR9ZAYAnoKRxYVogNIr1CsGSLQVShkH2eE= X-Received: by 2002:a05:6214:3187:b0:6d8:7db7:1f2e with SMTP id 6a1803df08f44-6e42fb84041mr34373436d6.14.1738757254610; Wed, 05 Feb 2025 04:07:34 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 5 Feb 2025 13:07:24 +0100 X-Gm-Features: AWEUYZne8vhJZD3Ipxb8wWK2ufh3g2UAI9GSh0-G0T-28l5PdTkxTzSIzIzCKEo Message-ID: Subject: Re: [PHP-DEV] RFC: Not Null Assertion Operator To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Mihail Thanks for your proposal. On Wed, Feb 5, 2025 at 9:24=E2=80=AFAM Mihail Liahimov <91liahim@gmail.com>= wrote: > > Good afternoon. I would like to create an RFC on the implementation of th= e NOT null assertion operator. Do you think it makes sense to create it? I = was able to implement the operator. I've already posted a draft in my githu= b - https://github.com/rekmixa/php-src/tree/feature/not_null_assertion_oper= ator > An example of the implementation of this operator can be viewed in kotlin= or in typescript. The point of it is that in places where we did not expec= t null, we should not make additional checks, but use this operator. It wil= l also be convenient for highlighting in the IDE. First off, it would be useful if you show some examples in your proposals. Especially for people who don't know Kotlin, it's not clear how such a feature would work. Looking at your patch, you're introducing the !-> operator, which presumably would error on (null)!->foo. A few thoughts: * This approach/patch seems unnecessarily limiting and complex. it would be easier to create a postfix operator ! that works on all expressions, and simply errors if null. This won't require much special handling in the engine. It would also allow you to do foo($bar!). TBH, this seems most useful for static analysis, but assert($bar) will do there too, so I'm not particularly convinced we need such a feature. * Especially in the case of property access on null, it would be worth considering whether we ever want to make this error by default, which seems like the general trajectory PHP has been taking. This is currently a warning (since PHP 8, and a notice since 5.0). If we rule that out, the feature might make more sense. Ilija