Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127478 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 0BEA61A00BC for ; Tue, 27 May 2025 08:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748334786; bh=wMgy1NXW3G3GlPGpBY5PBjCLqOZDItQXqQHwcArtbH0=; h=From:Subject:Date:References:To:In-Reply-To:From; b=WGvb1kgCdzfxGW7tori4MqpD9UzW8jS+P9phssmPNYneaDXk8SXM0Wr7hFKAgBCym gW2H7Udi6+Oq76LVwwEauXGw9o2quI9QONSyXuECL/lzzK6xekwBDAb6wlX/o9Aoc0 ETs8qdZGgkuASDJBiFZZvUXAqIWMP6pGWInEQg6PCHU0PthKJtL/wWMb4DdBB/eAZ2 a6NWkJ1HZFuSh2k8WFbanA/R8LDs58d47Bq+FRUI6wz9Igho1xng62nb7mfm5jXkNE AJLZq+K8T9zze8GpHhGCJlExsXzejpxQ9cJ69GJ0PfKaNGVUjqOGI74alrDYMKMXhq r+HbSpK4x1Mww== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2F08A18006A for ; Tue, 27 May 2025 08:33:05 +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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,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.gna.ch (mail.gna.ch [212.45.196.109]) (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 ; Tue, 27 May 2025 08:33:04 +0000 (UTC) Received: from smtpclient.apple (unknown [IPv6:2a02:1210:2e2d:4d00:c84b:1db7:d932:f470]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id 3EFD33A0795 for ; Tue, 27 May 2025 10:35:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cschneid.com; s=default; t=1748334910; bh=wMgy1NXW3G3GlPGpBY5PBjCLqOZDItQXqQHwcArtbH0=; h=From:Subject:Date:References:To:In-Reply-To; b=GjkbZ+3xzSTTcVYxH4Y2+CnSlugHj1POJg9wy/O4xi9xkhGwmKr7ntKCUgupE9uSS xL8BDUZRDwgkTbI6o4PV00FZCY1iJ52PpmHA3UCYfZELcBHl3TdgRZGclKULLwnyQx X2UmQ/LMGB/62+R3GTkuoZMR0spBYepvY1O/10rk= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: [PHP-DEV] ext/gd: changing signatures for functions returning true Date: Tue, 27 May 2025 10:35:09 +0200 References: <639E0BE3-F1F7-49F3-801F-721C87134063@gmail.com> To: PHP internals In-Reply-To: <639E0BE3-F1F7-49F3-801F-721C87134063@gmail.com> Message-ID: <90661865-1EE7-445D-A5DC-DFD0C2558205@cschneid.com> X-Mailer: Apple Mail (2.3826.600.51.1.1) From: cschneid@cschneid.com (Christian Schneider) Am 27.05.2025 um 10:00 schrieb Claude Pache : >> Le 27 mai 2025 =C3=A0 00:51, David CARLIER a = =C3=A9crit : >> Working through this https://github.com/php/php-src/pull/18651/files, = do not mind waiting for PHP 9 if needs be. Let me know what you think. >=20 >=20 > Those functions are documented to return false on failure (e.g. = https://www.php.net/manual/en/function.imagesetthickness.php). For that = reason, I typically check for failure (e.g., `if (! = imagesetthickness(...)) { return false; }`). >=20 > If some or all functions of the gd library do not or no longer return = false, please amend the documentation, so that I (and everyone else, see = e.g. https://phpstan.org/r/a69b0ad4-b4bd-4487-a6d1-a436ce142dc2 ) know = that those checks are useless without needing to read the php source = code. >=20 > But don=E2=80=99t just change the return type from `bool` to `void`: = you are needlessly breaking existing code. Thanks! I agree. If you want to change this then it should go through a warning = phase whenever the return value is not discarded. The engine has means = to determine this, similar but opposite of #[\NoDiscard]. OTOH I'm not sure the change is even worth it, maybe just adapt the = documentation saying that it always returns true and move on. The current behavior also allows for constructs like file_exists($fn) && ($img =3D imagecreatefrompng($fn)) && = imagesetthickness($img, 10) && ... Not that I'm advocating this usage but it can be short form of chaining = things. Regards, - Chris