Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130224 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 3FCF41A00BC for ; Mon, 2 Mar 2026 19:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1772478743; bh=np3qi0OWvfdINWk+Aa7++rm9niEQU3dySbS8/eZEOt0=; h=Date:Subject:To:References:From:In-Reply-To:From; b=HIG1DvxkbHunAfPLmyZJV5V1q64XLcKSX1XizjLJEZxrkChQAp1Y6EShPSZDidBgh NymCG3FAI6OimQZlCDduhW1oBpO3oJbTWSNX4ZopyUsmBfEuiRfTddqmfDFZXiQcuq TCsu1U8SXbeFcPXbxaGDyj23UMB86ppPvL7LwcQHULLgIO1vAQwAog38wUIUcllZBS a3Ep5Gsbr+cH2AZ5agRdLlo/S4mjhStNNIPn2FJ3duBOA7V+ls+rfJJIFwZzSp+ISr mNyqiPY81evY+VnbPr0n+wow9HGRVyao8ezIwa+GSFeNtKDmQnKb1Iu6meUa+fASOe OxgdQlvE5uOXg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A689D180083 for ; Mon, 2 Mar 2026 19:12:19 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Mon, 2 Mar 2026 19:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1772478731; bh=nVFk6bI7AbbS5CWBxzDNgA+2OzlKNJRRgaHgOL1qCd4=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=IL7FZh+kiBeVmf+6lgGvQclZ3tESPSMP/d1G6fX7kV+Dt5l+z3Vvv655DkeKchNCr A3f+fdIgjwpnqistY79F8/rIbrOGMtYdPqjR8TJJPuIX8DrAlqqZwDwp9RrxGugGGT dsgkN1vCJAa8Xd7cqKJM91hVObymHNjAOnf0clofYuJ/3//c/qyjlEMjLkiQT0eNWe J/2G1vibVIPPXPQ2M5gClsULExwf7Uad/ga9SKMrisIawRgPnzGR2q4VE0UBUQhEyi OYyxm4Yv0V59QEwasDq1k4uCjmFBFSSFnnqdB1TKnfagYMsgu8lrDXyVafwdY1pN0L 6L3mt8sMMN4vw== Message-ID: Date: Mon, 2 Mar 2026 20:12:10 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] Exempt input type and value validation from BC Break policy To: Christian Schneider , PHP internals References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 3/2/26 14:49, Christian Schneider wrote: > Playing my favourite broken record: > Can we please state that additions of Exceptions should (in most cases) go through an E_WARNING phase to allow a time window to fix code before changing the behaviour? “Not passing invalid values” is perfectly backwards compatible. Folks can just fix their code before upgrading their production deployment to the new PHP version, e.g. by trying out the new PHP version in a staging system or running CI for both the old and new PHP version. In practice an E_WARNING is no less breaking than going straight to an Error, because: 1. The common frameworks include error handlers that just convert any warning and notice to an Exception. 2. The code is already broken, because it relies on unspecified behavior. The error would just making the user aware that the code is very likely not doing what it appears to be doing based on the input values passed to a function. To give a concrete example: The `sort()` function has a second parameter `int $flags = SORT_REGULAR`. So clearly I can pass one of the `SORT_*` constants to it. Let's see which ones we have: foreach (get_defined_constants() as $constant => $value) { if (str_starts_with($constant, 'SORT_')) { echo $constant, ": ", $value, PHP_EOL; } } This prints: SORT_ASC: 4 SORT_DESC: 3 SORT_REGULAR: 0 SORT_NUMERIC: 1 SORT_STRING: 2 SORT_LOCALE_STRING: 5 SORT_NATURAL: 6 SORT_FLAG_CASE: 8 Great! Let's sort an array in descending order: $array = [1, 5, 3]; sort($array, SORT_DESC); echo implode(", ", $array), PHP_EOL; This code *clearly* prints 5, 3, 1, since `SORT_DESC` is a `SORT_*` constant that is accepted by `sort()` and DESC is a common abbreviation for descending, right? ----------- Going through an E_WARNING would add maintainer busywork and complicate the php-src codebase for no real gain. Best regards Tim Düsterhus