rfc:property_write_visibility
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:property_write_visibility [2020/06/29 14:25] – Fix intro of "Main differences to previous proposals" andrerom | rfc:property_write_visibility [2020/07/07 07:33] (current) – andrerom | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Property write/set visibility ====== | ====== PHP RFC: Property write/set visibility ====== | ||
- | * Version: 0.4.5 | + | * Version: 0.4.6 |
* Date: 2020-06-29 | * Date: 2020-06-29 | ||
* Author: André Rømcke < | * Author: André Rømcke < | ||
- | * Proposed PHP version: PHP 8.0 | + | * Proposed PHP version: PHP 8.1 |
* Status: Under Discussion | * Status: Under Discussion | ||
* First Published at: http:// | * First Published at: http:// | ||
Line 18: | Line 18: | ||
<code php> | <code php> | ||
+ | /** | ||
+ | * @property-read int $id | ||
+ | * @property-read string $name | ||
+ | */ | ||
class User { | class User { | ||
private int $id; | private int $id; | ||
Line 92: | Line 96: | ||
This RFC is inspired by what was proposed on internals mailing list in "RFC Proposal - Attributes read/write visibility" | This RFC is inspired by what was proposed on internals mailing list in "RFC Proposal - Attributes read/write visibility" | ||
+ | |||
+ | In both cases the purpose is to provide for a wider set of use cases. | ||
==== Readonly ==== | ==== Readonly ==== | ||
Line 135: | Line 141: | ||
| | ||
// Property is write-only in public and protected scope | // Property is write-only in public and protected scope | ||
- | private: | + | private: |
public function __construct(int $id, string $name) { | public function __construct(int $id, string $name) { | ||
Line 159: | Line 165: | ||
| | ||
// Property is write-only in public and protected scope | // Property is write-only in public and protected scope | ||
- | private public(set) string $newName; | + | private public(set) string $newPassword; |
public function __construct(int $id, string $name) { | public function __construct(int $id, string $name) { | ||
Line 224: | Line 230: | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | Next PHP version, 8.0 suggested. | + | Next PHP version, 8.1 suggested. |
rfc/property_write_visibility.txt · Last modified: 2020/07/07 07:33 by andrerom