refactor: add PHP 8.3 types to BC-safe class constants - #63133
Open
solracsf wants to merge 1 commit into
Open
Conversation
solracsf
requested review from
a team,
ChristophWurst,
SebastianKrupinski,
blizzz,
hamza221,
kesselb,
miaulalala,
nickvergessen and
tcitworld
as code owners
August 10, 2026 15:28
solracsf
requested review from
Altahrim,
leftybournes,
provokateurin and
salmart-dev
and removed request for
a team
August 10, 2026 15:28
ChristophWurst
approved these changes
Aug 10, 2026
CarlSchwan
approved these changes
Aug 10, 2026
SebastianKrupinski
approved these changes
Aug 10, 2026
PHP 8.3 allows class constants to declare a type. Adopt it where doing so cannot break third-party apps. Typing an inheritable constant is a hard BC break: a subclass that redeclares it untyped fails to load with "Type of C::FOO must be compatible with P::FOO of type string". Changes are therefore limited to constants that cannot be redeclared by a subclass: - private const (not inherited) - final public/protected const - constants declared in a final class or an enum Interface constants, trait constants, and public/protected constants in non-final (including abstract) classes are left untyped, as is all of lib/public (OCP) and lib/unstable (NCU). One review-requested exception: the public OBJECT_PREFIX/OBJECT_SUFFIX constants of the app-internal CalDAV import helpers (TextImporter, XmlImporter) are typed as well; these classes are not public API and have no subclasses. Only string, int and array are used. float is avoided because it would silently coerce an int literal and change === comparisons. No constant name or value is modified: every changed line adds only the type token, so runtime behaviour is unchanged. Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
solracsf
force-pushed
the
chore/php83-typed-class-constants
branch
from
August 10, 2026 16:35
aaf4508 to
ea0608f
Compare
Member
Author
|
@SebastianKrupinski Under the looser standard ("public const in a class nothing extends"), generalized repo-wide, many other constants would qualify. I deliberately did not apply those. "No subclass in this repo" is not "No subclass", the list literally includes CalDavBackend, a known third-party extension surface. If you want that expansion, let me know. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PHP 8.3 allows class constants to declare a type. Adopt it where doing so cannot break third-party apps.
Checklist
3. to review, feature component)stable32)AI (if applicable)