michabbb on Nostr: š #PHP8.4 Introduces Asymmetric Visibility for Properties: ā¢ Allows different ...
š #PHP8.4 Introduces Asymmetric Visibility for Properties:
ā¢ Allows different read/write access levels for #PHP properties
ā¢ New syntax: public private(set) for public read, private write access
ā¢ š 9 possible visibility configurations, 3 are illegal
ā¢ šļø Applies to typed properties only, including static ones
ā¢ š Backward compatible with existing symmetric visibilities
ā¢ š« Cannot be used with untyped properties
#PHPDevelopment #OOP #Coding #SoftwareEngineering
Key features:
- Enhances encapsulation and access control in object-oriented programming
- Provides more granular control over property access
- Helps prevent unwanted modifications to properties
Use cases:
- Implementing read-only properties with internal write access
- Creating properties that can be read publicly but modified only within the class
Developers should refer to the RFC for detailed information on implementation and best practices.
https://www.exakat.io/en/asymmetric-visibility-for-php-properties/Published at
2024-10-19 07:13:07Event JSON
{
"id": "87f99f093f67d0af255c36ee858016a905c8f11aebf3344987dfc3c8556b3a02",
"pubkey": "129f83898c7008d335771fe681ecf979e7767ad958c552ff85de962ba2f775be",
"created_at": 1729321987,
"kind": 1,
"tags": [
[
"t",
"php8"
],
[
"t",
"php"
],
[
"t",
"phpdevelopment"
],
[
"t",
"oop"
],
[
"t",
"coding"
],
[
"t",
"softwareengineering"
],
[
"proxy",
"https://social.vivaldi.net/users/michabbb/statuses/113332845756599199",
"activitypub"
]
],
"content": "š #PHP8.4 Introduces Asymmetric Visibility for Properties:\n\nā¢ Allows different read/write access levels for #PHP properties\nā¢ New syntax: public private(set) for public read, private write access\nā¢ š 9 possible visibility configurations, 3 are illegal\nā¢ šļø Applies to typed properties only, including static ones\nā¢ š Backward compatible with existing symmetric visibilities\nā¢ š« Cannot be used with untyped properties\n\n#PHPDevelopment #OOP #Coding #SoftwareEngineering\n\nKey features:\n- Enhances encapsulation and access control in object-oriented programming\n- Provides more granular control over property access\n- Helps prevent unwanted modifications to properties\n\nUse cases:\n- Implementing read-only properties with internal write access\n- Creating properties that can be read publicly but modified only within the class\n\nDevelopers should refer to the RFC for detailed information on implementation and best practices.\n\nhttps://www.exakat.io/en/asymmetric-visibility-for-php-properties/",
"sig": "f823d1a8a5a72aff984f6bab3ff491524a9aeb89f3e6d10bcc0ea955587cc453883ae4bbbd2582245673a52b2b8854cd4fd801aac5fbd9615c7a963e9bdf6779"
}