Skip to content

Commit

Permalink
update rector config
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-sainthillier committed Sep 28, 2024
1 parent 79d2d0c commit 288af58
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
7 changes: 4 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
use Rector\Config\RectorConfig;
use Rector\Symfony\Set\JMSSetList;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector;

return RectorConfig::configure()
->withImportNames()
->withPaths([
__DIR__ . '/src/zugferd2',
__DIR__ . '/tests/zugferd2',
])
->withPhpSets(php81: true)
->withPhpSets()
->withPreparedSets(codeQuality: true, deadCode: true)
->withRules([
ReturnTypeFromStrictNativeCallRector::class,
ReturnTypeFromStrictScalarReturnExprRector::class,
])
->withSets([
JMSSetList::ANNOTATIONS_TO_ATTRIBUTES,
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 @@ -67,7 +67,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(ProcuringProject::class)]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
Expand Down
2 changes: 1 addition & 1 deletion src/zugferd2/Model/LineTradeDelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LineTradeDelivery
#[Type(Quantity::class)]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
#[SerializedName('PackageQuantity')]
public ?Quantity $packageQuantity;
public ?Quantity $packageQuantity = null;

#[Type(SupplyChainEvent::class)]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
Expand Down
2 changes: 1 addition & 1 deletion src/zugferd2/Model/ProductType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ProductType
#[Type(Id::class)]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
#[SerializedName('GlobalID')]
public ?Id $id;
public ?Id $id = null;

#[Type('string')]
#[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')]
Expand Down
4 changes: 3 additions & 1 deletion src/zugferd2/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Easybill\ZUGFeRD2;

use DOMDocument;

class Validator
{
public const SCHEMA_BASIC = __DIR__ . '/Schema/BASIC/Factur-X_1.0.07_BASIC.xsd';
Expand All @@ -14,7 +16,7 @@ class Validator

public function validateAgainstXsd(string $xml, string $schemaFile): ?string
{
$domDoc = new \DOMDocument();
$domDoc = new DOMDocument();
$domDoc->loadXML($xml);

try {
Expand Down
4 changes: 2 additions & 2 deletions tests/zugferd2/Tests/Legacy/TradeAccountingAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testTradeAccountingAccount(): void

$invoice->supplyChainTradeTransaction->lineItems[] = $item1;

$xml = <<<'XML'
$xml = <<<'XML_WRAP'
<?xml version="1.0" encoding="UTF-8"?>
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
<rsm:ExchangedDocumentContext>
Expand Down Expand Up @@ -107,7 +107,7 @@ public function testTradeAccountingAccount(): void
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>
XML;
XML_WRAP;
$this->assertEquals(
// Removes white-space
preg_replace('/\s/', '', $xml),
Expand Down
4 changes: 3 additions & 1 deletion tests/zugferd2/Tests/Traits/ReformatXmlTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

namespace Easybill\ZUGFeRD2\Tests\Traits;

use DOMDocument;

trait ReformatXmlTrait
{
public static function reformatXml(string $xml): string
{
$xml = preg_replace('/<!--(.|\s)*?-->/', '', $xml);

$doc = new \DOMDocument('1.0', 'UTF-8');
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->preserveWhiteSpace = false;
$doc->formatOutput = true;
$doc->loadXML($xml);
Expand Down

0 comments on commit 288af58

Please sign in to comment.