Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
"ext-libxml": "Needed for XSD validation"
},
"require-dev": {
"phpunit/phpunit": "^12.2",
"ext-libxml": "*",
"friendsofphp/php-cs-fixer": "^v3.75",
"phpstan/phpstan": "^2.1",
"symfony/finder": "^5.4 || ^7.0",
"phpstan/phpstan-strict-rules": "^2.0"
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^12.2",
"rector/rector": "^2.2",
"symfony/finder": "^5.4 || ^7.0"
},
"autoload": {
"psr-4": {
Expand Down
62 changes: 61 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\BooleanAnd\RepeatedAndNotEqualToNotInArrayRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
// uncomment to reach your current PHP version
->withPhpSets()
->withPreparedSets(
deadCode: true,
codeQuality: true,
phpunitCodeQuality: true,
)
->withComposerBased(
phpunit: true
)
->withSkip([
PreferPHPUnitThisCallRector::class,
RepeatedAndNotEqualToNotInArrayRector::class,
RemoveUnusedPromotedPropertyRector::class => __DIR__ . '/src/zugferd10/Model/ContextParameterID.php',
])
;
2 changes: 1 addition & 1 deletion src/zugferd10/Model/AllowanceCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class AllowanceCharge
* @var TradeTax[]
*/
#[JMS\Type('array<Easybill\ZUGFeRD\Model\Trade\Tax\TradeTax>')]
#[JMS\XmlList(inline: true, entry: 'CategoryTradeTax', namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
#[JMS\XmlList(entry: 'CategoryTradeTax', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
private $categoryTradeTaxes;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/zugferd10/Model/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Header
* @var Note[]
*/
#[Type('array<Easybill\ZUGFeRD\Model\Note>')]
#[XmlList(inline: true, entry: 'IncludedNote', namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
#[XmlList(entry: 'IncludedNote', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
private $notes = [];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/zugferd10/Model/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getSubjectCode()
public function setSubjectCode($subjectCode)
{
if ($subjectCode !== null
&& strlen($subjectCode) > 0
&& (string)$subjectCode !== ''
&& $subjectCode !== 'REG'
&& $subjectCode !== 'AAK'
&& $subjectCode !== 'AAJ'
Expand Down
2 changes: 1 addition & 1 deletion src/zugferd10/Model/Trade/Agreement.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Agreement
* @var ReferencedDocument[]
*/
#[Type('array<Easybill\ZUGFeRD\Model\Trade\ReferencedDocument>')]
#[XmlList(inline: true, entry: 'AdditionalReferencedDocument', namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
#[XmlList(entry: 'AdditionalReferencedDocument', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
private $additionalReferencedDocuments;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/zugferd10/Model/Trade/Item/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Price
* @var AllowanceCharge[]
*/
#[JMS\Type('array<Easybill\ZUGFeRD\Model\AllowanceCharge>')]
#[JMS\XmlList(inline: true, entry: 'AppliedTradeAllowanceCharge', namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
#[JMS\XmlList(entry: 'AppliedTradeAllowanceCharge', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
private $allowanceCharges = [];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/zugferd10/Model/Trade/TradeParty.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(#[Type('string')]
* @var TaxRegistration[]
*/
#[Type('array<Easybill\ZUGFeRD\Model\Trade\Tax\TaxRegistration>')]
#[XmlList(inline: true, entry: 'SpecifiedTaxRegistration', namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
#[XmlList(entry: 'SpecifiedTaxRegistration', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12')]
private array $taxRegistrations = [], ?TradeContact $definedTradeContact = null)
{
$this->definedTradeContact = $definedTradeContact;
Expand Down
4 changes: 2 additions & 2 deletions src/zugferd2/Model/DocumentLineDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class DocumentLineDocument
#[Type('string')]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
#[SerializedName('LineStatusCode')]
public ?string $lineStatusCode;
public ?string $lineStatusCode = null;

#[Type('string')]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
#[SerializedName('LineStatusReasonCode')]
public ?string $lineStatusReasonCode;
public ?string $lineStatusReasonCode = null;

/** @var Note[] */
#[Type('array<Easybill\ZUGFeRD2\Model\Note>')]
Expand Down
2 changes: 1 addition & 1 deletion src/zugferd2/Model/HeaderTradeAgreement.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class HeaderTradeAgreement
#[Type(ReferencedDocument::class)]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
#[SerializedName('SellerOrderReferencedDocument')]
public ?ReferencedDocument $sellerOrderReferencedDocument;
public ?ReferencedDocument $sellerOrderReferencedDocument = null;

#[Type(ReferencedDocument::class)]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
Expand Down
2 changes: 1 addition & 1 deletion tests/zugferd10/Tests/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
use Easybill\ZUGFeRD\SchemaValidator;
use PHPUnit\Framework\TestCase;

class BuilderTest extends TestCase
final class BuilderTest extends TestCase
{
/**
* @before
Expand Down
2 changes: 1 addition & 1 deletion tests/zugferd10/Tests/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Easybill\ZUGFeRD\Reader;
use PHPUnit\Framework\TestCase;

class ReaderTest extends TestCase
final class ReaderTest extends TestCase
{
/**
* @before
Expand Down
6 changes: 3 additions & 3 deletions tests/zugferd2/Tests/Legacy/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
use Easybill\ZUGFeRD2\Validator;
use PHPUnit\Framework\TestCase;

class BuilderTest extends TestCase
final class BuilderTest extends TestCase
{
public function testBuildXRechnungExample(): void
{
Expand Down Expand Up @@ -201,7 +201,7 @@ public function testBuildXRechnungExample(): void
$referenceFile = (string)file_get_contents(__DIR__ . '/official_example_xml/zugferd_2p1_XRECHNUNG_Einfach.xml');
$referenceFile = ReaderAndBuildTest::reformatXml($referenceFile);
$xml = ReaderAndBuildTest::reformatXml($xml);
self::assertEquals($referenceFile, $xml);
self::assertSame($referenceFile, $xml);

$result = (new Validator())->validateAgainstXsd($xml, Validator::SCHEMA_EN16931);
self::assertNull($result, $result ?? '');
Expand Down Expand Up @@ -392,7 +392,7 @@ public function testBuildXRechnungExtendedExample(): void
$referenceFile = (string)file_get_contents(__DIR__ . '/official_example_xml/zugferd_2p1_XRECHNUNG_Extended.xml');
$referenceFile = ReaderAndBuildTest::reformatXml($referenceFile);
$xml = ReaderAndBuildTest::reformatXml($xml);
self::assertEquals($referenceFile, $xml);
self::assertSame($referenceFile, $xml);

$result = (new Validator())->validateAgainstXsd($xml, Validator::SCHEMA_EXTENDED);
self::assertNull($result, $result ?? '');
Expand Down
14 changes: 6 additions & 8 deletions tests/zugferd2/Tests/Legacy/ReaderAndBuildTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class ReaderAndBuildTest extends TestCase
final class ReaderAndBuildTest extends TestCase
{
use ReformatXmlTrait;

Expand All @@ -28,14 +28,12 @@ public function testGetDocument(string $filename): void
}

/**
* @return string[][]
* @return \Iterator<(int | string), array<string>>
*/
public static function dataProvider(): array
public static function dataProvider(): \Iterator
{
return [
['zugferd_2p1_BASIC-WL_Einfach.xml'],
['zugferd_2p1_EN16931_Einfach.xml'],
['zugferd_2p1_XRECHNUNG_Einfach.xml'],
];
yield ['zugferd_2p1_BASIC-WL_Einfach.xml'];
yield ['zugferd_2p1_EN16931_Einfach.xml'];
yield ['zugferd_2p1_XRECHNUNG_Einfach.xml'];
}
}
Loading