Skip to content

Commit

Permalink
[CS] Code Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Jan 18, 2025
1 parent 5381433 commit a5c8026
Show file tree
Hide file tree
Showing 18 changed files with 223 additions and 53 deletions.
2 changes: 1 addition & 1 deletion build/phprectorconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
->withPhp73Sets()
->withPreparedSets(
codeQuality: true,
codingStyle: true,
//
carbon: false,
codingStyle: false,
deadCode: false,
doctrineCodeQuality: false,
earlyReturn: false,
Expand Down
9 changes: 6 additions & 3 deletions examples/02_ZugferdDocumentPdfBuilder_EN16931.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,16 @@
function ($which) {
if ($which === 'title') {
return "DummyTitle";
}
}

if ($which === 'author') {
return "DummyAuthor";
}
}

if ($which === 'subject') {
return "DummySubject";
}
}

if ($which === 'keywords') {
return "DummyKeywords";
}
Expand Down
9 changes: 6 additions & 3 deletions examples/02_ZugferdDocumentPdfBuilder_XRECHNUNG.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,16 @@
function ($which) {
if ($which === 'title') {
return "DummyTitle";
}
}

if ($which === 'author') {
return "DummyAuthor";
}
}

if ($which === 'subject') {
return "DummySubject";
}
}

if ($which === 'keywords') {
return "DummyKeywords";
}
Expand Down
19 changes: 12 additions & 7 deletions make/genchangelog.php

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions make/gencodelists.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function strIdentifier(string $str, bool $shortIdentifier): string
$str = str_replace("\t", "", $str);
$str = strtoupper($str);
$str = preg_replace("/[^A-Za-z0-9\s]/", "", $str);

$strArray = explode(" ", $str);
if (count($strArray) == 1) {
$strNew = $strArray[0];
Expand All @@ -90,13 +91,15 @@ function strIdentifier(string $str, bool $shortIdentifier): string
if ($strNew !== "") {
$strNew .= "_";
}

if ($shortIdentifier) {
$strNew .= substr($item, 0, 4);
} else {
$strNew .= $item;
}
}
}

$strNew = preg_replace('/__+/', '_', $strNew);
$strNew = preg_replace('~\d~', '', $strNew, 5);
$strNew = rtrim(ltrim($strNew, "_"), "_");
Expand Down
71 changes: 37 additions & 34 deletions make/genmethoddocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public function getArray(): array
foreach ($types as $type) {
$parameterTypeString .= $type->getName() . '|';
}

$parameterTypeString = rtrim($parameterTypeString, '|');
} elseif ($parameterType instanceof ReflectionNamedType) {
$parameterTypeString = $parameterType->getName();
Expand Down Expand Up @@ -672,9 +673,11 @@ private function fixPhpType(string $string): string
if (stripos($string, '[]') !== false) {
$string = 'array';
}

if (stripos($string, 'array<') === 0) {
$string = 'array';
}

if ($string === '$this') {
$string = 'static';
}
Expand Down Expand Up @@ -736,38 +739,38 @@ public static function generate(array $classes, array $ignoreInheritance = [])
ZugferdQuickDescriptorXRechnung2::class => __DIR__ . '/Class-ZugferdQuickDescriptorXRechnung2.md',
ZugferdQuickDescriptorXRechnung3::class => __DIR__ . '/Class-ZugferdQuickDescriptorXRechnung3.md',
], [
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::generateDocument',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::generateDocument',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::saveDocument',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::saveDocument',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::saveDocumentInline',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::saveDocumentInline',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::downloadString',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::downloadString',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setAdditionalCreatorTool',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setAdditionalCreatorTool',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setAttachmentRelationshipType',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setAttachmentRelationshipType',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setAttachmentRelationshipTypeToData',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setAttachmentRelationshipTypeToData',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setAttachmentRelationshipTypeToAlternative',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setAttachmentRelationshipTypeToAlternative',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setAttachmentRelationshipTypeToSource',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setAttachmentRelationshipTypeToSource',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::attachAdditionalFileByRealFile',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::attachAdditionalFileByRealFile',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::attachAdditionalFileByContent',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::attachAdditionalFileByContent',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setDeterministicModeEnabled',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setDeterministicModeEnabled',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setAuthorTemplate',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setAuthorTemplate',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setKeywordTemplate',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setKeywordTemplate',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setTitleTemplate',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setTitleTemplate',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setSubjectTemplate',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setSubjectTemplate',
'horstoeko\zugferd\ZugferdDocumentPdfBuilder::setMetaInformationCallback',
'horstoeko\zugferd\ZugferdDocumentPdfMerger::setMetaInformationCallback',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::generateDocument',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::generateDocument',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::saveDocument',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::saveDocument',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::saveDocumentInline',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::saveDocumentInline',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::downloadString',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::downloadString',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setAdditionalCreatorTool',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setAdditionalCreatorTool',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setAttachmentRelationshipType',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setAttachmentRelationshipType',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setAttachmentRelationshipTypeToData',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setAttachmentRelationshipTypeToData',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setAttachmentRelationshipTypeToAlternative',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setAttachmentRelationshipTypeToAlternative',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setAttachmentRelationshipTypeToSource',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setAttachmentRelationshipTypeToSource',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::attachAdditionalFileByRealFile',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::attachAdditionalFileByRealFile',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::attachAdditionalFileByContent',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::attachAdditionalFileByContent',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setDeterministicModeEnabled',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setDeterministicModeEnabled',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setAuthorTemplate',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setAuthorTemplate',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setKeywordTemplate',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setKeywordTemplate',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setTitleTemplate',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setTitleTemplate',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setSubjectTemplate',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setSubjectTemplate',
\horstoeko\zugferd\ZugferdDocumentPdfBuilder::class . '::setMetaInformationCallback',
\horstoeko\zugferd\ZugferdDocumentPdfMerger::class . '::setMetaInformationCallback',
]);
2 changes: 2 additions & 0 deletions src/ZugferdDocumentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public function setForeignCurrency(string $foreignCurrencyCode, float $foreignTa
if ($this->getObjectHelper()->tryCallAndReturn($taxTotalAmount, "getCurrencyID") == $invoiceCurrencyCode) {
$taxTotalAmountInvoice = $taxTotalAmount;
}

if ($this->getObjectHelper()->tryCallAndReturn($taxTotalAmount, "getCurrencyID") == $foreignCurrencyCode) {
$taxTotalAmountForeign = $taxTotalAmount;
}
Expand Down Expand Up @@ -2501,6 +2502,7 @@ public function setDocumentSummation(float $grandTotalAmount, float $duePayableA
$invoiceCurrencyCode = $this->getObjectHelper()->tryCallByPathAndReturn($this->headerTradeSettlement, "getInvoiceCurrencyCode.value");
$this->getObjectHelper()->tryCall($taxTotalAmount[0], 'setCurrencyID', $invoiceCurrencyCode);
}

return $this;
}

Expand Down
7 changes: 6 additions & 1 deletion src/ZugferdDocumentPdfBuilderAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ abstract class ZugferdDocumentPdfBuilderAbstract
* 'Data', 'Alternative', 'Source', 'Supplement', 'Unspecified'
*/
public const AF_RELATIONSHIP_DATA = "Data";

public const AF_RELATIONSHIP_ALTERNATIVE = "Alternative";

public const AF_RELATIONSHIP_SOURCE = "Source";

public const AF_RELATIONSHIP_SUPPLEMENT = "Supplement";

public const AF_RELATIONSHIP_UNSPECIFIED = "Unspecified";

/**
Expand Down Expand Up @@ -566,6 +570,7 @@ private function updatePdfMetadata(): void
$descNodes->title->children('rdf', true)->Alt->li = $pdfMetadataInfos['title'];
$descNodes->creator->children('rdf', true)->Seq->li = $pdfMetadataInfos['author'];
$descNodes->description->children('rdf', true)->Alt->li = $pdfMetadataInfos['subject'];

$this->pdfWriter->addMetadataDescriptionNode($descDc->asXML());

$descAdobe = $descriptionNodes[4];
Expand Down Expand Up @@ -668,7 +673,7 @@ private function isFile($pdfData): bool
{
try {
return @is_file($pdfData);
} catch (Throwable $ex) {
} catch (Throwable $throwable) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ZugferdDocumentPdfMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private function xmlDataIsFile(): bool
{
try {
return @is_file($this->xmlDataOrFilename);
} catch (\TypeError $ex) {
} catch (\TypeError $typeError) {
return false;
}
}
Expand Down
Loading

0 comments on commit a5c8026

Please sign in to comment.