From 95f6636b6d7aeb095d48d03721fab17bde1fb4a5 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 22 Aug 2019 12:14:02 +0200 Subject: [PATCH] Promote warnings to errors in chunk_split() --- ext/standard/string.c | 4 ++-- .../tests/strings/chunk_split_variation5.phpt | Bin 2321 -> 2219 bytes .../tests/strings/chunk_split_variation8.phpt | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index c2f29baec7732..cbdf6efb2a969 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2194,8 +2194,8 @@ PHP_FUNCTION(chunk_split) ZEND_PARSE_PARAMETERS_END(); if (chunklen <= 0) { - php_error_docref(NULL, E_WARNING, "Chunk length should be greater than zero"); - RETURN_FALSE; + zend_throw_error(NULL, "Chunk length should be greater than zero"); + return; } if ((size_t)chunklen > ZSTR_LEN(str)) { diff --git a/ext/standard/tests/strings/chunk_split_variation5.phpt b/ext/standard/tests/strings/chunk_split_variation5.phpt index 8650f2cb92f8093bdebd4098c9f64871aeb50685..bea49d24b48923832a447ba07d197f477c4f7d6f 100644 GIT binary patch delta 71 zcmbOzv|4b(B^Ggov2td){n;fY0gnR)3}3dtFzdD-#B1v!}|8k$xLlWRFNWEC>=6jX~9 x^79mOGV@XuR8zQ;^7C^v(h_ruQ#CiQXXRw1$bbiIa|sxrjMoKRF8O(>TmWf>Le~HQ diff --git a/ext/standard/tests/strings/chunk_split_variation8.phpt b/ext/standard/tests/strings/chunk_split_variation8.phpt index 9804ee21e13f7..15c224962e103 100644 --- a/ext/standard/tests/strings/chunk_split_variation8.phpt +++ b/ext/standard/tests/strings/chunk_split_variation8.phpt @@ -50,6 +50,8 @@ for($count = 0; $count < count($values); $count++) { var_dump( chunk_split($heredoc_str, $values[$count], $ending) ); } catch (TypeError $e) { echo $e->getMessage(), "\n"; + } catch (\Error $e) { + echo $e->getMessage() . "\n"; } } @@ -58,18 +60,14 @@ echo "Done" --EXPECTF-- *** Testing chunk_split() : different 'chunklen' with heredoc 'str' *** -- Iteration 1 -- - -Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d -bool(false) +Chunk length should be greater than zero -- Iteration 2 -- string(504) "T:::h:::i:::s:::':::s::: :::h:::e:::r:::e:::d:::o:::c::: :::s:::t:::r:::i:::n:::g::: :::w:::i:::t:::h::: ::: ::: :::a:::n:::d::: ::: ::: :::w:::h:::i:::t:::e::: :::s:::p:::a:::c:::e::: :::c:::h:::a:::r:::.::: :::I:::t::: :::h:::a:::s::: :::_:::s:::p:::e:::c:::i:::@:::l::: :::c:::h:::@:::r:::$::: :::2:::2:::2:::2::: :::!:::!:::!:::N:::o:::w::: :::\:::k::: :::a:::s::: :::e:::s:::c:::a:::p:::e::: :::c:::h:::a:::r::: :::t:::o::: :::t:::e:::s:::t::: :::c:::h:::u:::n:::k:::_:::s:::p:::l:::i:::t:::(:::):::" -- Iteration 3 -- - -Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d -bool(false) +Chunk length should be greater than zero -- Iteration 4 -- string(129) "This's heredoc string with and white space char. @@ -88,7 +86,5 @@ chunk_split():::" -- Iteration 7 -- chunk_split() expects parameter 2 to be int, float given -- Iteration 8 -- - -Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d -bool(false) +Chunk length should be greater than zero Done