ErrorException:implode():弃用数组后传递胶水字符串.交换参数 [英] ErrorException : implode(): Passing glue string after array is deprecated. Swap the parameters
问题描述
正在运行Laravel 5.8并在播种时出现此错误
Am running Laravel 5.8 and getting this error when seeding
Seeding: CategoriesTableSeeder
ErrorException:implode():弃用数组后传递胶水字符串.交换参数
ErrorException : implode(): Passing glue string after array is deprecated. Swap the parameters
在/Users/saly/Sites/Saly/vendor/fzaninotto/faker/src/Faker/Provider/Lorem.php:95
at /Users/saly/Sites/Saly/vendor/fzaninotto/faker/src/Faker/Provider/Lorem.php:95
91|
92| $words = static::words($nbWords);
93| $words[0] = ucwords($words[0]);
94|
95| return implode($words, ' ') . '.';
96| }
97|
98| /**
99| * Generate an array of sentences
Exception trace:
1 implode(" ")
/Users/saly/Sites/Saly/vendor/fzaninotto/faker/src/Faker/Provider/Lorem.php:95
2 Faker\Provider\Lorem::sentence()
/Users/saly/Sites/Saly/vendor/fzaninotto/faker/src/Faker/Generator.php:222
> Please use the argument -v to see more details.
该应用正在通过PHP 7.3和7.2在CI中通过测试,因此问题可能出在我的本地计算机"OSX"中是PHP 7.4.
The app is passing tests just fine in CI using PHP 7.3 and 7.2 so the problem might be PHP 7.4 in my local machine "OSX"
这是我的种子文件
<?php
use Saly\Category;
use Illuminate\Database\Seeder;
class CategoriesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(Category::class, 3)->create();
}
}
还有工厂
<?php
use Saly\Category;
use Faker\Generator as Faker;
$factory->define(Category::class, function (Faker $faker) {
$name = $faker->sentence(4, true); // Here maybe?
return [
'name' => $name,
'slug' => sluggify($name),
];
});
我认为问题出在使用 sentence()
的那一行中,但是我不能说出解决方法,因为我只是从Faker的文档中复制了这一行
I think the problem is in the line where sentence()
is used but I can't tell how to solve it because I just copied that line from the Faker docs
此错误是什么意思,我该如何解决?
What does this error mean and how can I solve it?
推荐答案
此问题已在最新版本的Faker中修复.在您的错误提示中
This has already been fixed in the most recent version of Faker. In your error it says
> 95| return implode($words, ' ') . '.';
,但如果我们查看第95行,来源,我们看到了:
but if we look at line 95 of the source we see:
> 95| return implode(' ', $words) . '.';
因此,您可能需要做的就是拉最新版本的Faker,
So, all you need to do is pull the latest version of Faker, probably by doing
composer update fzaninotto/faker
这篇关于ErrorException:implode():弃用数组后传递胶水字符串.交换参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!