Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120959 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42821 invoked from network); 30 Aug 2023 11:44:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Aug 2023 11:44:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 22D8C1804F2 for ; Wed, 30 Aug 2023 04:44:02 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 30 Aug 2023 04:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1693395840; bh=imkH2u+p4bpwHtM32FOMckAir0NrU7KmvfRoSLAfSjE=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type:from:to: cc:subject:message-id; b=jxOfU9N/sav+cPLxHadiI54hG5n573B3aR3OVB0fXVBAJRqwro+IVjsYijZdFVGGi JIky38IavWUIZi0GbYPjV/RK76Y7HTUmSEu3fjOEu7Ixv4Ri59cBpjFslpJvcP9CJc HrtpVWM3UCSCip/Ocz92bpatdPEOitAKubtBlPz1IuUUFpwlrdrld3MxVp/G5yCW9F QUfGm2GNf6mzCkpzKQvBPSrj+ztYP7ksajyGhGmPMtc3ox0tSInoOiiaILYdRIjx/J e8vcy4Oq9KRcqHFSkLMy26ivRNhzfYd52QwyLII7QKW8Sz+4adlaptZcq0VAzdx8ZE ZeX6oBHAS8s/g== Message-ID: <01e3ff17-5088-0431-6014-82ef4e4789b2@bastelstu.be> Date: Wed, 30 Aug 2023 13:43:59 +0200 MIME-Version: 1.0 Content-Language: en-US To: PHP internals Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Casing of acronyms in class and method names From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi after suggesting the use of ucfirst(strtolower(...)) casing for acronyms within a classname of a draft RFC, I was made aware of previous class naming RFC (June 2017) that required the use of PascalCase for class names, with the exception of acronyms which must be completely uppercased: https://wiki.php.net/rfc/class-naming I'd like to propose to revisit this earlier decision for the following reasons. Before writing an RFC I'd like have some pre-discussion to gauge opinions. -------------------- 1. It is not consistently applied: a) As an example ext/json has 'JsonException' which should've been JSONException according to the RFC's results. In fact JsonException's RFC was created just 3 months (!) after the class naming RFC in September 2017: https://wiki.php.net/rfc/json_throw_on_error b) Another example is ext/curl which has both 'CurlHandle' and 'CURLFile'. CURLFile predates the RFC, but there's also CURLStringFile which was added in PHP 8.1 and likely followed CURLFile's naming for consistency, but violating the RFC and being inconsistent with CurlHandle. c) ext/random's Random\Engine\PcgOneseq128XslRr64 would've needed to be called Random\Engine\PCGOneseq128XSLRR64 according to the class naming RFC. d) The accepted, but not yet implemented, "PDO driver specific sub-classes" RFC uses Pdo, e.g. PdoOdbc instead of PDOODBC: https://wiki.php.net/rfc/pdo_driver_specific_subclasses 2. It decreases readability. Especially if multiple acronyms follow each other. One example is the PCGOneseq128XSLRR64 mentioned above: It's not clear that XSL (XorShiftLow) and RR (RandomlyRotate) are two different acronyms. Likewise PDOODBC is much harder to parse than PdoOdbc. Another example might be JavaScript's XMLHttpRequest which incidentally mixes both variants. According to the class naming RFC it would need to be called XMLHTTPRequest, resulting in 8 consecutive uppercase characters. 3. Several commonly used userland libraries make a different choice. - Symfony's HttpFoundation: https://github.com/symfony/symfony/tree/6.4/src/Symfony/Component/HttpFoundation - Symfony's CssSelector: https://github.com/symfony/symfony/tree/6.4/src/Symfony/Component/CssSelector - Laravel's HtmlString: https://github.com/laravel/framework/blob/10.x/src/Illuminate/Support/HtmlString.php - PSR-7: https://www.php-fig.org/psr/psr-7/ - PSR-18: https://www.php-fig.org/psr/psr-18/ - ramsey/uuid: https://github.com/ramsey/uuid/tree/4.x/src - Flysystem is a little inconsistent, but has 'Ftp': https://github.com/thephpleague/flysystem/tree/3.x/src/Ftp - PHPUnit is a little inconsistent, but has 'Xml' and 'Json': https://github.com/sebastianbergmann/phpunit/tree/main/src/Util - Doctrine is also a little inconsistent, but has 'Dsn' and 'Sql' (but also 'SQL'): https://github.com/doctrine/dbal/tree/3.6.x/src/Schema/Visitor and https://github.com/doctrine/dbal/blob/3.6.x/src/Tools/DsnParser.php Best regards Tim Düsterhus