rfc:class_const_visibility
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:class_const_visibility [2015/10/06 15:17] – sean-der | rfc:class_const_visibility [2015/12/08 16:01] – Merged into 7.1 sean-der | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2015-09-13 | * Date: 2015-09-13 | ||
* Author: Sean DuBois < | * Author: Sean DuBois < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 14: | Line 14: | ||
In a thread on php-internals a couple real world examples were offered. | In a thread on php-internals a couple real world examples were offered. | ||
- | | + | * Defining bitmasks/ |
- | | + | * Help make it more clear what is important, exposing harmless constants clutters documentation |
===== Proposal ===== | ===== Proposal ===== | ||
Line 23: | Line 23: | ||
Class constant may be define as public, private or protected. class constants declared | Class constant may be define as public, private or protected. class constants declared | ||
- | without any explict | + | without any explicit |
Proposed syntax: | Proposed syntax: | ||
Line 38: | Line 38: | ||
protected const PROTECTED_CONST = 0; | protected const PROTECTED_CONST = 0; | ||
public const PUBLIC_CONST_TWO = 0; | public const PUBLIC_CONST_TWO = 0; | ||
+ | | ||
+ | //Constants can only have one visibility declaration list | ||
+ | private const FOO = 1, BAR = 2; | ||
} | } | ||
- | // | + | // |
interface ICache { | interface ICache { | ||
public const PUBLIC = 0; | public const PUBLIC = 0; | ||
- | protected | + | |
- | + | ||
- | public function get($k, $v); | + | |
- | public function set($k); | + | |
} | } | ||
- | </code> | + | //Reflection |
- | + | ||
- | + | ||
- | ===== Backward Incompatible Changes ===== | + | |
- | + | ||
- | ==== Reflection | + | |
- | The reflection extension has been updated | + | |
- | + | ||
- | Instead of getConstant/ | + | |
- | + | ||
- | <code php> | + | |
- | <?php | + | |
class testClass | class testClass | ||
const TEST_CONST = ' | const TEST_CONST = ' | ||
Line 68: | Line 56: | ||
$obj = new ReflectionClass( " | $obj = new ReflectionClass( " | ||
- | $const = $obj->getConstant( " | + | $const = $obj->getReflectionConstant( " |
- | $const-> | + | $consts = $obj->getReflectionConstants(); |
- | $const->getName(); | + | |
- | $const-> | + | |
- | $const-> | + | |
- | $const-> | + | |
- | $const-> | + | |
- | $const-> | + | |
- | $const-> | + | |
</ | </ | ||
+ | |||
+ | |||
+ | ===== Backward Incompatible Changes ===== | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 94: | Line 79: | ||
There will be new _ex APIs that allow callers to explicitly pass flags. | There will be new _ex APIs that allow callers to explicitly pass flags. | ||
- | If a extension accesses non-public structures (the now non-existant | + | If a extension accesses non-public structures (the now non-existent |
==== To Opcache ==== | ==== To Opcache ==== | ||
Line 100: | Line 85: | ||
Need update. | Need update. | ||
- | ===== Proposed Voting Choices | + | ===== Vote ===== |
Simple Yes/No option. This requires a 2/3 majority. | Simple Yes/No option. This requires a 2/3 majority. | ||
+ | |||
+ | This vote will close on 06:00 UTC on Tuesday 2015-10-27 | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 108: | Line 100: | ||
A pull request has been made. It is feature complete but needs review, more tests, and help with opcache changes : https:// | A pull request has been made. It is feature complete but needs review, more tests, and help with opcache changes : https:// | ||
+ | This feature was merged into PHP master here: https:// | ||
===== References ===== | ===== References ===== |
rfc/class_const_visibility.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1