Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123583 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 926311ADDF8 for ; Tue, 11 Jun 2024 14:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718116823; bh=vOsn6UbQ39FOfEHXrnvS1hSU1kjbUGZqgX6KeBZesW8=; h=References:In-Reply-To:From:Date:Subject:To:From; b=GSKPt/0zkcG1KO3xi8SwNcEBPwz4Ryn4STd/+tt6D2k9MLnnU/3Qk0+ZhiV6dhXHq vG0fpZrrj2bUIVpRCgOCuYM5SbqMWWKKiu0n6Uw/4faz3Tdo2wufWElDKhzI/sgaQU al+kLT81oW0G1GfzYNpl5l/tvnZDjuNhfMIO/WSWy428ujob0XczfABIudKNP+HYNz jbudveyup0SA4CjXSnFvXy1FltG++tSYynGX9mI4nX2R1EX4o4pjlJrLzeui0TvQ19 +FH5o0hgctCCmcld0PV+8A+y6LLYfirGJ5/ZbJlS0xMb4PvZYONESvfv3ZL2o3HAO1 2xvc7iOlBB8qA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A1A211809AF for ; Tue, 11 Jun 2024 14:40:20 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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, 11 Jun 2024 14:40:16 +0000 (UTC) Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a6f3efa1cc7so85296166b.0 for ; Tue, 11 Jun 2024 07:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718116747; x=1718721547; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vOsn6UbQ39FOfEHXrnvS1hSU1kjbUGZqgX6KeBZesW8=; b=c+RGJ795hU7q5wiq7Oast9hoBB9yEE3BnoR/LbxmU292uSGabiqe6scvrtlXZJHajp 1McDOtDC8cyDtMXm99ouJJ1H0SkjO6JFfdKHxllltb6oLxKaQUQUapJzA2YR7zmOftGd POUXS0gsSfzSeOFdwpCGXhDEFjKq4WTmN7wdQU52U/A8V4RzYwPIqRNCm/zwm8cjgWzo cCV6qxgLlM4g44v/0quM2dcEo4rLbaPNNmm9ZmutOD6X8p1BeY+1nZXjh5+RgiITVAq9 yno+hBSpB5h3ANhydD6mvmMOXc4rapQNpHatKpm158HQMOiyymtdh/58lM5rDrAXgtMf 1HQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718116747; x=1718721547; h=content-transfer-encoding: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=vOsn6UbQ39FOfEHXrnvS1hSU1kjbUGZqgX6KeBZesW8=; b=XOHbesk+FTzEdcOxjN59DqqKv39rDTVqXijXu4Q/uRx3GU+CGrafv3vpkMLfzgosXi SPBWIj+Vy+bQuCtlb8wlBEINnkBasODHekvdF44M7zDLZVhGqWyXoDl8pDr6lIbG8xJN uHxzzNXUDqApW90BTDmSNKAB1Cz6ZxEfOL05G2+1uWyPdLIeQIrTz2FsGz1Rqn71bWSq SvAIdizeRKsPgSwQFJEEDERo7G1oBg9Ov/QADXn0wzIlEJIP4cgAD0YGqI6jvfgNxh+n deJXfI5WbkcYiP00PNhyfSSSLkgZFFvjQ3uST9gGCcXUAUmBWiPN4o5Vg0ZN+wG00aAQ XL1w== X-Gm-Message-State: AOJu0YxHtdJJ2nf7C48WYH1/+d84AnEotpN1LJ0EI4S6+XJtNY8/bt5x OJ2VPmvopD0Zq7UKor/LMpk/Xgl/ylacjyzNadQob9dmPCAcW2jOXgPLFRG0YF2NkSwB+Xy7BfD YfqwKYHeqLTr2peH0upkk7VFIj+/pu70= X-Google-Smtp-Source: AGHT+IGulqfHLwV+PC86jlJjLhUPVcfbVV0cGsWVHEatGNJ2P0+IwB5wgSoKmkPox3txlCGVjRQPrsWRPrUcpo1Ctn8= X-Received: by 2002:adf:ef0c:0:b0:35f:30f1:848b with SMTP id ffacd0b85a97d-35f30f184demr204292f8f.4.1718116296814; Tue, 11 Jun 2024 07:31:36 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 11 Jun 2024 23:31:25 +0900 Message-ID: Subject: Re: [PHP-DEV] Revisiting case-sensitivity in PHP To: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: youkidearitai@gmail.com (youkidearitai) 2024=E5=B9=B46=E6=9C=8811=E6=97=A5(=E7=81=AB) 23:18 Levi Morrison : > > On Mon, Jun 10, 2024 at 9:40=E2=80=AFPM Ben Ramsey wrote= : > > > > > On Jun 10, 2024, at 20:35, Valentin Udaltsov wrote: > > > > > > Hi, internals! > > > > > > 9 years have passed since the last discussions of case sensitive PHP:= https://externals.io/message/79824 and https://externals.io/message/83640. > > > Here I would like to revisit this topic. > > > > > > What is case-sensitive in PHP 8.3: > > > - variables > > > - constants (all since https://wiki.php.net/rfc/case_insensitive_cons= tant_deprecation) > > > - class constants > > > - properties > > > > > > What is case-insensitive in PHP 8.3: > > > - namespaces > > > - functions > > > - classes (including self, parent and static relative class types) > > > - methods (including the magic ones) > > > > > > Pros: > > > 1. no need to convert strings to lowercase inside the engine for name= lookups (a small performance and memory gain) > > > 2. better fit for case sensitive platforms that PHP code is mostly ru= n on (Linux) > > > 3. uniform handling of ASCII and non-ASCII symbols (currently non-ASC= II symbols in names are case sensitive: https://3v4l.org/PWkvG) > > > 4. PSR-4 compatibility (https://www.php-fig.org/psr/psr-4/#:~:text=3D= All%20class%20names%20MUST%20be%20referenced%20in%20a%20case%2Dsensitive%20= fashion) > > > > > > Cons: > > > 1. pain for users, obviously > > > 2. a backward compatibility layer might be difficult to implement and= /or have a performance penalty > > > > > > On con 1. I think today PHP users are much more prepared for the chan= ge: > > > - more and more projects adopted namespaces and PSR-4 autoloading via= Composer that never supported case-insensitivity (https://github.com/compo= ser/composer/issues/1803, https://github.com/composer/composer/issues/8906)= which forced to mind casing > > > - static analyzers became more popular and they do complain about the= wrong casing (see https://psalm.dev/r/fbdeee2f38 and https://phpstan.org/r= /1789a32d-d928-4311-b02e-155dd98afbd4) > > > - Rector appeared (it can be used to automatically prepare the codeba= se for the next PHP version) > > > > > > On con 2. While considering different transition options proposed in = prior discussions (compilation flag, ini option, deprecation notice) I stum= bled upon Nikita's comment (https://externals.io/message/79824#79939): > > > May I recommend to only target class and class-like names for an init= ial RFC? Those have the strongest argument in favor of case-sensitivity giv= en > > > how current autoloader implementations work - essentially the case-in= sensitivity doesn't properly work anyway in modern code....I'd also appreci= ate having a voting option for removing case-insensitivity right away, as o= pposed to throwing E_STRICT/E_DEPRECATED. If we want to change this, I pers= onally would rather drop it right away than start throwing E_STRICT warning= s that would make the case-insensitive usage impossible anyway. > > > It makes a lot of sense to me: a fairly simple change in the core and= no performance penalty. At the same time, a gradual approach will reduce t= he stress. > > > > > > So the plan for 8.4 might be to just drop case insensitivity for clas= s names and that's it... Let's discuss that! > > > > > > I=E2=80=99m not saying I agree with or support this, but I think your p= roposal has a better chance of being accepted if you target PHP 9.0 instead= of 8.4. > > > > Cheers, > > Ben > > > > In fact, it's definitely a BC break I would not personally vote for in > 8.4. This isn't some minor thing squirreled away in a library--this is > the core language, with wide impact. For this reason, I believe it > should target 9.0. > > I will happily vote for this feature, as long as the patch is reasonable. > > The most obvious implementation is not very good, though. The engine > uses lowercase names for case insensitivity. Namespaces are embedded > into the type names. To lowercase the namespace but not the type name, > one could do a reverse scan for a namespace separator on the type > name, and then lowercase from the start to the index of the namespace > separator. For example, " Psr\Log\LoggerInterface" needs to become > "psr\log\LoggerInterface". The problem with this is that it's not > really going to save CPU nor memory because it still has to lowercase > the namespace. > > We could refactor the engine to store the namespace separately from > the type name. This is a lot more work and will increase the size of > some types, which might be difficult at a technical level. > > I can't think of other implementations right now. If nobody can come > up with a better implementation, I think we should consider going with > split-sensitivity on namespaces where it matches the sensitivity of > the thing it is attached to. A namespaced class would have a case > sensitive namespace but a namesped function would still have a case > insensitive one. Hi I'm worried that have an impact on Windows (case-insensitive file system). Even if it's only the Class name. Looks like need to more discussion. Regards Yuya --=20 --------------------------- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info - https://github.com/youkidearitai -----------------------------