Skip to content

Commit

Permalink
[CS] Removed useless test asserts, Fix code issues reported by PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Dec 27, 2024
1 parent 41e8098 commit 54c0e1d
Show file tree
Hide file tree
Showing 26 changed files with 7 additions and 125 deletions.
3 changes: 3 additions & 0 deletions build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ parameters:
- ../src/codelistsenum/*
- ../tests/testcases/issues/Issue32Test.php
- ../src/quick/ZugferdQuickDescriptor.php
- ../tests/traits/HandlesXmlTests.php
ignoreErrors:
- identifier: parameterByRef.unusedType
2 changes: 1 addition & 1 deletion src/ZugferdDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function getProfileDefinitionParameter(string $parameterName)
{
$profileDefinition = $this->getProfileDefinition();

if (is_array($profileDefinition) && isset($profileDefinition[$parameterName])) {
if (isset($profileDefinition[$parameterName])) {
return $profileDefinition[$parameterName];
}

Expand Down
2 changes: 1 addition & 1 deletion src/ZugferdDocumentPdfMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private function getProfileDefinitionParameter(string $parameterName)
{
$profileDefinition = $this->getProfileDefinition();

if (is_array($profileDefinition) && isset($profileDefinition[$parameterName])) {
if (isset($profileDefinition[$parameterName])) {
return $profileDefinition[$parameterName];
}

Expand Down
4 changes: 2 additions & 2 deletions src/ZugferdDocumentReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3230,12 +3230,12 @@ public function nextDocumentPositionAdditionalReferencedDocument(): bool
* @param string|null $typeCode __BT-X-30, From EXTENDED__ Type of referenced document (See codelist UNTDID 1001)
* @param string|null $uriId __BT-X-28, From EXTENDED__ The Uniform Resource Locator (URL) at which the external document is available. A means of finding the resource including the primary access method intended for it, e.g. http: // or ftp: //. The location of the external document must be used if the buyer needs additional information to support the amounts billed. External documents are not part of the invoice. Access to external documents can involve certain risks.
* @param string|null $lineId __BT-X-29, From EXTENDED__ The referenced position identifier in the additional document
* @param string|null $name __BT-X-299, From EXTENDED__ A description of the document, e.g. Hourly billing, usage or consumption report, etc.
* @param array|null $name __BT-X-299, From EXTENDED__ A description of the document, e.g. Hourly billing, usage or consumption report, etc.
* @param string|null $refTypeCode __BT-X-32, From EXTENDED__ The identifier for the identification scheme of the identifier of the item invoiced. If it is not clear to the recipient which scheme is used for the identifier, an identifier of the scheme should be used, which must be selected from UNTDID 1153 in accordance with the code list entries.
* @param DateTime|null $issueDate __BT-X-33, From EXTENDED__ Document date
* @return ZugferdDocumentReader
*/
public function getDocumentPositionAdditionalReferencedDocument(?string &$issuerAssignedId, ?string &$typeCode, ?string &$uriId, ?string &$lineId, ?string &$name, ?string &$refTypeCode, ?DateTime &$issueDate): ZugferdDocumentReader
public function getDocumentPositionAdditionalReferencedDocument(?string &$issuerAssignedId, ?string &$typeCode, ?string &$uriId, ?string &$lineId, ?array &$name, ?string &$refTypeCode, ?DateTime &$issueDate): ZugferdDocumentReader
{
$tradeLineItem = $this->getInvoiceValueByPath("getSupplyChainTradeTransaction.getIncludedSupplyChainTradeLineItem", []);
$tradeLineItem = $tradeLineItem[$this->positionPointer];
Expand Down
4 changes: 0 additions & 4 deletions src/ZugferdDocumentValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@ class ZugferdDocumentValidator
{
/**
* The invoice document reference
*
* @var ZugferdDocument
*/
private $document;

/**
* The validator instance
*
* @var \Symfony\Component\Validator\Validator\ValidatorInterface;
*/
private $validator = null;

Expand Down
4 changes: 0 additions & 4 deletions src/ZugferdProfileResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ public static function resolve(string $xmlContent): array
throw new ZugferdUnknownXmlContentException();
}

/**
* @var int $profile
* @var array $profiledef
*/
foreach (ZugferdProfiles::PROFILEDEF as $profile => $profiledef) {
if ($typeelement[0] == $profiledef["contextparameter"]) {
return [$profile, $profiledef];
Expand Down
1 change: 0 additions & 1 deletion tests/testcases/BuilderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,6 @@ public function testWriteFile(): void
public function testToString(): void
{
$xmlContent = (string)self::$document;
$this->assertIsString($xmlContent);
$this->assertStringStartsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rsm:CrossIndustryInvoice", $xmlContent);
}

Expand Down
1 change: 0 additions & 1 deletion tests/testcases/BuilderExtendedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,6 @@ public function testWriteFile(): void
public function testToString(): void
{
$xmlContent = (string)self::$document;
$this->assertIsString($xmlContent);
$this->assertStringStartsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rsm:CrossIndustryInvoice", $xmlContent);
}

Expand Down
1 change: 0 additions & 1 deletion tests/testcases/BuilderMinimumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,6 @@ public function testWriteFile(): void
public function testToString(): void
{
$xmlContent = (string)self::$document;
$this->assertIsString($xmlContent);
$this->assertStringStartsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rsm:CrossIndustryInvoice", $xmlContent);
}

Expand Down
5 changes: 0 additions & 5 deletions tests/testcases/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class DocumentTest extends TestCase
public function testDocumentCreationMinimum(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_MINIMUM);
$this->assertNotNull($doc);
$this->assertEquals(ZugferdProfiles::PROFILE_MINIMUM, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
Expand All @@ -24,7 +23,6 @@ public function testDocumentCreationMinimum(): void
public function testDocumentCreationBasic(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_BASIC);
$this->assertNotNull($doc);
$this->assertEquals(ZugferdProfiles::PROFILE_BASIC, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
Expand All @@ -35,7 +33,6 @@ public function testDocumentCreationBasic(): void
public function testDocumentCreationBasicWl(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_BASICWL);
$this->assertNotNull($doc);
$this->assertEquals(ZugferdProfiles::PROFILE_BASICWL, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
Expand All @@ -46,7 +43,6 @@ public function testDocumentCreationBasicWl(): void
public function testDocumentCreationEn16931(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EN16931);
$this->assertNotNull($doc);
$this->assertEquals(ZugferdProfiles::PROFILE_EN16931, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
Expand All @@ -57,7 +53,6 @@ public function testDocumentCreationEn16931(): void
public function testDocumentCreationExtended(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EXTENDED);
$this->assertNotNull($doc);
$this->assertEquals(ZugferdProfiles::PROFILE_EXTENDED, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
Expand Down
13 changes: 0 additions & 13 deletions tests/testcases/PdfBuilderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public function testBuildFromSourcePdfFile(): void

$pdfContent = $pdfBuilder->downloadString(self::$destPdfFilename);

$this->assertIsString($pdfContent);
$this->assertNotEquals('', $pdfContent);
$this->assertStringStartsNotWith('%PDF-1.4', $pdfContent);
}
Expand Down Expand Up @@ -149,7 +148,6 @@ public function testBuildFromSourcePdfString(): void

$pdfContent = $pdfBuilder->downloadString(self::$destPdfFilename);

$this->assertIsString($pdfContent);
$this->assertNotEquals('', $pdfContent);
$this->assertStringStartsNotWith('%PDF-1.4', $pdfContent);
}
Expand All @@ -164,7 +162,6 @@ public function testPdfMetaData(): void
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails); //"FPDF 1.84"
$this->assertArrayHasKey("CreationDate", $pdfDetails); //"2020-12-09T05:19:39+00:00"
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down Expand Up @@ -367,7 +364,6 @@ public function testAdditionalFilesAreEmbedded(): void
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfFilespecs = $pdfParsed->getObjectsByType('Filespec');

$this->assertIsArray($pdfFilespecs);
$this->assertEquals(2, count($pdfFilespecs));
$this->assertArrayHasKey("8_0", $pdfFilespecs);
$this->assertArrayHasKey("10_0", $pdfFilespecs);
Expand Down Expand Up @@ -469,7 +465,6 @@ public function testAttachAdditionalFileByContentAllValid(): void
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfFilespecs = $pdfParsed->getObjectsByType('Filespec');

$this->assertIsArray($pdfFilespecs);
$this->assertEquals(2, count($pdfFilespecs));
$this->assertArrayHasKey("8_0", $pdfFilespecs);
$this->assertArrayHasKey("10_0", $pdfFilespecs);
Expand Down Expand Up @@ -545,7 +540,6 @@ public function testDeterministicMode(): void
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down Expand Up @@ -596,7 +590,6 @@ public function testCustomMetaInformation(): void
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down Expand Up @@ -645,7 +638,6 @@ public function testCustomMetaInformation(): void
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down Expand Up @@ -695,7 +687,6 @@ public function testCustomMetaInformation(): void
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down Expand Up @@ -746,7 +737,6 @@ public function testCustomMetaInformation(): void
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down Expand Up @@ -820,7 +810,6 @@ function ($which) use (&$whichArray) {
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down Expand Up @@ -884,7 +873,6 @@ function ($which) {
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down Expand Up @@ -936,7 +924,6 @@ function ($which) {
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Title", $pdfDetails);
Expand Down
7 changes: 0 additions & 7 deletions tests/testcases/PdfReaderEn16931AllowanceChargeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,10 @@ public function testDocumentShipToGeneral(): void
{
self::$document->getDocumentShipTo($shiptoname, $shiptoids, $shiptodescription);
$this->assertNotNull($shiptoname);
$this->assertIsString($shiptoname);
$this->assertEquals("", $shiptoname);
$this->assertIsArray($shiptoids);
$this->assertEmpty($shiptoids);
$this->assertNotNull($shiptodescription);
$this->assertIsString($shiptodescription);
$this->assertEquals("", $shiptodescription);
}

Expand Down Expand Up @@ -788,32 +786,27 @@ public function testDocumentDespatchAdviceReferencedDocument(): void
self::$document->getDocumentDespatchAdviceReferencedDocument($despatchdocid, $despatchdocdate);
$this->assertEquals("", $despatchdocid);
$this->assertNull($despatchdocdate);
$this->assertNotInstanceOf("DateTime", $despatchdocdate);
}

public function testDocumentReceivingAdviceReferencedDocument(): void
{
self::$document->getDocumentReceivingAdviceReferencedDocument($recadvid, $recadvdate);
$this->assertEquals("", $recadvid);
$this->assertNull($recadvdate);
$this->assertNotInstanceOf("DateTime", $recadvdate);
}

public function testDocumentDeliveryNoteReferencedDocument(): void
{
self::$document->getDocumentDeliveryNoteReferencedDocument($deliverynoterefdocid, $deliverynoterefdocdate);
$this->assertEquals("", $deliverynoterefdocid);
$this->assertNull($deliverynoterefdocdate);
$this->assertNotInstanceOf("DateTime", $deliverynoterefdocdate);
}

public function testDocumentBillingPeriod(): void
{
self::$document->getDocumentBillingPeriod($docbillingperiodstart, $docbillingperiodend);
$this->assertNull($docbillingperiodstart);
$this->assertNotInstanceOf("DateTime", $docbillingperiodstart);
$this->assertNull($docbillingperiodend);
$this->assertNotInstanceOf("DateTime", $docbillingperiodend);
}

public function testDocumentAllowanceCharges(): void
Expand Down
7 changes: 0 additions & 7 deletions tests/testcases/PdfReaderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,10 @@ public function testDocumentShipToGeneral(): void
{
self::$document->getDocumentShipTo($shiptoname, $shiptoids, $shiptodescription);
$this->assertNotNull($shiptoname);
$this->assertIsString($shiptoname);
$this->assertEquals("", $shiptoname);
$this->assertIsArray($shiptoids);
$this->assertEmpty($shiptoids);
$this->assertNotNull($shiptodescription);
$this->assertIsString($shiptodescription);
$this->assertEquals("", $shiptodescription);
}

Expand Down Expand Up @@ -780,32 +778,27 @@ public function testDocumentDespatchAdviceReferencedDocument(): void
self::$document->getDocumentDespatchAdviceReferencedDocument($despatchdocid, $despatchdocdate);
$this->assertEquals("", $despatchdocid);
$this->assertNull($despatchdocdate);
$this->assertNotInstanceOf("DateTime", $despatchdocdate);
}

public function testDocumentReceivingAdviceReferencedDocument(): void
{
self::$document->getDocumentReceivingAdviceReferencedDocument($recadvid, $recadvdate);
$this->assertEquals("", $recadvid);
$this->assertNull($recadvdate);
$this->assertNotInstanceOf("DateTime", $recadvdate);
}

public function testDocumentDeliveryNoteReferencedDocument(): void
{
self::$document->getDocumentDeliveryNoteReferencedDocument($deliverynoterefdocid, $deliverynoterefdocdate);
$this->assertEquals("", $deliverynoterefdocid);
$this->assertNull($deliverynoterefdocdate);
$this->assertNotInstanceOf("DateTime", $deliverynoterefdocdate);
}

public function testDocumentBillingPeriod(): void
{
self::$document->getDocumentBillingPeriod($docbillingperiodstart, $docbillingperiodend);
$this->assertNull($docbillingperiodstart);
$this->assertNotInstanceOf("DateTime", $docbillingperiodstart);
$this->assertNull($docbillingperiodend);
$this->assertNotInstanceOf("DateTime", $docbillingperiodend);
}

public function testDocumentAllowanceCharges(): void
Expand Down
3 changes: 0 additions & 3 deletions tests/testcases/PdfReaderExtended2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,23 +780,20 @@ public function testDocumentDespatchAdviceReferencedDocument(): void
self::$document->getDocumentDespatchAdviceReferencedDocument($despatchdocid, $despatchdocdate);
$this->assertEquals("DESPADV002", $despatchdocid);
$this->assertNull($despatchdocdate);
$this->assertNotInstanceOf("DateTime", $despatchdocdate);
}

public function testDocumentReceivingAdviceReferencedDocument(): void
{
self::$document->getDocumentReceivingAdviceReferencedDocument($recadvid, $recadvdate);
$this->assertEquals("RECEIV-ADV002", $recadvid);
$this->assertNull($recadvdate);
$this->assertNotInstanceOf("DateTime", $recadvdate);
}

public function testDocumentDeliveryNoteReferencedDocument(): void
{
self::$document->getDocumentDeliveryNoteReferencedDocument($deliverynoterefdocid, $deliverynoterefdocdate);
$this->assertEquals("", $deliverynoterefdocid);
$this->assertNull($deliverynoterefdocdate);
$this->assertNotInstanceOf("DateTime", $deliverynoterefdocdate);
}

public function testDocumentBillingPeriod(): void
Expand Down
5 changes: 0 additions & 5 deletions tests/testcases/PdfReaderExtendedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,32 +795,27 @@ public function testDocumentDespatchAdviceReferencedDocument(): void
self::$document->getDocumentDespatchAdviceReferencedDocument($despatchdocid, $despatchdocdate);
$this->assertEquals("", $despatchdocid);
$this->assertNull($despatchdocdate);
$this->assertNotInstanceOf("DateTime", $despatchdocdate);
}

public function testDocumentReceivingAdviceReferencedDocument(): void
{
self::$document->getDocumentReceivingAdviceReferencedDocument($recadvid, $recadvdate);
$this->assertEquals("", $recadvid);
$this->assertNull($recadvdate);
$this->assertNotInstanceOf("DateTime", $recadvdate);
}

public function testDocumentDeliveryNoteReferencedDocument(): void
{
self::$document->getDocumentDeliveryNoteReferencedDocument($deliverynoterefdocid, $deliverynoterefdocdate);
$this->assertEquals("L87654321012", $deliverynoterefdocid);
$this->assertNull($deliverynoterefdocdate);
$this->assertNotInstanceOf("DateTime", $deliverynoterefdocdate);
}

public function testDocumentBillingPeriod(): void
{
self::$document->getDocumentBillingPeriod($docbillingperiodstart, $docbillingperiodend);
$this->assertNull($docbillingperiodstart);
$this->assertNotInstanceOf("DateTime", $docbillingperiodstart);
$this->assertNull($docbillingperiodend);
$this->assertNotInstanceOf("DateTime", $docbillingperiodend);
}

public function testDocumentAllowanceCharges(): void
Expand Down
Loading

0 comments on commit 54c0e1d

Please sign in to comment.