Skip to content

Commit

Permalink
Rename toStringRecursive to toHtmlRecursive because that's how it's used
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinai committed Nov 30, 2020
1 parent 46e230f commit 97ab1dc
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Api/DataTypeValueToStringConverterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ interface DataTypeValueToStringConverterInterface

public function toString($value): ?string;

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string;
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string;
}
4 changes: 2 additions & 2 deletions Model/DataType/ArrayDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = 1): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = 1): ?string
{
return $this->valueToTypeCode($value) && $this->mayRecurse($maxRecursionDepth)
? $this->implode($value, $maxRecursionDepth)
Expand All @@ -69,7 +69,7 @@ private function recur(array $value, int $maxRecursionDepth): array

$strings = map(function ($value) use ($maxRecursionDepth): string {
$converter = $this->toStringConverterLocator->forTypeCode($this->dataTypeGuesser->valueToTypeCode($value));
return $converter->toStringRecursive($value, $maxRecursionDepth - 1);
return $converter->toHtmlRecursive($value, $maxRecursionDepth - 1);
}, $itemsToShow);

return merge($strings, ($overLimit ? ['...'] : []));
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/CategoryLinkDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/CustomerAddressDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/DateTimeDataTypeConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/GenericObjectDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/LongTextDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/PriceDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
4 changes: 2 additions & 2 deletions Model/DataType/ProductCustomOptionDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->valueToTypeCode($value)
? $this->formatCustomOptionAsArray($value, $maxRecursionDepth)
Expand All @@ -67,7 +67,7 @@ private function formatCustomOptionAsArray(ProductCustomOptionInterface $value,
];
$converter = $this->dataTypeToStringConverterLocator->forTypeCode('array');
return $converter
? 'Custom Option: ' . $converter->toStringRecursive($parts, $maxRecursionDepth)
? 'Custom Option: ' . $converter->toHtmlRecursive($parts, $maxRecursionDepth)
: '';
}

Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/ProductDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function getDisplayName(ProductInterface $product): string
return (string) ($product->getName() ?? $product->getSku() ?? $product->getId() ?? '(not initialized)');
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->valueToTypeCode($value)
? sprintf('%s [SKU %s]', $this->getDisplayName($value), $value->getSku() ?? '?')
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/ProductGalleryDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function toString($value): ?string
return implode('', map([$this, 'buildImageTag'], $value['images'] ?? []));
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/ProductGalleryEntryDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->valueToTypeCode($value)
? $this->toString($value)
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/ProductImageDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $value
? $this->productMedia->getImageHtmlElement($value, 'Product Image')
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/ProductLinkDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->valueToTypeCode($value)
? $this->toString($value)
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/ScalarAndNullDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
4 changes: 2 additions & 2 deletions Model/DataType/StockItemDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public function toString($value): ?string
: null;
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->valueToTypeCode($value)
? $this->toStringConverterLocator->forTypeCode('array')->toStringRecursive(
? $this->toStringConverterLocator->forTypeCode('array')->toHtmlRecursive(
$this->dataObjectProcessor->buildOutputDataArray($value, StockItemInterface::class),
$maxRecursionDepth
)
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/TierPriceDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function toString($value): ?string
* @param int $maxRecursionDepth
* @return string|null
*/
public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->isProductTierPriceInstance($value)
? $this->implode([
Expand Down
2 changes: 1 addition & 1 deletion Model/DataType/UnknownDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function toString($value): ?string
}
}

public function toStringRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
public function toHtmlRecursive($value, $maxRecursionDepth = self::UNLIMITED_RECURSION): ?string
{
return $this->toString($value);
}
Expand Down
18 changes: 9 additions & 9 deletions Test/Functional/Model/DataType/ArrayDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testMatchesArray(): void
public function testReturnsNullIfTypeDoesNotMatch(): void
{
$this->assertNull($this->createArrayDataType()->toString('foo'));
$this->assertNull($this->createArrayDataType()->toStringRecursive('foo'));
$this->assertNull($this->createArrayDataType()->toHtmlRecursive('foo'));
}

public function testArrayToStringWithoutRecursion(): void
Expand All @@ -50,22 +50,22 @@ public function testArrayToStringWithoutRecursion(): void
public function testArrayToStringWithRecursion(): void
{
$sut = $this->createArrayDataType();
$this->assertSame('[ ]', $sut->toStringRecursive([]));
$this->assertSame('[1]', $sut->toStringRecursive([1]));
$this->assertSame('[1, a]', $sut->toStringRecursive([1, 'a']));
$this->assertSame('[[ ], a]', $sut->toStringRecursive([[], 'a']));
$this->assertSame('[ ]', $sut->toHtmlRecursive([]));
$this->assertSame('[1]', $sut->toHtmlRecursive([1]));
$this->assertSame('[1, a]', $sut->toHtmlRecursive([1, 'a']));
$this->assertSame('[[ ], a]', $sut->toHtmlRecursive([[], 'a']));

$o = new class() {
public function __toString(): string
{
return 'foo';
}
};
$this->assertSame('[[ ], a, foo]', $sut->toStringRecursive([[], 'a', $o]));
$this->assertSame('[[ ], a, foo]', $sut->toHtmlRecursive([[], 'a', $o]));

$noLimit = ArrayDataType::UNLIMITED_RECURSION;
$this->assertSame('[[[[ ]]]]', $sut->toStringRecursive([[[[]]]], $noLimit));
$this->assertSame('[[[[10, 9, 8]]]]', $sut->toStringRecursive([[[[10, 9, 8]]]], $noLimit));
$this->assertSame('[[[[ ]]]]', $sut->toHtmlRecursive([[[[]]]], $noLimit));
$this->assertSame('[[[[10, 9, 8]]]]', $sut->toHtmlRecursive([[[[10, 9, 8]]]], $noLimit));
}

/**
Expand All @@ -86,7 +86,7 @@ public function testArraytoStringWithLimitedRecursion(int $recursionDepth, strin
[4, 5, []],
],
];
$this->assertSame($expected, $sut->toStringRecursive($value, $recursionDepth));
$this->assertSame($expected, $sut->toHtmlRecursive($value, $recursionDepth));
}

public function recursionDepthDataProvider(): array
Expand Down
6 changes: 3 additions & 3 deletions Test/Functional/Model/DataType/ProductDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testMatchesProducts(): void
public function testReturnsNullIfTypeDoesNotMatch(): void
{
$this->assertNull((new ProductDataType())->toString([]));
$this->assertNull((new ProductDataType())->toStringRecursive([]));
$this->assertNull((new ProductDataType())->toHtmlRecursive([]));
}

public function testToString(): void
Expand All @@ -43,7 +43,7 @@ public function testToStringRecursive(): void
$product->setSku('1234xyz');
$product->setId(23);

$this->assertSame('Test [SKU 1234xyz]', (new ProductDataType())->toStringRecursive($product));
$this->assertSame('Test [SKU 1234xyz]', (new ProductDataType())->toHtmlRecursive($product));
}

public function testEmptyProduct(): void
Expand All @@ -52,6 +52,6 @@ public function testEmptyProduct(): void
$product = ObjectManager::getInstance()->create(ProductInterface::class);

$this->assertSame('(not initialized)', (new ProductDataType())->toString($product));
$this->assertSame('(not initialized) [SKU ?]', (new ProductDataType())->toStringRecursive($product));
$this->assertSame('(not initialized) [SKU ?]', (new ProductDataType())->toHtmlRecursive($product));
}
}
4 changes: 2 additions & 2 deletions Test/Functional/Model/DataType/ScalarAndNullDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testReturnsNullForNonMatchingTypes($nonMatchingType): void
{
$sut = new ScalarAndNullDataType();
$this->assertNull($sut->toString($nonMatchingType));
$this->assertNull($sut->toStringRecursive($nonMatchingType));
$this->assertNull($sut->toHtmlRecursive($nonMatchingType));
}

public function notMatchingTypeProvider(): array
Expand All @@ -36,7 +36,7 @@ public function testReturnsStringForMatchingTypes($matchingType): void
{
$sut = new ScalarAndNullDataType();
$this->assertSame((string) $matchingType, $sut->toString($matchingType));
$this->assertSame((string) $matchingType, $sut->toStringRecursive($matchingType));
$this->assertSame((string) $matchingType, $sut->toHtmlRecursive($matchingType));
}

public function matchingTypeProvider(): array
Expand Down
2 changes: 1 addition & 1 deletion ViewModel/HyvaGrid/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function convertToString($value, bool $useRecursion): string
return '#unknownType(' . $columnType . ')';
}
$stringValue = $useRecursion
? $converter->toStringRecursive($value, 1 /* recursion depth */)
? $converter->toHtmlRecursive($value, 1 /* recursion depth */)
: $converter->toString($value);

return $stringValue ?? $this->mismatch($columnType, $value);
Expand Down

0 comments on commit 97ab1dc

Please sign in to comment.