rfc:counting_non_countables

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:counting_non_countables [2016/10/04 09:40] – Added mailing list link duncan3dcrfc:counting_non_countables [2016/10/17 20:47] – Remove the outstanding question about count(null) duncan3dc
Line 1: Line 1:
 ====== PHP RFC: Counting of non-countable objects ====== ====== PHP RFC: Counting of non-countable objects ======
-  * Version: 0.1+  * Version: 0.3
   * Date: 2016-10-04   * Date: 2016-10-04
   * Author: Craig Duncan <git@duncanc.co.uk>   * Author: Craig Duncan <git@duncanc.co.uk>
Line 9: Line 9:
 ===== Introduction ===== ===== Introduction =====
  
-Calling ''count()'' on an object that doesn't implement the Countable interface (http://php.net/manual/en/class.countable.php) returns 1.+Calling ''count()'' on a scalar or object that doesn't implement the Countable interface (http://php.net/manual/en/class.countable.php) returns 1.
 There are no known use cases for this, and it can easily hide bugs, take the following example: There are no known use cases for this, and it can easily hide bugs, take the following example:
 <code php> <code php>
Line 27: Line 27:
 ===== Proposal ===== ===== Proposal =====
  
-This RFC proposes raising a warning when attempting to count an object that doesn't implement Countable.+This RFC proposes deprecating count with a parameter that is a scalar, null, or an object that doesn't implement Countable. 
 + 
 +//Note that the sizeof alias is also affected.// http://php.net/manual/en/function.sizeof.php
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
  
-Counting objects that don't implement the Countable interface will still workso the only BC will be in cases where userland convert warnings to Exceptions.+Nonedeprecating features does not break BC.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
  
 PHP 7.2 PHP 7.2
- 
-===== Open Issues ===== 
- 
-  * Should we deprecate instead, and then disable in 8.0 
-  * Does introducing a warning in a minor release qualify as breaking BC 
- 
-===== Unaffected PHP Functionality ===== 
- 
-Counting scalars is unaffected and will still return ''1''. 
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
Line 53: Line 46:
  
 Patch to handle the change: Patch to handle the change:
-https://github.com/duncan3dc/php-src/commit/73f6dfbf1eefa65f3a0aa9156bcad1291520f0ea+https://github.com/duncan3dc/php-src/commit/d253a1680361e63d070b324cf5a33493120f8050
  
-Example test+Example tests
-https://github.com/duncan3dc/php-src/commit/2741d8f518f6e0963c9a98a1e8954bee81e23e1b+https://github.com/duncan3dc/php-src/commit/46a4f0061956f27ec195e3d497005a0a8c00ceb6
  
 =====References ===== =====References =====
rfc/counting_non_countables.txt · Last modified: 2018/03/01 23:26 by carusogabriel