rfc:static-aviz

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:static-aviz [2024/10/23 05:24] – created crellrfc:static-aviz [2025/02/27 20:51] (current) – Close the vote crell
Line 3: Line 3:
   * Date: 2024-10-23   * Date: 2024-10-23
   * Author: Ilija Tovilo (tovilo.ilija@gmail.com), Larry Garfield (larry@garfieldtech.com)   * Author: Ilija Tovilo (tovilo.ilija@gmail.com), Larry Garfield (larry@garfieldtech.com)
-  * Status: Draft+  * Status: Approved
   * First Published at: http://wiki.php.net/rfc/static-aviz   * First Published at: http://wiki.php.net/rfc/static-aviz
  
Line 13: Line 13:
  
 All behavior described in the Asymmetric Visibility v2 RFC (linked above) for object properties will apply for static properties in the exact same way.  See that RFC for complete details, as they are identical here. All behavior described in the Asymmetric Visibility v2 RFC (linked above) for object properties will apply for static properties in the exact same way.  See that RFC for complete details, as they are identical here.
 +
 +<code php>
 +class Example
 +{
 +    public private(set) static string $classTitle = 'Example class';
 +    
 +    // Implicitly public-read, just like object properties.
 +    protected(set) static int $counter = 0;
 +    
 +    public static function changeName(string $name): void
 +    {
 +        // From private scope, so this is allowed.
 +        self::$classTitle = $name;
 +    }
 +}
 +
 +print Example::$classTitle; // Allowed.
 +
 +Example::$classTitle = 'Nope'; // Disallowed.
 +</code>
 +
 +Note that some aviz functionality relates to ''final'' properties specifically, such as ''private(set)'' being implicitly ''final'' ''final'' static properties are already supported in PHP, so that poses no concern for this RFC.
 +
 +==== Exclusions ====
 +
 +Of note, ''readonly'' and property hooks are not affected by this RFC.  Those remain available only on object properties.  They have their own implementation complexities and use case considerations, and if there is interest would be a subject for another time.
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 32: Line 58:
  
 2/3 yes or no vote. 2/3 yes or no vote.
 +
 +Vote opened 12 February 2025
 +Vote closes 26 February 2025
 +
 +<doodle title="Approve asymmetric visibility for static properties?" auth="crell" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
 +
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
rfc/static-aviz.1729661063.txt.gz · Last modified: 2024/10/23 05:24 by crell