rfc:user_defined_operator_overloads

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:user_defined_operator_overloads [2021/12/16 04:19] – Extra future scope jordanrlrfc:user_defined_operator_overloads [2022/01/17 01:16] (current) – closed voting jordanrl
Line 3: Line 3:
   * Date: 2021-08-14   * Date: 2021-08-14
   * Author: Jordan LeDoux, jordan.ledoux@gmail.com   * Author: Jordan LeDoux, jordan.ledoux@gmail.com
-  * Status: Under Discussion+  * Status: Declined
   * First Published at: http://wiki.php.net/rfc/user_defined_operator_overloads   * First Published at: http://wiki.php.net/rfc/user_defined_operator_overloads
  
Line 101: Line 101:
 This is avoided by allowing the restrictions on operator names to be separated from the restrictions on function names. This is avoided by allowing the restrictions on operator names to be separated from the restrictions on function names.
  
-=== Non-Callable ===+=== Callable ===
  
-Operand implementations cannot be called on an instance of an object the way normal methods can.+Operand implementations can be called on an instance of an object the way normal methods can.
  
 <code php> <code php>
-// These all should result in an error+// These all will work normally 
 +$op = '+'; 
 +$callable = [$obj, '+']; 
 + 
 +// Calls on the object variable
 $obj->{'+'}(1, OperandPosition::LeftSide); $obj->{'+'}(1, OperandPosition::LeftSide);
 +$obj->$op(1, OperandPosition::LeftSide);
 +$callable(1, OperandPosition::LeftSide);
 +
 +// Calls using call_user_func
 call_user_func([$obj, '+'], 1, OperandPosition::LeftSide); call_user_func([$obj, '+'], 1, OperandPosition::LeftSide);
 +call_user_func($callable, 1, OperandPosition::LeftSide);
 +
 +// This will error since + is not static
 call_user_func('ObjClass::+', 1, OperandPosition::LeftSide); call_user_func('ObjClass::+', 1, OperandPosition::LeftSide);
 </code> </code>
  
-They can be directly invoked with a Closure however. This is to fully support Reflection, and to allow direct calls while still making it obvious to PHP developers that they should not be treating these as normal methods.+They can be also be directly invoked with a Closure however. This fully supports Reflection, and allows direct calls.
  
 <code php> <code php>
Line 702: Line 713:
  
 It is listed as a separate RFC because it is something that could be delivered whether or not this RFC passes. It is listed as a separate RFC because it is something that could be delivered whether or not this RFC passes.
- 
-===== Proposed Voting Choices ===== 
-Add limited user-defined operator overloads as described: yes/no. A 2/3 vote is required to pass.  
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
Line 716: Line 724:
   - a link to the language specification section (if any)   - a link to the language specification section (if any)
  
-===== References =====+===== Proposed Voting Choices ===== 
 +Add limited user-defined operator overloads as described: yes/no. A 2/3 vote is required to pass.  
 + 
 +===== Vote ===== 
 + 
 +Voting started 2022-01-03 at 00:15 UTC and will end 2022-01-17 at 00:15 UTC.
  
 +<doodle title="Adopt user defined operator overloads as described?" auth="jordanrl" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
  
 ===== Changelog ===== ===== Changelog =====
rfc/user_defined_operator_overloads.1639628374.txt.gz · Last modified: 2021/12/16 04:19 by jordanrl