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
Last revisionBoth sides next revision
rfc:counting_non_countables [2016/10/11 09:46] – Convert markdown to wikitext duncan3dcrfc:counting_non_countables [2017/09/22 13:28] – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: Counting of non-countable objects ====== ====== PHP RFC: Counting of non-countable objects ======
-  * Version: 0.2+  * Version: 0.4
   * Date: 2016-10-04   * Date: 2016-10-04
-  * Author: Craig Duncan <git@duncanc.co.uk>+  * Author: Craig Duncan <php@duncanc.co.uk>
   * Proposed version: PHP 7.2   * Proposed version: PHP 7.2
-  * Status: Under Discussion+  * Status: Accepted
   * ML thread: http://externals.io/thread/350   * ML thread: http://externals.io/thread/350
  
Line 19: Line 19:
  
     foreach ($iterable as $value) {     foreach ($iterable as $value) {
-        handle_value($val);+        handle_value($value);
     }     }
 } }
Line 27: Line 27:
 ===== Proposal ===== ===== Proposal =====
  
-This RFC proposes deprecating count with a parameter that is a scalar or an object that doesn't implement Countable.+This RFC proposes adding a warning when calling ''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 //Note that the sizeof alias is also affected.// http://php.net/manual/en/function.sizeof.php
Line 33: Line 33:
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
  
-Nonedeprecating features does not break BC.+The call to ''count()'' will still return 1 (or 0 for null) so backwards compatibility is maintained. 
 + 
 +Environments that display warnings or convert them to more severe errors/exceptions would be affectedbut this should just bring attention to a bug in the code.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
  
 PHP 7.2 PHP 7.2
- 
-===== Open Issues ===== 
- 
-  * At the moment ''count(null)'' returns ''0'', should this be deprecated too 
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
Line 47: Line 45:
 Simple Yes/No vote that doesn't change the language itself so requires 50% + 1 votes to get 'accepted' Simple Yes/No vote that doesn't change the language itself so requires 50% + 1 votes to get 'accepted'
  
-===== Patches and Tests =====+===== Vote =====
  
-Patch to handle the change: +<doodle title="Counting of non-countable objects" auth="duncan3dc" voteType="single" closed="true"> 
-https://github.com/duncan3dc/php-src/commit/d253a1680361e63d070b324cf5a33493120f8050+   * Yes 
 +   * No 
 +</doodle>
  
-Example tests+===== Implementation ===== 
-https://github.com/duncan3dc/php-src/commit/46a4f0061956f27ec195e3d497005a0a8c00ceb6+ 
 +Pull request to handle the change
 +https://github.com/php/php-src/pull/2185
  
 =====References ===== =====References =====
Line 59: Line 61:
 Initial discussion that led to this RFC's creation: Initial discussion that led to this RFC's creation:
 https://github.com/php/php-src/pull/1672 https://github.com/php/php-src/pull/1672
 +
 +Discussion thread:
 +http://externals.io/thread/350
 +
 +Voting thread:
 +http://externals.io/thread/409
  
rfc/counting_non_countables.txt · Last modified: 2018/03/01 23:26 by carusogabriel