Typed class constants cho phép khai báo kiểu dữ liệu cho hằng số trong class, tương tự typed properties.
Ví dụ: public const int MAX_USERS = 1000; hoặc public const string API_KEY = "secret";.
Lợi ích: tăng type safety, IDE autocomplete chính xác hơn, ngăn nhầm kiểu dữ liệu vô tình, tự document code. Kiểu phải khớp với giá trị gán tại thời điểm khai báo—PHP sẽ báo lỗi nếu không khớp. Đây là tính năng nhỏ nhưng quan trọng giúp codebase PHP lớn dễ bảo trì hơn.
Typed class constants allow declaring the type of a class constant, similar to typed properties.
Example: public const int MAX_USERS = 1000; or public const string API_KEY = "secret";.
Benefits: improved type safety, better IDE autocompletion, prevent accidental type mismatches, self-documenting code. The type must match the assigned value at declaration time—PHP will error on mismatch. A small but important feature that makes large PHP codebases more maintainable.