Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127749 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 lists.php.net (Postfix) with ESMTPS id 60B881A00BC for ; Wed, 25 Jun 2025 12:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1750853979; bh=qRn0f9IJf6nT73HHpw8z2mFtSJkMtEfkg8PYfehGXj8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hav0CipqXzSAbmgwJpN1teXgbW9OB+j+2yRiF2N2txRF82IDi5eVI0tKa6GdzfkCE kW98RKE3b9iKELX19V2DzBnBk/PW0xsUgrDLUezD9pSUDebK0+LgoNEcCLENYIaPyu D2qReuqNNOvMWD7iT8nvSnesMB1wGtQr8ZnVsn9USi42LCahxmmxVCSOXsSvukqvuh ps9/CyUNQ5oXnV/HvLqbYODqgw7FdIQcsLojfEr859422o7N5MjqK+CD5WGBa4RI8+ YII/CDOq7TfB3nB70VxgvzcOtfaZ5UXQVFIgqEHOePl/BrkPJImqH5hIIn2ei96p+C /pSNKQk/D3y5w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AC9E7180051 for ; Wed, 25 Jun 2025 12:19:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (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, 25 Jun 2025 12:19:38 +0000 (UTC) Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e81826d5b72so1320305276.3 for ; Wed, 25 Jun 2025 05:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech.net; s=google; t=1750854093; x=1751458893; 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=qRn0f9IJf6nT73HHpw8z2mFtSJkMtEfkg8PYfehGXj8=; b=NJOu73E6EKfBzvbD6oD7vLBmMiBGb9DmfyJOnkAdlh5iKCExoXmDeOZ5QctqO0Pa4C F6oie3IhNRr3q8n4gglAsDU2QR6fK8OIoXrBanwTSn/R0T7nAy+UYDp1PMUCpYTMlfmm 1ukfkUlSaeg+q1T0xGS+eCPgr0Oc+QZr5k3t2DsfMzug22jkOnLYBESYvqx01pwngAxa jtUXEKUnqd9vVsqeVirbcw0Y5WJZK568yI7CHDpeMaNhNCLl/JKAt1tJhlj42R06TGBl WTHCuILgOdtU6aG6W96Pn3Simb1rXvPc76RudzdcwlURg321fDJMFtrpDpYNuHb7nkhL glXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750854093; x=1751458893; 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=qRn0f9IJf6nT73HHpw8z2mFtSJkMtEfkg8PYfehGXj8=; b=iQ9FVNrXKMDNUGEB4rzIgJLWg2UOUx47E4p80F3qdLCzDsVDPA+Nb6CHztMmand3mb UHsbYgoHCE3/8f2fHNLRQaAOP0sE+tNnGdhJZyOctQmKo7K7hDRam5NCHf3f9kmFL8KT ntqCxCfxIJRWn1HebR6lRU5K49q+soXhwecy7OA1i3HeDP/+8nzr/iw7YwB/e8F+b9g4 Zyt1ZqnVu2Q+tdtly4Oa+1htr8AxUq5PY51knE1RvOyKhYVDky9+DRU2sHXi0lBBaxO8 ThKqrrAH/ZJz33rZjmNWjShJ6z3oKfs0kvKWB78Ro/h3qqDDIU9J/JNjzMQtJmQP40wc 2WBg== X-Gm-Message-State: AOJu0YwrENPwt8+xqOi3dXwUtodyP2JUvETUW7wz11lWGgGGv0qxQ0zD E8Jf7whC1liPNt2ERJHqOtj5U0bN9OkIZkiwIaTjaR5PHnolAjcWB9LOu1ZRNunNwyopyxuie+g j+F7788vJGGp/CFJHBZkn6bZ34gePivq6Cf0D6DIcMUH5IuXR8dyI2vQ= X-Gm-Gg: ASbGncsh4F0tpPBYqRsDeOebZybgg9RKEFsGC3XXPeUXqFoZxCcYpQS2xL4hAuFr7vk m2d73LHwzDQCfA8ciMQ7QxqWihkCp5HgDDz2KYd+uY57UjpAhHXFaxMqK/Q6qljIHDeHZq69oNd 22vGBTyPiJ1KY1KD3gGq6QGYNABoZKiyB8cOGtMjSN X-Google-Smtp-Source: AGHT+IGkhnuBhhkbMF8D7C5CyR32WvsayFVb1wz0FZp4B2IKtrVUTAoS8byxSv7yU4eJjRyPjG88cknjtEhzIrN9u1w= X-Received: by 2002:a05:6902:268a:b0:e84:3650:42cc with SMTP id 3f1490d57ef6-e86016cf890mr3289141276.3.1750854093139; Wed, 25 Jun 2025 05:21:33 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <2108D675-AEF0-410B-9BD1-E68BFEBE4F9B@cschneid.com> In-Reply-To: <2108D675-AEF0-410B-9BD1-E68BFEBE4F9B@cschneid.com> Date: Wed, 25 Jun 2025 14:21:22 +0200 X-Gm-Features: Ac12FXx51GpK9M-W83BzzgvGdXupVOqWlPmhOAQuLI12Gzq8u-8UZmluQJH9ok0 Message-ID: Subject: Re: [PHP-DEV] Make Reflection*::getDocComment() return an empty string instead of false To: Christian Schneider Cc: PHP internals Content-Type: text/plain; charset="UTF-8" From: andreas@dqxtech.net (Andreas Hennings) On Wed, 25 Jun 2025 at 13:56, Christian Schneider wrote: > > Am 25.06.2025 um 12:37 schrieb Gina P. Banyard : > > While working on the deprecation to/from bool type juggling in functions RFC and seeing the impact within Symfony, we found a common slightly annoying case. > > The getDocComment method of various Reflection classes was always used as a string, and we thought changing the behaviour in PHP made more sense. > > > > I submitted a PR [1] but was asked to gather feedback on the mailing list. > > > > Please let me know what you think. > > In general I like out-of-band instead of in-band signalling as it seems more robust to me. I agree with this. I was not familiar with the terms, but they make a lot of sense. This said, I have experienced that some people feel different, and want to return '' all the time.. In general, "return null" becomes more valuable if an empty string would have a different meaning. In this case, an existing doc comment can never be an empty string. So there is no ambiguity if we would use ''. But semantically, I think of "no doc comment" as different from "empty doc comment", and null (or false) reflects that better than an empty string. > > I am a bit confused why it was false in the first place and not null as the absence of something was in my book the definition of null. > But then again I realise there is a general aversion against null. I think false is just "legacy null" for a lot of php built-in functions and methods. Any argument for the aversion to null would equally apply to false, when used as a "not found" value. If starting from scratch, I would prefer "return null" in all of those places. But at this point I don't think the BC break is worth it, so the "return false" will follow us around for a long time. (The BC break applies to extending and to conditonal checks with === false) > > I noticed that the "empty string for absence of value" was also used in DOMElement::getAttribute() but you can argue that the existence of DOMElement::hasAttribute() fills this gap. I think all this shows is that different parts of php were created by different people, or that somebody changed their mind over time. To me, "return null" would be preferable for DOMElement::getAttribute(). https://3v4l.org/QHXlA Cheers Andreas > > Anyway, I'm not a big fan of this move but won't fight it either. > > Regards, > - Chris