diff --git a/build/phprectorconfig.php b/build/phprectorconfig.php
index 801790d8..03d19783 100644
--- a/build/phprectorconfig.php
+++ b/build/phprectorconfig.php
@@ -35,9 +35,9 @@
earlyReturn: true,
phpunitCodeQuality: true,
privatization: true,
+ deadCode: true,
//
carbon: false,
- deadCode: false,
doctrineCodeQuality: false,
naming: false,
rectorPreset: false,
diff --git a/make/gencodelists.php b/make/gencodelists.php
index d57dd6ad..d5f58de1 100644
--- a/make/gencodelists.php
+++ b/make/gencodelists.php
@@ -45,8 +45,7 @@ function handleUmlauts(string $str): string
$str = str_replace("ö", "oe", $str);
$str = str_replace("ä", "ae", $str);
$str = str_replace("ü", "ue", $str);
- $str = str_replace("Å", "A", $str);
- return $str;
+ return str_replace("Å", "A", $str);
}
/**
@@ -62,8 +61,7 @@ function strComment(string $str): string
$str = str_replace("\r", "", $str);
$str = str_replace("\t", "", $str);
$str = preg_replace('/\s+/', ' ', $str);
- $str = wordwrap($str);
- return $str;
+ return wordwrap($str);
}
/**
@@ -102,8 +100,7 @@ function strIdentifier(string $str, bool $shortIdentifier): string
$strNew = preg_replace('/__+/', '_', $strNew);
$strNew = preg_replace('~\d~', '', $strNew, 5);
- $strNew = rtrim(ltrim($strNew, "_"), "_");
- return $strNew;
+ return rtrim(ltrim($strNew, "_"), "_");
}
/**
@@ -119,8 +116,7 @@ function strDesc(string $str): string
$str = str_replace("\n", " ", $str);
$str = str_replace("\r", " ", $str);
$str = str_replace("\t", " ", $str);
- $str = preg_replace('/\s+/', ' ', $str);
- return $str;
+ return preg_replace('/\s+/', ' ', $str);
}
/**
diff --git a/make/genmethoddocs.php b/make/genmethoddocs.php
index 94638406..8f3fcb47 100644
--- a/make/genmethoddocs.php
+++ b/make/genmethoddocs.php
@@ -212,7 +212,7 @@ public function getArray(): array
'name' => $parameterName,
'type' => $parameterTypeString ?: 'mixed',
'isNullable' => $parameterType && $parameterType->allowsNull(),
- 'defaultValueavailable' => $parameter->isOptional() ? ($parameter->isDefaultValueAvailable()) : false,
+ 'defaultValueavailable' => $parameter->isOptional() && $parameter->isDefaultValueAvailable(),
'defaultValue' => $parameter->isOptional() ? ($parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null) : null,
'description' => $paramDescriptions[$parameterName]['description'] ?? ''
];
@@ -261,7 +261,7 @@ class MarkDownGenerator
*
* @var ExtractClass
*/
- protected $extractor = null;
+ protected $extractor;
/**
* The lines for the MD
@@ -455,20 +455,6 @@ private function addLineRaw(string $string, ...$args): MarkDownGenerator
return $this;
}
- /**
- * Add a line to internal container
- *
- * @param string $string
- * @param mixed ...$args
- * @return MarkDownGenerator
- */
- private function addLineRawAllowEmpty(string $string, ...$args): MarkDownGenerator
- {
- $this->lines[] = sprintf($string, ...$args);
-
- return $this;
- }
-
/**
* Add an empty line to internal container
*
@@ -481,24 +467,6 @@ private function addEmptyLine(): MarkDownGenerator
return $this;
}
- /**
- * Add an H1-Line to internal container
- *
- * @param string $string
- * @param boolean $newLine
- * @return MarkDownGenerator
- */
- private function addLineH1(string $string, bool $newLine = true): MarkDownGenerator
- {
- $this->addLine("# %s", $string);
-
- if ($newLine) {
- $this->addEmptyLine();
- }
-
- return $this;
- }
-
/**
* Add an H2-Line to internal container
*
@@ -585,18 +553,6 @@ private function addLineItalic(string $string, ...$args): MarkDownGenerator
return $this->addLine(sprintf("_%s_", $string), ...$args);
}
- /**
- * Add line as bold formatted
- *
- * @param string $string
- * @param mixed ...$args
- * @return MarkDownGenerator
- */
- private function addLineBold(string $string, ...$args): MarkDownGenerator
- {
- return $this->addLine(sprintf("__%s__", $string), ...$args);
- }
-
/**
* Import an example from a markdown file
*
@@ -644,9 +600,8 @@ private function sanatizeString(string $string): string
$string = str_replace("\n", "
", $string);
$string = str_replace("__BT-, From __", "", $string);
$string = str_replace("__BT-, From", "__BT-??, From", $string);
- $string = trim($string);
- return $string;
+ return trim($string);
}
/**
@@ -657,9 +612,7 @@ private function sanatizeString(string $string): string
*/
private function removeSprintfPlaceholder(string $string): string
{
- $string = str_replace("%", "", $string);
-
- return $string;
+ return str_replace("%", "", $string);
}
/**
diff --git a/src/ZugferdDocument.php b/src/ZugferdDocument.php
index a31d4bfe..1435787f 100644
--- a/src/ZugferdDocument.php
+++ b/src/ZugferdDocument.php
@@ -57,12 +57,12 @@ class ZugferdDocument
/**
* @var \horstoeko\zugferd\entities\basic\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\basicwl\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice $invoiceObject The internal invoice object
*/
- private $invoiceObject = null;
+ private $invoiceObject;
/**
* @var ZugferdObjectHelper $objectHelper Object Helper
*/
- private $objectHelper = null;
+ private $objectHelper;
/**
* Constructor
diff --git a/src/ZugferdDocumentBuilder.php b/src/ZugferdDocumentBuilder.php
index 225d2686..1fb6f561 100644
--- a/src/ZugferdDocumentBuilder.php
+++ b/src/ZugferdDocumentBuilder.php
@@ -34,42 +34,42 @@ class ZugferdDocumentBuilder extends ZugferdDocument
*
* @var object
*/
- protected $headerTradeAgreement = null;
+ protected $headerTradeAgreement;
/**
* HeaderTradeDelivery
*
* @var object
*/
- protected $headerTradeDelivery = null;
+ protected $headerTradeDelivery;
/**
* HeaderTradeSettlement
*
* @var object
*/
- protected $headerTradeSettlement = null;
+ protected $headerTradeSettlement;
/**
* SupplyChainTradeTransactionType
*
* @var object
*/
- protected $headerSupplyChainTradeTransaction = null;
+ protected $headerSupplyChainTradeTransaction;
/**
* Last added payment terms
*
* @var object
*/
- protected $currentPaymentTerms = null;
+ protected $currentPaymentTerms;
/**
* Last added position (line) to the docuemnt
*
* @var object
*/
- protected $currentPosition = null;
+ protected $currentPosition;
/**
* Receive the content as XML string
@@ -153,9 +153,7 @@ public function getContentAsDomDocument(): DOMDocument
*/
public function getContentAsDomXPath(): DOMXpath
{
- $domXPath = new DOMXPath($this->getContentAsDomDocument());
-
- return $domXPath;
+ return new DOMXPath($this->getContentAsDomDocument());
}
/**
diff --git a/src/ZugferdDocumentJsonExporter.php b/src/ZugferdDocumentJsonExporter.php
index 8cd82a4e..a8e4ae25 100644
--- a/src/ZugferdDocumentJsonExporter.php
+++ b/src/ZugferdDocumentJsonExporter.php
@@ -28,7 +28,7 @@ class ZugferdDocumentJsonExporter
*
* @var ZugferdDocument
*/
- private $document = null;
+ private $document;
/**
* Constructor
@@ -57,9 +57,7 @@ public function toJsonString(): string
*/
public function toJsonObject(): ?\stdClass
{
- $jsonObject = json_decode($this->toJsonString());
-
- return $jsonObject;
+ return json_decode($this->toJsonString());
}
/**
diff --git a/src/ZugferdDocumentPdfBuilder.php b/src/ZugferdDocumentPdfBuilder.php
index aa325197..70bc9e18 100644
--- a/src/ZugferdDocumentPdfBuilder.php
+++ b/src/ZugferdDocumentPdfBuilder.php
@@ -30,7 +30,7 @@ class ZugferdDocumentPdfBuilder extends ZugferdDocumentPdfBuilderAbstract
*
* @var ZugferdDocumentBuilder
*/
- private $documentBuilder = null;
+ private $documentBuilder;
/**
* Cached XML data
diff --git a/src/ZugferdDocumentPdfBuilderAbstract.php b/src/ZugferdDocumentPdfBuilderAbstract.php
index a042ed8d..aa4f4f95 100644
--- a/src/ZugferdDocumentPdfBuilderAbstract.php
+++ b/src/ZugferdDocumentPdfBuilderAbstract.php
@@ -71,7 +71,7 @@ abstract class ZugferdDocumentPdfBuilderAbstract
*
* @var ZugferdPdfWriter
*/
- private $pdfWriter = null;
+ private $pdfWriter;
/**
* Contains the data of the original PDF document
@@ -120,7 +120,7 @@ abstract class ZugferdDocumentPdfBuilderAbstract
*
* @var callable|null
*/
- private $metaInformationCallback = null;
+ private $metaInformationCallback;
/**
* Constructor
@@ -606,7 +606,7 @@ private function preparePdfMetadata(): array
$title = sprintf('%s : %s %s', $invoiceInformations['seller'], $invoiceInformations['docTypeName'], $invoiceInformations['invoiceId']);
$subject = sprintf('FacturX/ZUGFeRD %s %s dated %s issued by %s', $invoiceInformations['docTypeName'], $invoiceInformations['invoiceId'], $dateString, $invoiceInformations['seller']);
- $pdfMetadata = [
+ return [
'author' => $this->buildMetadataField('author', $author, $invoiceInformations),
'keywords' => $this->buildMetadataField('keywords', $keywords, $invoiceInformations),
'title' => $this->buildMetadataField('title', $title, $invoiceInformations),
@@ -614,8 +614,6 @@ private function preparePdfMetadata(): array
'createdDate' => $invoiceInformations['date'],
'modifiedDate' => (new DateTime())->format('Y-m-d\TH:i:sP'),
];
-
- return $pdfMetadata;
}
/**
@@ -652,14 +650,12 @@ protected function extractInvoiceInformations(): array
break;
}
- $invoiceInformation = [
+ return [
'invoiceId' => $invoiceId,
'docTypeName' => $docTypeName,
'seller' => $sellerName,
'date' => $dateReformatted,
];
-
- return $invoiceInformation;
}
/**
diff --git a/src/ZugferdDocumentValidator.php b/src/ZugferdDocumentValidator.php
index 52fb7004..92f3a158 100644
--- a/src/ZugferdDocumentValidator.php
+++ b/src/ZugferdDocumentValidator.php
@@ -33,7 +33,7 @@ class ZugferdDocumentValidator
/**
* The validator instance
*/
- private $validator = null;
+ private $validator;
/**
* Constructor
diff --git a/src/ZugferdObjectHelper.php b/src/ZugferdObjectHelper.php
index a05d3417..8b02c42e 100644
--- a/src/ZugferdObjectHelper.php
+++ b/src/ZugferdObjectHelper.php
@@ -551,9 +551,7 @@ public function getCountryIDType(?string $id = null): ?object
return null;
}
- $countryIDType = $this->createClassInstance('qdt\CountryIDType', $id);
-
- return $countryIDType;
+ return $this->createClassInstance('qdt\CountryIDType', $id);
}
/**
diff --git a/src/ZugferdPdfValidator.php b/src/ZugferdPdfValidator.php
index 32869ee8..4cf8ac80 100644
--- a/src/ZugferdPdfValidator.php
+++ b/src/ZugferdPdfValidator.php
@@ -362,16 +362,6 @@ public function validate(): ZugferdPdfValidator
return $this;
}
- /**
- * Internal get the content of the PDF
- *
- * @return string
- */
- private function getPdfContent(): string
- {
- return $this->pdfContent;
- }
-
/**
* Internal get (and create) the directory for downloads and file creation
*
diff --git a/src/ZugferdPdfWriter.php b/src/ZugferdPdfWriter.php
index 3b53397e..d8839065 100644
--- a/src/ZugferdPdfWriter.php
+++ b/src/ZugferdPdfWriter.php
@@ -210,7 +210,7 @@ public function setDeterministicModeEnabled(bool $deterministicModeEnabled): voi
*/
protected function _putfiles(): void
{
- foreach ($this->files as $_ => &$info) {
+ foreach ($this->files as &$info) {
$this->putFileSpecification($info);
$info['file_index'] = $this->n;
$this->putFileStream($info);
@@ -328,7 +328,7 @@ protected function putMetadataDescriptions(): void
$s .= '' . "\n";
$this->_newobj();
$this->descriptionIndex = $this->n;
- foreach ($this->metaDataDescriptions as $_ => $desc) {
+ foreach ($this->metaDataDescriptions as $desc) {
$s .= $desc . "\n";
}
diff --git a/src/jms/ZugferdTypesHandler.php b/src/jms/ZugferdTypesHandler.php
index 6f3a663f..788b45ef 100644
--- a/src/jms/ZugferdTypesHandler.php
+++ b/src/jms/ZugferdTypesHandler.php
@@ -234,7 +234,7 @@ public function serializeQuantityType(XmlSerializationVisitor $visitor, $data)
*/
public function serializePercentType(XmlSerializationVisitor $visitor, $data)
{
- $node = $visitor->getDocument()->createTextNode(
+ return $visitor->getDocument()->createTextNode(
number_format(
$data->value(),
ZugferdSettings::getSpecialDecimalPlacesMap($visitor->getCurrentNode()->getNodePath(), ZugferdSettings::getPercentDecimals()),
@@ -242,8 +242,6 @@ public function serializePercentType(XmlSerializationVisitor $visitor, $data)
ZugferdSettings::getThousandsSeparator()
)
);
-
- return $node;
}
/**
@@ -283,7 +281,6 @@ public function serializeMeasureType(XmlSerializationVisitor $visitor, $data)
*/
public function serializeIndicatorType(XmlSerializationVisitor $visitor, $data)
{
- $node = $visitor->getDocument()->createElement('udt:Indicator', $data->getIndicator() == false ? 'false' : 'true');
- return $node;
+ return $visitor->getDocument()->createElement('udt:Indicator', $data->getIndicator() == false ? 'false' : 'true');
}
}
diff --git a/tests/testcases/SettingsTest.php b/tests/testcases/SettingsTest.php
index 457c7b66..d2ff5669 100644
--- a/tests/testcases/SettingsTest.php
+++ b/tests/testcases/SettingsTest.php
@@ -109,7 +109,7 @@ public function testIccProfileFilename(): void
$this->assertSame("sRGB_v5_ICC.icc", ZugferdSettings::getIccProfileFilename());
- $property = $this->getPrivatePropertyFromClassname(ZugferdSettings::class, "iccProfileFilename");
+ $this->getPrivatePropertyFromClassname(ZugferdSettings::class, "iccProfileFilename");
}
public function testGetRootDirectory(): void
diff --git a/tests/testcases/issues/Issue104Test.php b/tests/testcases/issues/Issue104Test.php
index 65082cac..913e3b5e 100644
--- a/tests/testcases/issues/Issue104Test.php
+++ b/tests/testcases/issues/Issue104Test.php
@@ -16,7 +16,7 @@ public function testInvalidException1()
{
$this->expectException(ZugferdUnknownXmlContentException::class);
- $document = ZugferdDocumentReader::readAndGuessFromFile(__DIR__ . '/../../assets/xml_invalid_1.xml');
+ ZugferdDocumentReader::readAndGuessFromFile(__DIR__ . '/../../assets/xml_invalid_1.xml');
}
/**
@@ -27,6 +27,6 @@ public function testInvalidException2()
{
$this->expectException(ZugferdUnknownXmlContentException::class);
- $document = ZugferdDocumentReader::readAndGuessFromFile(__DIR__ . '/../../assets/xml_invalid_2.xml');
+ ZugferdDocumentReader::readAndGuessFromFile(__DIR__ . '/../../assets/xml_invalid_2.xml');
}
}