Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123573 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 0906A1A009C for ; Tue, 11 Jun 2024 00:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718066201; bh=MxpTMGO3wjxAVACjy5f+IT+12tu+/8xvrK2/elPpjXk=; h=From:Date:Subject:To:From; b=Du9xqa5j/TLW4VlFI2kcWgHU5KNW0Op9XNZluLS2pL29t3A/nxJO+Up1GzdkDtswz oOtkB//CLvx7FGiVXpYZM0gZNtRqoj1s5nCYp7IkAQ9txanxLruobhLMCEjdSYdWVl 3k2QmRUsuWDqoEgSAQv5ohIWvHFa1MLSmM6JjCc5CugaZ37AtKnx4fNOPpECiic0CM X7gITW0JnJTlswOM2wb/R1ndcahd8exwN+dnE7ZyLuVBqod+4aHMSQXn5b7wDxmJ2o 35ha+aFvomi4nwPwuFTWEbOqCeW9Ar42cdIgvxCrwBhFW6KHQrTdqZWSR1qUTgVPl3 UvCuxfMFIiRwg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 93182180039 for ; Tue, 11 Jun 2024 00:36:40 +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, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 00:36:40 +0000 (UTC) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4218008c613so4482265e9.2 for ; Mon, 10 Jun 2024 17:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718066131; x=1718670931; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=++B4WyGCdMid7CWHA157Lp3ZYlSRo2Oe1zKiXG4bJf4=; b=jAQ/KRPoXAg2lYIBMyk4E7stTx3gNCBZ4uPvjwYur/QIgV2YxE4iiKbpmpzlWA8tQ8 HaiBBCzIQNVP+74FRWAURePp9+S5rujb6/2CxtAI9kCel7ATWtkj6tN2v+IWEmJxZTEh BwiPwhBHOX7X78+t60BKCA3p2Zotul1C1HhZKwzCvn+gt5FRZjviJ7fx4yNR7FzGLjvD JwQmbFPgfhdpxXkPRqckOUpvQcis6I46zKWrq+ariscAFO0PzEXZ5Immdub65ASYyS3t /27E4yrV0xdazZPEtkRrprPdCLPro5v7XXMDBhKSnnK7qQ9e78Y7cm4zvbCoo57iRVAH gCOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718066131; x=1718670931; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=++B4WyGCdMid7CWHA157Lp3ZYlSRo2Oe1zKiXG4bJf4=; b=JsR0q50ARZVR0fmwEJfCaBpQTfwe1nLNwRDS7C25hMQWQTLipIqlfBsOZ5zGyPY63N +NazXEv8c9wxaYrACscIhjkeLK1dNPA4u5MBJT9/6CPubaRIJqtgpc8ze2XkNdQW999q w5h72D6WebUAIUlLKfgmJPIPLrFLmXWM1l/L0mYKTp+ioNrQ6Dd4/Sv7NKiWz4s2mi7/ luUX4xHb70bUwY/HjenKZbW64INwnIC6yDR/0SaubRIYesIhKFAT0ug4h+O5Edj8HncI 7YDnYkl+8gPTWlyKi7ekgT4wsbD7BwAJrC/BDgw+f3mDvSrh2c6eBUBF+ttjwc7Dly2i wMkQ== X-Gm-Message-State: AOJu0Yw0kqhaksNGhAjkDM56ylANuZHORiLvw5coP0h6An/QR9VTOfhj CfUNwBXXe0gDPtksEe/c+aCNqE3aUT6jN3hOtNgY0OCE7Qw8CU03schsB8YuwwzUd6MwOoHUpTt tVlt6reTWlAVYX3mi0vpVCRTS5MVKiA1ICQ== X-Google-Smtp-Source: AGHT+IHfndZFyVnyCdr/v2Sfbb3MPqnPNfpcvVg2gDtcJ9fvmTAJ6Op2Fe9GKt6K/mn57wXPcu15qGtcTSek4QzMwuU= X-Received: by 2002:a05:600c:1c10:b0:41c:2313:da92 with SMTP id 5b1f17b1804b1-421649ec7b1mr92325375e9.4.1718066130776; Mon, 10 Jun 2024 17:35:30 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Date: Tue, 11 Jun 2024 03:35:19 +0300 Message-ID: Subject: [PHP-DEV] Revisiting case-sensitivity in PHP To: php internals Content-Type: multipart/alternative; boundary="0000000000006cf903061a927158" From: udaltsov.valentin@gmail.com (Valentin Udaltsov) --0000000000006cf903061a927158 Content-Type: text/plain; charset="UTF-8" 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_constant_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 run on (Linux) 3. uniform handling of ASCII and non-ASCII symbols (currently non-ASCII symbols in names are case sensitive: https://3v4l.org/PWkvG) 4. PSR-4 compatibility ( https://www.php-fig.org/psr/psr-4/#:~:text=All%20class%20names%20MUST%20be%20referenced%20in%20a%20case%2Dsensitive%20fashion ) 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 change: - more and more projects adopted namespaces and PSR-4 autoloading via Composer that never supported case-insensitivity ( https://github.com/composer/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 codebase for the next PHP version) On con 2. While considering different transition options proposed in prior discussions (compilation flag, ini option, deprecation notice) I stumbled upon Nikita's comment (https://externals.io/message/79824#79939): > May I recommend to only target class and class-like names for an initial > RFC? Those have the strongest argument in favor of case-sensitivity given > how current autoloader implementations work - essentially the > case-insensitivity doesn't properly work anyway in modern code. ... I'd also appreciate having a voting option for removing case-insensitivity > right away, as opposed to throwing E_STRICT/E_DEPRECATED. If we want to change this, I personally would rather drop it right away than start > throwing E_STRICT warnings 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 the stress. So the plan for 8.4 might be to just drop case insensitivity for class names and that's it... Let's discuss that! -- Best regards, Valentin Udaltsov --0000000000006cf903061a927158 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, internals!

9 years have passed since the last d= iscussions of case sensitive PHP:=C2=A0https://externals.io/message/79824 and https://externals.io/message/83640.
Here = I would like to revisit this topic.

What is case-se= nsitive in PHP 8.3:
- variables
- constants (all since https= ://wiki.php.net/rfc/case_insensitive_constant_deprecation)
- class = constants
- properties

What is case-= insensitive in PHP=C2=A08.3:
- namespaces
- functions
= - classes (including self, parent and static relative class types)
- methods (including the magic ones)

Pros:<= /div>
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 run on (Linux)
3. uniform handling of=C2=A0ASCII and non-ASCII symbols (currently non-A= SCII symbols in names are case sensitive: https://3v4l.org/PWkvG)

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 f= or the change:
- more and more projects adopted namespaces and PS= R-4 autoloading via Composer that never supported case-insensitivity (https://github.com/= composer/composer/issues/1803, https://github.com/composer/composer/issues/8906) = which forced to mind casing
- static analyzers became more popular and t= hey do complain about the wrong=C2=A0casing (see https://psalm.dev/r/fbdeee2f38 and https://phpstan.org/r/1= 789a32d-d928-4311-b02e-155dd98afbd4)
- Rector appeared=C2=A0(it can = be used to automatically prepare the codebase for the next PHP version)
=

On con 2.=C2=A0While considering different transition options proposed in pr= ior discussions (compilation flag, ini option, deprecation notice) I stumbl= ed upon Nikita's comment (https://externals.io/message/79824#79939):
May I recommend to only target class and class-like n= ames for an initial RFC? Those have the strongest argument in favor of case= -sensitivity given
how current autoloader implementations work - essenti= ally the case-insensitivity doesn't properly work anyway in modern code= .
...
I'd=C2=A0also ap= preciate having a voting option for removing case-insensitivity right away,= as opposed to throwing E_STRICT/E_DEPRECATED. If we want to=C2=A0
change this, I person= ally would rather drop it right away than start throwing E_STRICT warnings = that would make the case-insensitive usage impossible anyway.
<= div>It makes a lot of sense to me: a fairly simple change in the core and n= o performance penalty. At the same time, a gradual approach will reduce the= =C2=A0stress.

So the plan for 8.4 might be to = just drop case insensitivity for class names and that's it... Let's= discuss that!
-- Best regards,
Valentin Udaltsov

--0000000000006cf903061a927158--