rfc:scalar-pseudo-type

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
Next revisionBoth sides next revision
rfc:scalar-pseudo-type [2017/12/24 17:17] – Added Open Issue fleshgrinderrfc:scalar-pseudo-type [2017/12/24 17:29] – Added more Examples fleshgrinder
Line 93: Line 93:
  
 However, it is also useful in userland. However, it is also useful in userland.
 +
 +<code php>
 +interface Parser {
 +    /** @return static */
 +    function parse(scalar $input);
 +}
 +</code>
  
 <code php> <code php>
Line 123: Line 130:
  
 ======= Scalar Returns ======= ======= Scalar Returns =======
-The return type constraint is less commonly useful than the one for parameters, however, it is specifically of interest while designing supertypes for others and to work around the magic ''__toString'' method that can only return values of type ''string'' (and is incompatible with exceptions).+The return type constraint is less commonly useful than the one for parameters, however, it is specifically of interest while designing supertypes for others and to work around the magic ''toString'' method that can only return values of type ''string'' (and is incompatible with exceptions).
  
 <code php> <code php>
Line 149: Line 156:
  
 ===== Open Issues ===== ===== Open Issues =====
-  * Whether ''scalar'' should accept objects with a magic ''__toString'' method in weak mode like the ''string'' constraint does.+  * Whether ''scalar'' should accept objects with a magic ''toString'' method in weak mode like the ''string'' constraint does.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
rfc/scalar-pseudo-type.txt · Last modified: 2017/12/24 23:33 by fleshgrinder