diff --git a/src/Fdpi/FdpiFacturX.php b/src/Fdpi/FdpiFacturX.php index 4aab00e..db8c4aa 100644 --- a/src/Fdpi/FdpiFacturX.php +++ b/src/Fdpi/FdpiFacturX.php @@ -46,7 +46,7 @@ public function __construct( $this->PDFVersion = \sprintf('%.1F', $pdfVersion); if ($binaryData) { - $this->PDFVersion .= "\n" . '%' . \chr(rand(128, 256)) . \chr(rand(128, 256)) . \chr(rand(128, 256)) . \chr(rand(128, 256)); + $this->PDFVersion .= "\n" . '%' . \chr(rand(128, 255)) . \chr(rand(128, 255)) . \chr(rand(128, 255)) . \chr(rand(128, 255)); } } @@ -150,7 +150,7 @@ protected function putFiles(): void /* * Sorting files in name order as PDF specs (if not, issue with Acrobat Reader when trying to download attachments) */ - usort($files, function ($a, $b) { + usort($files, static function ($a, $b) { return strcmp($a['name'], $b['name']); }); @@ -199,12 +199,12 @@ public function addXmlMetadata(): void 'Factur-X %s %s dated %s issued by %s', $this->xmlDocumentTypeName, $this->xmlInvoiceId, - $this->xmlDateTime->format('Y-m-d'), + $this->xmlDateTime->format('Ymd'), $this->xmlSeller ); $producer = 'FPDF'; $creatorTool = 'Factur-X PHP library by Tiime'; - $timestamp = (new \DateTime('now', new \DateTimeZone('UTC')))->format('Y-m-d\TH:i:sP'); + $dt = new \DateTimeImmutable('now', new \DateTimeZone('UTC')); $xmlString = << @@ -236,8 +236,8 @@ public function addXmlMetadata(): void {$creatorTool} - {$timestamp} - {$timestamp} + {$dt->format('c')} + {$dt->format('c')} diff --git a/src/Writer.php b/src/Writer.php index 4001337..bb02bd6 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -134,8 +134,8 @@ public function generate( $pdfWriter->SetSubject(\sprintf('Factur-X %s %s dated %s issued by %s', $documentTypeName, $invoiceId, $dateTime->format('Y-m-d'), $seller)); $pdfWriter->SetKeywords(\sprintf('%s, Factur-X', $documentTypeName)); $pdfWriter->SetCreator('Factur-X PHP library by Tiime'); - $pdfWriter->setModifiedDate($now->format('Y-m-d')); - $pdfWriter->setCreationDate($now->format('Y-m-d')); + $pdfWriter->setModifiedDate('D:' . $now->format('YmdHis') . 'Z'); + $pdfWriter->setCreationDate('D:' . $now->format('YmdHis') . 'Z'); $pageCount = $pdfWriter->setSourceFile($pdfStreamReader); diff --git a/tests/ReaderTest.php b/tests/ReaderTest.php index 22d0b9a..6241822 100644 --- a/tests/ReaderTest.php +++ b/tests/ReaderTest.php @@ -1,7 +1,5 @@