Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Faker/Provider/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static function numberBetween($int1 = 0, $int2 = 2147483647)
$max = $int1 < $int2 ? $int2 : $int1;
return mt_rand($min, $max);
}

/**
* Returns the passed value
*
Expand Down Expand Up @@ -354,6 +354,7 @@ private static function replaceWildcard($string, $wildcard = '#', $callback = 's
}
for ($i = $pos, $last = strrpos($string, $wildcard, $pos) + 1; $i < $last; $i++) {
if ($string[$i] === $wildcard) {
$callback = str_replace('static::' , self::class.'::' , $callback);
$string[$i] = call_user_func($callback);
}
}
Expand Down Expand Up @@ -500,9 +501,9 @@ public static function regexify($regex = '')
return Base::randomElement(str_split($matches[1]));
}, $regex);
// replace \d with number and \w with letter and . with ascii
$regex = preg_replace_callback('/\\\w/', 'static::randomLetter', $regex);
$regex = preg_replace_callback('/\\\d/', 'static::randomDigit', $regex);
$regex = preg_replace_callback('/(?<!\\\)\./', 'static::randomAscii', $regex);
$regex = preg_replace_callback('/\\\w/', self::class.'::'.'randomLetter', $regex);
$regex = preg_replace_callback('/\\\d/', self::class.'::'.'randomDigit', $regex);
$regex = preg_replace_callback('/(?<!\\\)\./', self::class.'::'.'randomAscii', $regex);
// remove remaining backslashes
$regex = str_replace('\\', '', $regex);
// phew
Expand Down