Skip to content

Commit

Permalink
Merge pull request #11 from kynx/pretty-printer-fixes
Browse files Browse the repository at this point in the history
Pretty printer fixes
  • Loading branch information
kynx authored Feb 14, 2024
2 parents f22d088 + 089156b commit d8ba8fe
Show file tree
Hide file tree
Showing 19 changed files with 139 additions and 103 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
/test/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.markdownlint.json export-ignore
/.psr-container.php.stub export-ignore
/composer.lock export-ignore
/phpcs.xml export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
/psalm.xml export-ignore
/psalm-baseline.xml export-ignore
110 changes: 55 additions & 55 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,216 +1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.21.0@04ba9358e3f7d14a9dc3edd4e814a9d51d8c637f">
<files psalm-version="5.22.0@fe2c67ec89f358940f90db05efd2d663388b45a6">
<file src="src/File/FormFile.php">
<PossiblyUnusedProperty>
<code>$file</code>
<code><![CDATA[$file]]></code>
</PossiblyUnusedProperty>
</file>
<file src="test/ConfigProviderTest.php">
<PossiblyUnusedMethod>
<code>aliasProvider</code>
<code>factoryProvider</code>
<code>filterVisitorsProvider</code>
<code>regexPatternProvider</code>
<code>validatorVisitorsProvider</code>
<code><![CDATA[aliasProvider]]></code>
<code><![CDATA[factoryProvider]]></code>
<code><![CDATA[filterVisitorsProvider]]></code>
<code><![CDATA[regexPatternProvider]]></code>
<code><![CDATA[validatorVisitorsProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Decorator/KeyedArrayDecoratorTest.php">
<PossiblyUnusedMethod>
<code>typeNameProvider</code>
<code><![CDATA[typeNameProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Decorator/UnionDecoratorTest.php">
<file src="test/Decorator/PrettyPrinterTest.php">
<PossiblyUnusedMethod>
<code>combineTypesProvider</code>
<code>typeProvider</code>
<code><![CDATA[combineTypesProvider]]></code>
<code><![CDATA[typeProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/File/FormReaderTest.php">
<PossiblyUnusedMethod>
<code>getFormFileProvider</code>
<code><![CDATA[getFormFileProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Filter/AbstractFilterVisitorTestCase.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Filter/AllowListVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Filter/BooleanVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Filter/DigitsVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Filter/InflectorVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Filter/ToFloatVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Filter/ToIntVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Filter/ToNullVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Form/FormCollectionSmokeTest.php">
<PossiblyUnusedMethod>
<code>countAllowRemoveProvider</code>
<code>validationMatchesProvider</code>
<code><![CDATA[countAllowRemoveProvider]]></code>
<code><![CDATA[validationMatchesProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Form/FormElementSmokeTest.php">
<PossiblyUnusedMethod>
<code>defaultElementProvider</code>
<code><![CDATA[defaultElementProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Form/FormFieldsetSmokeTest.php">
<PossiblyUnusedMethod>
<code>validationMatchProvider</code>
<code><![CDATA[validationMatchProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/InputFilter/InputFilterVisitorTest.php">
<PossiblyUnusedMethod>
<code>collectionProvider</code>
<code><![CDATA[collectionProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/InputFilter/InputVisitorTest.php">
<PossiblyUnusedMethod>
<code>addNotEmptyProvider</code>
<code><![CDATA[addNotEmptyProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Psalm/ConfigLoaderTrait.php">
<PossiblyUnusedMethod>
<code>reloadConfig</code>
<code><![CDATA[reloadConfig]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Psalm/TypeComparatorTest.php">
<PossiblyUnusedMethod>
<code>isContainedByFalseProvider</code>
<code>isContainedByTrueProvider</code>
<code><![CDATA[isContainedByFalseProvider]]></code>
<code><![CDATA[isContainedByTrueProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Psalm/TypeUtilTest.php">
<PossiblyUnusedMethod>
<code>filterProvider</code>
<code>narrowProvider</code>
<code>replaceTypeProvider</code>
<code>toLaxUnion</code>
<code>toStrictUnionProvider</code>
<code>widenProvider</code>
<code><![CDATA[filterProvider]]></code>
<code><![CDATA[narrowProvider]]></code>
<code><![CDATA[replaceTypeProvider]]></code>
<code><![CDATA[toLaxUnion]]></code>
<code><![CDATA[toStrictUnionProvider]]></code>
<code><![CDATA[widenProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/AbstractValidatorVisitorTestCase.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/BetweenVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/CsrfVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/DateStepVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/DateVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/DigitsVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/ExplodeVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/FileValidatorVisitorTest.php">
<PossiblyUnusedMethod>
<code>defaultValidatorProvider</code>
<code>visitProvider</code>
<code><![CDATA[defaultValidatorProvider]]></code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/HexVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/InArrayVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/IsCountableVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/IsInstanceOfVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/IsbnVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/NonEmptyStringVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/NotEmptyVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/RegexVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/Sitemap/PriorityVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/StepVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Validator/StringLengthVisitorTest.php">
<PossiblyUnusedMethod>
<code>visitProvider</code>
<code><![CDATA[visitProvider]]></code>
</PossiblyUnusedMethod>
</file>
</files>
4 changes: 2 additions & 2 deletions src/Command/PsalmTypeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Kynx\Laminas\FormShape\Command;

use Kynx\Laminas\FormShape\DecoratorInterface;
use Kynx\Laminas\FormShape\File\FormReaderInterface;
use Kynx\Laminas\FormShape\Form\FormVisitorInterface;
use Kynx\Laminas\FormShape\InputFilter\InputVisitorException;
use Kynx\Laminas\FormShape\UnionDecoratorInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -19,7 +19,7 @@ final class PsalmTypeCommand extends Command
public function __construct(
private readonly FormReaderInterface $formReader,
private readonly FormVisitorInterface $formVisitor,
private readonly UnionDecoratorInterface $decorator,
private readonly DecoratorInterface $decorator,
) {
parent::__construct();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/PsalmTypeCommandFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Kynx\Laminas\FormShape\Command;

use Kynx\Laminas\FormShape\DecoratorInterface;
use Kynx\Laminas\FormShape\File\FormReader;
use Kynx\Laminas\FormShape\Form\FormVisitorInterface;
use Kynx\Laminas\FormShape\UnionDecoratorInterface;
use Psr\Container\ContainerInterface;

final readonly class PsalmTypeCommandFactory
Expand All @@ -16,7 +16,7 @@ public function __invoke(ContainerInterface $container): PsalmTypeCommand
return new PsalmTypeCommand(
$container->get(FormReader::class),
$container->get(FormVisitorInterface::class),
$container->get(UnionDecoratorInterface::class)
$container->get(DecoratorInterface::class)
);
}
}
8 changes: 4 additions & 4 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Kynx\Laminas\FormShape\Command\PsalmTypeCommand;
use Kynx\Laminas\FormShape\Command\PsalmTypeCommandFactory;
use Kynx\Laminas\FormShape\Decorator\UnionDecorator;
use Kynx\Laminas\FormShape\Decorator\UnionDecoratorFactory;
use Kynx\Laminas\FormShape\Decorator\PrettyPrinter;
use Kynx\Laminas\FormShape\Decorator\PrettyPrinterFactory;
use Kynx\Laminas\FormShape\File\FormReader;
use Kynx\Laminas\FormShape\File\FormReaderFactory;
use Kynx\Laminas\FormShape\Filter\AllowListVisitor;
Expand Down Expand Up @@ -206,7 +206,7 @@ private function getDependencyConfig(): array
'aliases' => [
FormVisitorInterface::class => FormVisitor::class,
InputFilterVisitorInterface::class => InputFilterVisitor::class,
UnionDecoratorInterface::class => UnionDecorator::class,
DecoratorInterface::class => PrettyPrinter::class,
],
'factories' => [
AllowListVisitor::class => AllowListVisitorFactory::class,
Expand All @@ -222,7 +222,7 @@ private function getDependencyConfig(): array
InputVisitor::class => InputVisitorFactory::class,
NonEmptyStringVisitor::class => NonEmptyStringVisitorFactory::class,
RegexVisitor::class => RegexVisitorFactory::class,
UnionDecorator::class => UnionDecoratorFactory::class,
PrettyPrinter::class => PrettyPrinterFactory::class,
],
];
}
Expand Down
11 changes: 8 additions & 3 deletions src/Decorator/ArrayDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@

final readonly class ArrayDecorator
{
public function __construct(private UnionDecorator $unionDecorator)
public function __construct(private PrettyPrinter $unionDecorator)
{
}

public function decorate(TArray $array): string
public function decorate(TArray $array, int $indent = 0): string
{
[$key, $value] = $array->type_params;
return sprintf('%s<%s, %s>', $array->value, $key->getKey(), $this->unionDecorator->decorate($value));
return sprintf(
'%s<%s, %s>',
$array->value,
$key->getKey(),
$this->unionDecorator->decorate($value, $indent)
);
}
}
2 changes: 1 addition & 1 deletion src/Decorator/KeyedArrayDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

final readonly class KeyedArrayDecorator
{
public function __construct(private UnionDecorator $unionDecorator)
public function __construct(private PrettyPrinter $unionDecorator)
{
}

Expand Down
Loading

0 comments on commit d8ba8fe

Please sign in to comment.