私はこのラッパーに従っています
次のエラーがあります: 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 from incompatible contextを想定しています
これは、私が呼び出している setDueDate の関数です。
/**
* @param \DateTimeInterface $value
* @return Invoice
*/
public function setDueDate(\DateTimeInterface $value)
{
$this->propertyUpdated('DueDate', $value);
$this->_data['DueDate'] = $value;
return $this;
}
この DateTimeInterface をどのように使用するか、それを使用して将来の日付を設定する方法、およびこのすべてのエラーを解決する方法について、ここで本当に迷っています。