rfc:class_const_visibility

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
rfc:class_const_visibility [2015/10/21 17:15]
sean-der Interfaces now only support public constants
rfc:class_const_visibility [2015/12/08 16:01]
sean-der Merged into 7.1
Line 3: Line 3:
   * Date: 2015-09-13   * Date: 2015-09-13
   * Author: Sean DuBois <​sean@siobud.com>,​ Reeze Xia <​reeze@php.net>​   * Author: Sean DuBois <​sean@siobud.com>,​ Reeze Xia <​reeze@php.net>​
-  * Status: ​Under Discussion+  * Status: ​Accepted
   * First Published at: http://​wiki.php.net/​rfc/​class_const_visibility   * First Published at: http://​wiki.php.net/​rfc/​class_const_visibility
  
Line 50: Line 50:
 } }
  
-</code> +//Reflection ​was enhanced ​to allow fetching more than just the values of constants
- +
- +
-===== Backward Incompatible Changes ===== +
- +
-==== Reflection ​Ext ==== +
-The reflection extension has been updated ​to expose ​constants ​like [[ReflectionProperty|http://​php.net/​manual/​en/​class.reflectionproperty.php]].  +
- +
-Instead of getConstant/​getConstants returning values there is now a dedicated ReflectionClassConstant class. +
- +
-<code php> +
-<?php +
 class testClass ​ { class testClass ​ {
   const TEST_CONST = '​test';​   const TEST_CONST = '​test';​
Line 68: Line 56:
  
 $obj = new ReflectionClass( "​testClass"​ ); $obj = new ReflectionClass( "​testClass"​ );
-$const = $obj->getConstant( "​TEST_CONST"​ ); +$const = $obj->getReflectionConstant( "​TEST_CONST"​ ); 
-$const->​__toString();​ +$consts = $obj->getReflectionConstants(); 
-$const->getName(); +
-$const->​getValue();​ +
-$const->​isPublic();​ +
-$const->​isPrivate();​ +
-$const->​isProtected();​ +
-$const->​getModifiers();​ +
-$const->​getDeclaringClass();​+
 </​code>​ </​code>​
 +
 +
 +===== Backward Incompatible Changes =====
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
Line 106: Line 91:
 This vote will close on 06:00 UTC on Tuesday 2015-10-27 This vote will close on 06:00 UTC on Tuesday 2015-10-27
  
-<doodle title="​Class Constant Visibility"​ auth="​sdubois"​ voteType="​single"​ closed="​false">+<doodle title="​Class Constant Visibility"​ auth="​sdubois"​ voteType="​single"​ closed="​true">
    * Yes    * Yes
    * No    * No
Line 115: Line 100:
 A pull request has been made. It is feature complete but needs review, more tests, and help with opcache changes : https://​github.com/​php/​php-src/​pull/​1494 A pull request has been made. It is feature complete but needs review, more tests, and help with opcache changes : https://​github.com/​php/​php-src/​pull/​1494
  
 +This feature was merged into PHP master here: https://​github.com/​php/​php-src/​commit/​a75c195000b3226904103244fa9c3d0ce1111838
  
 ===== References ===== ===== References =====
rfc/class_const_visibility.txt · Last modified: 2017/09/22 13:28 (external edit)