PHP单元注意事项:数组到字符串的转换


PHP Unit Notice: Array to string conversion

我在PHP中使用strtotime()来获取一周中的天数(我制作了一个日历,具有不同的视图,因此它会发生变化)。每当我尝试以下操作时,PHP Unit就会给我数组到字符串转换的警告:

$monday  = date('Y-m-d', strtotime($sunday . '+ 1 day'));

$sunday是一个变量,我是这样得到的:

public function GetWeekRange($date) {
        $ts = strtotime($date);
        $start = (date('w', $ts) == 0) ? $ts : strtotime('last sunday', $ts);
        return date('Y-m-d', $start);
}

和$date是格式为'YYYY-mm-dd'的字符串

我不知道为什么我得到这个错误,代码工作得很好,但是测试给出了这个警告,它会在我的环境中给出一个警告,所有不同的项目都显示(红/绿取决于是否有一个失败)。

谢谢,

拿来

新手错误:我更新了函数,只返回一个字符串,但是我将模拟值保留为数组。

我的坏。