Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

Commit bd42144

Browse files
committed
Fix regexify on PHP 5.3
1 parent 430c066 commit bd42144

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Faker/Provider/Base.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,15 @@ public static function regexify($regex = '')
434434
return static::randomElement(str_split($matches[1]));
435435
}, $regex);
436436
// replace \d with number and \w with letter and . with ascii
437-
$regex = preg_replace_callback('/\\\w/', 'static::randomLetter', $regex);
438-
$regex = preg_replace_callback('/\\\d/', 'static::randomDigit', $regex);
439-
$regex = preg_replace_callback('/(?<!\\\)\./', 'static::randomAscii', $regex);
437+
$regex = preg_replace_callback('/\\\w/', function() {
438+
return static::randomLetter();
439+
}, $regex);
440+
$regex = preg_replace_callback('/\\\d/', function() {
441+
return static::randomDigit();
442+
}, $regex);
443+
$regex = preg_replace_callback('/(?<!\\\)\./', function() {
444+
return static::randomAscii();
445+
}, $regex);
440446
// remove remaining backslashes
441447
$regex = str_replace('\\', '', $regex);
442448
// phew

0 commit comments

Comments
 (0)