我正在关注这个包装
我有这个错误:Catchable fatal error: Argument 1 passed to XeroPHP\Models\Accounting\Invoice::setDueDate() must implement interface DateTimeInterface, string given
这是我的代码:
try{
$lineitem = new LineItem($this->_xi);
$lineitem->setAccountCode('200')
->setQuantity('5.400')
->setDescription('this is awesome test')
->setUnitAmount('9900.00');
$contact = new Contact($this->_xi);
$contact->setName("John Doe")
->setFirstName("John")
->setLastName("Doe")
->setEmailAddress("johngwapo@hot.com")
->setContactStatus(Contact::CONTACT_STATUS_ACTIVE);
$invoice = new Invoice($this->_xi);
$invoice->setType(Invoice::INVOICE_TYPE_ACCREC)
->setStatus(Invoice::INVOICE_STATUS_AUTHORISED)
->setContact($contact)
//->setDate(\DateTimeInterface::format("Y-m-d"))
->setDueDate("2018-09-09")
->setLineAmountType(Invoice::LINEAMOUNT_TYPE_EXCLUSIVE)
->addLineItem($lineitem)
->setInvoiceNumber('10')
->save();
}catch ( Exception $e ){
$GLOBALS['log']->fatal('[Xero-createContact]-' . $e->getMessage());
echo $e->getMessage();
}
当我尝试这样做时:
->setDueDate(\DateTimeInterface::format("Y-m-d"))
我得到了这个错误:致命错误:不能静态调用非静态方法 DateTimeInterface::format(),假设 $this 来自不兼容的上下文
这是我调用的 setDueDate 函数:
/**
* @param \DateTimeInterface $value
* @return Invoice
*/
public function setDueDate(\DateTimeInterface $value)
{
$this->propertyUpdated('DueDate', $value);
$this->_data['DueDate'] = $value;
return $this;
}
对于如何使用此 DateTimeInterface 以及如何使用它设置未来日期以及如何解决所有这些错误,我真的很迷茫。