mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Promote warnings to errors in str_repeat()
This commit is contained in:
parent
bba7f38c4f
commit
1059e3dc39
5 changed files with 28 additions and 7 deletions
|
@ -7,10 +7,7 @@ if (!function_exists('mb_ereg')) die('skip mbregex support not available');
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
var_dump(mb_ereg_search_init(NULL));
|
||||||
$v1=str_repeat("#", -1);
|
|
||||||
var_dump(mb_ereg_search_init($v1));
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Warning: str_repeat(): Second argument has to be greater than or equal to 0 in %sbug73646.php on line %d
|
|
||||||
bool(true)
|
bool(true)
|
||||||
|
|
|
@ -14,7 +14,9 @@ function bar() {
|
||||||
}
|
}
|
||||||
function foo() {
|
function foo() {
|
||||||
try { return bar(); }
|
try { return bar(); }
|
||||||
finally { @str_repeat("foo", -10); }
|
finally {
|
||||||
|
@fopen("non-existent", 'r');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var_dump(foo());
|
var_dump(foo());
|
||||||
|
|
|
@ -5363,7 +5363,7 @@ PHP_FUNCTION(str_repeat)
|
||||||
ZEND_PARSE_PARAMETERS_END();
|
ZEND_PARSE_PARAMETERS_END();
|
||||||
|
|
||||||
if (mult < 0) {
|
if (mult < 0) {
|
||||||
php_error_docref(NULL, E_WARNING, "Second argument has to be greater than or equal to 0");
|
zend_throw_error(NULL, "Second argument has to be greater than or equal to 0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
22
ext/standard/tests/strings/str_repeat_variation1.phpt
Normal file
22
ext/standard/tests/strings/str_repeat_variation1.phpt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
--TEST--
|
||||||
|
Test str_repeat() function: usage variations - complex strings containing other than 7-bit chars
|
||||||
|
--INI--
|
||||||
|
precision=14
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$str = chr(0).chr(128).chr(129).chr(234).chr(235).chr(254).chr(255);
|
||||||
|
|
||||||
|
$withCodePoint = str_repeat($str, chr(51)); // ASCII value of '3' given
|
||||||
|
$explicit = str_repeat($str, 3);
|
||||||
|
|
||||||
|
var_dump($withCodePoint === $explicit);
|
||||||
|
var_dump( bin2hex( $withCodePoint ) );
|
||||||
|
var_dump( bin2hex( $explicit ) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
DONE
|
||||||
|
--EXPECT--
|
||||||
|
bool(true)
|
||||||
|
string(42) "008081eaebfeff008081eaebfeff008081eaebfeff"
|
||||||
|
string(42) "008081eaebfeff008081eaebfeff008081eaebfeff"
|
||||||
|
DONE
|
Loading…
Add table
Add a link
Reference in a new issue