rfc:propertygetsetsyntax-alternative-typehinting-syntax

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:propertygetsetsyntax-alternative-typehinting-syntax [2013/01/10 21:25] – Add default value / nullabiltiy section nikicrfc:propertygetsetsyntax-alternative-typehinting-syntax [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 2: Line 2:
   * Date: 2013-01-04   * Date: 2013-01-04
   * Author: Nikita Popov <nikic@php.net>   * Author: Nikita Popov <nikic@php.net>
-  * Status: Under Discussion+  * Status: Declined
  
 ===== Introduction ===== ===== Introduction =====
Line 102: Line 102:
  
 Note that properties are ''null'' initialized by default. The nullability semantics do not (and can not) affect this. They only specify whether it's possible to **assign** ''null'' to the property after initialization. Note that properties are ''null'' initialized by default. The nullability semantics do not (and can not) affect this. They only specify whether it's possible to **assign** ''null'' to the property after initialization.
 +
 +Default values can only be used on the shorthand notation. If accessor methods are specified a default value can not be used. The only exception is the ''= null'' default, which can still be used to specify nullability:
 +
 +<code php>
 +public DateTime $date = null {
 +    get { ... } set { ... }
 +}
 +</code>
  
 ===== Benefits of the proposed syntax ===== ===== Benefits of the proposed syntax =====
Line 149: Line 157:
 ===== Patch ===== ===== Patch =====
  
-I haven't written a patch for this yet, but the change from the current syntax to this one is rather simple. The current accessors proposal will need special handling of the typehint in any case (it can't be handled as normal method typehint)The proposed syntax would actually make the handling slightly simpler.+The patch for this proposal is available here: https://gist.github.com/4579298. You can find the individual commits here: https://github.com/nikic/php-src/commits/alternativeSyntax. 
 + 
 +===== Voting ===== 
 + 
 +This proposal depends on the main accessors RFC. The result of this vote is only relevant if the main RFC is accepted. As this is a language change it requires 2/3 majority. 
 + 
 +<doodle title="Should the proposed typehinting syntax be used instead of the current one?" auth="nikic" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle> 
 + 
 +The vote ended 3 in favor, 12 against, as such this feature is declined.
rfc/propertygetsetsyntax-alternative-typehinting-syntax.1357853107.txt.gz · Last modified: 2017/09/22 13:28 (external edit)