在 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 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!