Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126379 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 A322E1ADB24 for ; Wed, 12 Feb 2025 14:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739369127; bh=uzocACD5AS407iL5VCdJIrzZdKcdBHj64k8sc3LLp2Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=b+K933jkcWf9ry4RGSKAHuqWMEU+qNsEn8gSiZASZNuEUio77EMVQR9DwWi63V3QL DdTjLHJZK3VvW/nUtAh0arxIZMqegX7+MU46NvGXk/2FIFRoIyTefUeL1AzkDA/+cQ LChIsbzUdADiOSehVzgKdYlQkGeqIcPdSp1sIPkbg7rK4W2W8qq+xX9S9zOeM1zTj1 iefoIFvvH0ZrfGnj38XR77QmkFcOAi26D3uy64KokWq57sQ/WRQe28P3aJQZXtn2Sf x9uRQ2Eyzjxo2xpSFhT8q4HunAsbsSgBppuZVNsu9Eze/6TKV9gBEdfZtlIyFJUj00 MuUhUMc4xSi1g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 817CF1801D8 for ; Wed, 12 Feb 2025 14:05:24 +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=-0.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,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-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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, 12 Feb 2025 14:05:21 +0000 (UTC) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-30761be8fa7so61939491fa.2 for ; Wed, 12 Feb 2025 06:08:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739369283; x=1739974083; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=uzocACD5AS407iL5VCdJIrzZdKcdBHj64k8sc3LLp2Y=; b=Ggeh/Mq0PY+Bo9zS4WuFjhhAwR3AiRlWapH9z53tGkKT/dZkR21B4pIInEfaSRS++7 qRYT+uUyBpPuB5ztoFofVmaVq0P/o1qI8eXclKbgfY8BbiSyIgYMjCSWqPQ9GEz257DJ ozc2d1733vWTaipfXyDiyItt2KjFg6XARRkx/6VJxKb94BDb/rzEjdTuk2k+aplxh82Q tVtP6+fS3LFn2dVhpRxGOn8OCMZdr9o1t/VM+My7cXfZdURlPF4iyJ2VDyCECnpsq+aG NSS/j3oekD35L31g1K4GxLQNussjQyK5V2wLWVRMEIYuafMBuOclwI9rUCf8Bd96cAr6 sWNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739369283; x=1739974083; 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=uzocACD5AS407iL5VCdJIrzZdKcdBHj64k8sc3LLp2Y=; b=km4l2HjmL8VIjkKSB0LxtojhlRoJwXc/OnKOZww4yKhGKhdDVnjveCO4GdwEQIA54V S2ZCD3i6RLgsQDMlFuwPNSUiE5w8xTuuEtxKQv2P9B1d42J9STcoahNNPSiKoEIvyQJM p9AUTWZJGpFSHLn0vyDlHZ3YMna6XgfC5qGuXIr3ISyF3o+qGjc3xbrvLR8JVpsXHqaX CMNZhr27excFtOnGeeBH4Sg1GyVStKqUmZuyqkTn+AWHI/sGXT6H5QaYqkJHiX4PBG/n f5joNok4cuTdYltgRmHDbmZgnwgg5mRQyOAKIgHBy+p1VUNqbENZcOU9Y91Zqf3k+BG9 x93g== X-Forwarded-Encrypted: i=1; AJvYcCXR9I8JQ4hwsmsuX+QWg9cq5LYVgj0QjvFlxRhdUEuvgchIDCouavy41nxuh9qKpAHvMCmvp3yB9Ig=@lists.php.net X-Gm-Message-State: AOJu0YywaVa6mNzeK6TL+j3MTPX0zoyfkc0OuFeaaZn9RMzcWj1ebpN4 yPUN6EdpF1bXl61P/lSvJWy6rxDbSOmArNV7S96SwX4IR8gwfV3mr6vbQcOkjcyJWLyBCrpIROf aUvU7MHmbrQm9wCEGiQAYngqpJMk= X-Gm-Gg: ASbGncvWj8N6dpyqGPad8QVeuLeMjuzR6/hkQ0wB+e74Dm8Y1nksAY+RLcX+7MXJFox WKVxGMDjdD7b1BOVb2hHpeZbJ4yPn1y6otshA/CSbiEWRFMngHDC8wzIMDhOXZqMqMPSk8QLW X-Google-Smtp-Source: AGHT+IEuCzTuZetjHpFKu0rpir3KwNV+gFYlCNtb51pjZdbDMam8o4ehLEbelcBHTNMPr1KsuvQhEShUNfXMBkXoxlQ= X-Received: by 2002:a2e:b8c3:0:b0:308:f01f:1835 with SMTP id 38308e7fff4ca-3090366912emr12474681fa.17.1739369282555; Wed, 12 Feb 2025 06:08:02 -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, 12 Feb 2025 14:07:51 +0000 X-Gm-Features: AWEUYZlegrUZ6ZQJgFtLADxDKdEoOUxOdujX1Jk3vr3WyHvYmrMscuPHfGF9s1Y Message-ID: Subject: Re: [PHP-DEV] RFC: Marking return values as important (#[\NoDiscard]) To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: Volker Dusch , php internals Content-Type: text/plain; charset="UTF-8" From: tekiela246@gmail.com (Kamil Tekiela) Hi Tim and Volker, I'd be honest, I have a very negative attitude towards this proposal and I'd be voting against it. It seems to me like it's creating a problem and then trying to find a solution for it. A return value is always supposed to be used. If some API is returning a value that can be safely ignored, it's a badly designed API. If a developer forgets to use a return value, a static analysis tool should inform the developer of the mistake. I understand that not all functions are pure like in your example, but adding an attribute doesn't feel like the solution. In fact, it's creating a problem for users who want to ignore the value, which you then propose to solve with (void) cast. My second gripe is the use of E_WARNING and E_USER_WARNING. I am of the opinion that warnings in PHP are a really bad idea. PHP isn't a language like C or C++ where the warnings would show up only during the compilation phase. In PHP warnings are runtime errors. The code should emit an exception instead of a warning. It would also make it much easier to handle and you wouldn't need any special construct to allow users to ignore the new attribute. And I am really not a fan of the PHP engine generating E_USER_WARNING which should be reserved only for warnings triggered by trigger_error. The examples you used don't support the need for the new attribute. Regarding the DateTimeImmutable methods, you said yourself: "The methods are badly named, because they do not actually set the updated value". So your proposal suggests adding a brand new thing to PHP to deal with bad method names? This problem should be solved using static analysers, IDE, and proper code refactoring. Regards, Kamil