From 787450e773249e0cadb739dc4342226816b7189a Mon Sep 17 00:00:00 2001 From: thinkverse Date: Thu, 29 Apr 2021 00:37:28 +0200 Subject: [PATCH 1/6] Add TypeError to changelog --- reference/array/functions/count.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index 3e9c1f4f7ef3..af5deaedb73b 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -145,6 +145,13 @@ echo count($food); // output 2 + + 8.0.0 + + count will now throw TypeError on + invalid countable types passed to the value parameter. + + 7.2.0 From df4cd2d1e12fbfb22c999de4361a128cfbad5e4f Mon Sep 17 00:00:00 2001 From: thinkverse Date: Thu, 29 Apr 2021 00:41:31 +0200 Subject: [PATCH 2/6] Update example for count to show TypeError --- reference/array/functions/count.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index af5deaedb73b..4d62d60bde73 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -104,6 +104,8 @@ var_dump(count(false)); int(3) int(3) +Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable .. on line 12 // as of PHP 8.0 + Warning: count(): Parameter must be an array or an object that implements Countable in … on line 12 // as of PHP 7.2 int(0) From e120de116086fbbefddc18db36a7f742c67d575d Mon Sep 17 00:00:00 2001 From: thinkverse Date: Thu, 29 Apr 2021 13:03:35 +0200 Subject: [PATCH 3/6] Add PHP 7.2 to example outputs --- language-snippets.ent | 2 ++ 1 file changed, 2 insertions(+) diff --git a/language-snippets.ent b/language-snippets.ent index aa0691265f41..c19b90ef1183 100644 --- a/language-snippets.ent +++ b/language-snippets.ent @@ -521,6 +521,8 @@ currently not documented; only its argument list is available. Output of the above example in PHP 7.1:'> +Output of the above example in PHP 7.2:'> + Output of the above example in PHP 7.3:'> Output of the above example in PHP 8:'> From 1fd11dc9553b94b119679b4ab7b5710593386396 Mon Sep 17 00:00:00 2001 From: thinkverse Date: Thu, 29 Apr 2021 13:04:06 +0200 Subject: [PATCH 4/6] Split example outputs into separate PHP versions --- reference/array/functions/count.xml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index 4d62d60bde73..efd5312a1a34 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -103,14 +103,30 @@ var_dump(count(false)); + + &example.outputs.72; + + + + &example.outputs.8; + + From becd632e2b50870616664af6747cc3a045f6e014 Mon Sep 17 00:00:00 2001 From: thinkverse Date: Thu, 29 Apr 2021 13:45:09 +0200 Subject: [PATCH 5/6] Remove redundant PHP version comments --- reference/array/functions/count.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index efd5312a1a34..683de5d6be29 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -113,10 +113,10 @@ int(1) int(3) int(3) -Warning: count(): Parameter must be an array or an object that implements Countable in … on line 12 // as of PHP 7.2 +Warning: count(): Parameter must be an array or an object that implements Countable in … on line 12 int(0) -Warning: count(): Parameter must be an array or an object that implements Countable in … on line 14 // as of PHP 7.2 +Warning: count(): Parameter must be an array or an object that implements Countable in … on line 14 int(1) ]]> @@ -126,7 +126,7 @@ int(1) int(3) int(3) -Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable .. on line 12 // as of PHP 8.0 +Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable .. on line 12 ]]> From 7c0b7db56a45a843055be5f20d7c9b8c3b83dc27 Mon Sep 17 00:00:00 2001 From: thinkverse Date: Thu, 29 Apr 2021 14:12:41 +0200 Subject: [PATCH 6/6] Split examples into good and bad examples --- reference/array/functions/count.xml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index 683de5d6be29..241a65e5a8e4 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -87,6 +87,28 @@ $a[1] = 3; $a[2] = 5; var_dump(count($a)); +$b[0] = 7; +$b[5] = 9; +$b[10] = 11; +var_dump(count($b)); +?> +]]> + + &example.outputs; + + + + + + + + <function>count</function> non Countable|array example (bad example - don't do this) + + @@ -111,7 +132,6 @@ int(1)