在 phpunit 的数据提供者中使用 yield 让变量更具可读性
改进前
public function test(int $a, int $b, int $c)
{
//
}
public function provider()
{
return [
[1, 2, 3],
[4, 3, 1],
[2, 2, 2]
];
}
改进后
public function test(int $a, int $b, int $c)
{
//
}
public function provider()
{
yield [1, 2, 3];
yield [4, 3, 1];
yield [2, 2, 2];
}
本作品采用《CC 协议》,转载必须注明作者和本文链接