Skip to content

Commit f51421c

Browse files
committed
Promote warnings to errors in chunk_split()
1 parent fdff6cf commit f51421c

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,8 +2194,8 @@ PHP_FUNCTION(chunk_split)
21942194
ZEND_PARSE_PARAMETERS_END();
21952195

21962196
if (chunklen <= 0) {
2197-
php_error_docref(NULL, E_WARNING, "Chunk length should be greater than zero");
2198-
RETURN_FALSE;
2197+
zend_throw_error(NULL, "Chunk length should be greater than zero");
2198+
return;
21992199
}
22002200

22012201
if ((size_t)chunklen > ZSTR_LEN(str)) {
Binary file not shown.

ext/standard/tests/strings/chunk_split_variation8.phpt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ for($count = 0; $count < count($values); $count++) {
5050
var_dump( chunk_split($heredoc_str, $values[$count], $ending) );
5151
} catch (TypeError $e) {
5252
echo $e->getMessage(), "\n";
53+
} catch (\Error $e) {
54+
echo $e->getMessage() . "\n";
5355
}
5456
}
5557

@@ -58,18 +60,14 @@ echo "Done"
5860
--EXPECTF--
5961
*** Testing chunk_split() : different 'chunklen' with heredoc 'str' ***
6062
-- Iteration 1 --
61-
62-
Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
63-
bool(false)
63+
Chunk length should be greater than zero
6464
-- Iteration 2 --
6565
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::: :::
6666
::: :::w:::h:::i:::t:::e::: :::s:::p:::a:::c:::e::: :::c:::h:::a:::r:::.:::
6767
:::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:::
6868
:::c:::h:::u:::n:::k:::_:::s:::p:::l:::i:::t:::(:::):::"
6969
-- Iteration 3 --
70-
71-
Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
72-
bool(false)
70+
Chunk length should be greater than zero
7371
-- Iteration 4 --
7472
string(129) "This's heredoc string with and
7573
white space char.
@@ -88,7 +86,5 @@ chunk_split():::"
8886
-- Iteration 7 --
8987
chunk_split() expects parameter 2 to be int, float given
9088
-- Iteration 8 --
91-
92-
Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d
93-
bool(false)
89+
Chunk length should be greater than zero
9490
Done

0 commit comments

Comments
 (0)