Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"name": "ybazli/faker",
"name": "bar5um/faker",
"description": "Persian fake data package for laravel",
"type": "laravel",
"license": "MIT",
"authors": [
{
"name": "ybazli",
"email": "Yashar.bazli@gmail.com"
},
{
"name": "bar5um",
"email": "bar5um@icloud.com"
}
],
"autoload": {
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Persian Faker
Persian faker package for laravel . This package is created for testing your project with fake data not for create spam. please do not use it to create spam. New options are comming soon. Enjoy it, thanks.

## PHP 8 Compatibility
This fork fixes compatibility issues with PHP 8 by removing the global `string()` helper, which caused conflicts, and replacing it with explicit `(string)` casts.

- All Faker methods (`word()`, `sentence()`, `paragraph()`, etc.) now work safely in PHP 8.
- This fork can be used directly in Laravel factories and seeders without throwing `Call to undefined function Ybazli\Faker\string()` errors.


## Installation

Expand Down
12 changes: 10 additions & 2 deletions src/Faker.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private function getRandomKey($object = null)
$name = array_rand($array);
}

return string($array[$name]);
return (string) $array[$name];
}

/**
Expand Down Expand Up @@ -126,7 +126,7 @@ public function mobile()
public function telephone()
{
$prefix = $this->getRandomKey('tellphone');
return string('0' . $prefix . randomNumber(7));
return (string) ('0' . $prefix . randomNumber(7));
}

/**
Expand Down Expand Up @@ -249,6 +249,14 @@ public function productCategory()
return $this->getRandomKey('productCategory');
}

/**
* return random persian productCategory
*/
public function product()
{
return $this->getRandomKey('product');
}


/**
* @param int $length
Expand Down
8 changes: 4 additions & 4 deletions src/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
namespace Ybazli\Faker;

// string helper
if (!function_exists('string')) {
function string($value)
{
return (string) $value;
if (!function_exists('str_cast')) {
function str_cast($value) {
return (string)$value;
}
}

//get rand int
if (!function_exists('randomNumber')) {
function randomNumber($length = 20, $int = false)
Expand Down
Loading