From 2a5a3c1746d986ed0950da38c9582f409c909265 Mon Sep 17 00:00:00 2001 From: brainshaker Date: Wed, 18 Oct 2023 21:44:49 +0200 Subject: [PATCH] refactor(visibilities): reduce visibilities wherever possible --- src/Command/DumpCommand.php | 4 +- src/Interface/Config.php | 78 ++++++++++++------------- src/Model/Config/FileType.php | 4 +- src/Model/Config/TypeDefinitionType.php | 4 +- src/Tool/Assert.php | 30 +++++----- src/Tool/Attribute.php | 6 +- src/Tool/Converter.php | 14 ++--- src/Tool/PhpStan.php | 24 ++++---- tests/DumpCommandTest.php | 74 +++++++++++------------ 9 files changed, 122 insertions(+), 116 deletions(-) diff --git a/src/Command/DumpCommand.php b/src/Command/DumpCommand.php index d240a4b..c1024b0 100644 --- a/src/Command/DumpCommand.php +++ b/src/Command/DumpCommand.php @@ -26,8 +26,8 @@ abstract class DumpCommand extends Command use HasConfiguration; use HasDumper; - final public const INDENT_STYLE_KEY = C::INDENT_KEY . '-' . C::INDENT_STYLE_KEY; - final public const INDENT_COUNT_KEY = C::INDENT_KEY . '-' . C::INDENT_COUNT_KEY; + final protected const INDENT_STYLE_KEY = C::INDENT_KEY . '-' . C::INDENT_STYLE_KEY; + final protected const INDENT_COUNT_KEY = C::INDENT_KEY . '-' . C::INDENT_COUNT_KEY; protected InputInterface $input; diff --git a/src/Interface/Config.php b/src/Interface/Config.php index c8d4fdb..9fbcea2 100644 --- a/src/Interface/Config.php +++ b/src/Interface/Config.php @@ -30,50 +30,50 @@ */ interface Config { - public const OUTPUT_DIR_KEY = 'output_dir'; - public const OUTPUT_DIR_DEFAULT = 'assets/ts/types/php-to-ts'; - public const OUTPUT_DIR_DESC = 'Directory in which to dump TypeScript interfaces'; - - public const INPUT_DIR_KEY = 'input_dir'; - public const INPUT_DIR_DEFAULT = 'src/Model'; - public const INPUT_DIR_DESC = 'Directory in which to look for models to include'; - - public const FILE_TYPE_KEY = 'file_type'; - public const FILE_TYPE_DEFAULT = FileType::TYPE_MODULE; - public const FILE_TYPE_DESC = 'File type to use for TypeScript interfaces'; - public const FILE_TYPE_VALID_VALUES = [FileType::TYPE_DECLARATION, FileType::TYPE_MODULE]; - - public const TYPE_DEFINITION_TYPE_KEY = 'type_definition_type'; - public const TYPE_DEFINITION_TYPE_DEFAULT = TypeDefinitionType::TYPE_INTERFACE; - public const TYPE_DEFINITION_TYPE_DESC = 'Type definition type to use for TypeScript interfaces'; - public const TYPE_DEFINITION_TYPE_VALID_VALUES = [TypeDefinitionType::TYPE_INTERFACE, TypeDefinitionType::TYPE_TYPE_ALIAS]; - - public const INDENT_KEY = 'indent'; - public const INDENT_DESC = 'Indentation used for TypeScript interfaces'; - public const INDENT_STYLE_KEY = 'style'; - public const INDENT_STYLE_DEFAULT = Indent::STYLE_SPACE; - public const INDENT_STYLE_DESC = 'Indent style used for TypeScript interfaces'; - public const INDENT_STYLE_VALID_VALUES = [Indent::STYLE_SPACE, Indent::STYLE_TAB]; - public const INDENT_COUNT_KEY = 'count'; - public const INDENT_COUNT_DEFAULT = 2; - public const INDENT_COUNT_DESC = 'Number of indent style characters per indent'; - - public const QUOTES_KEY = 'quotes'; - public const QUOTES_DESC = 'Quote style used for strings in TypeScript interfaces'; - public const QUOTES_DEFAULT = Quotes::STYLE_SINGLE; - public const QUOTES_VALID_VALUES = [Quotes::STYLE_DOUBLE, Quotes::STYLE_SINGLE]; - - public const SORT_STRATEGIES_KEY = 'sort_strategies'; - public const SORT_STRATEGIES_DEFAULT = [ + final public const OUTPUT_DIR_KEY = 'output_dir'; + final public const OUTPUT_DIR_DEFAULT = 'assets/ts/types/php-to-ts'; + final public const OUTPUT_DIR_DESC = 'Directory in which to dump TypeScript interfaces'; + + final public const INPUT_DIR_KEY = 'input_dir'; + final public const INPUT_DIR_DEFAULT = 'src/Model'; + final public const INPUT_DIR_DESC = 'Directory in which to look for models to include'; + + final public const FILE_TYPE_KEY = 'file_type'; + final public const FILE_TYPE_DEFAULT = FileType::TYPE_MODULE; + final public const FILE_TYPE_DESC = 'File type to use for TypeScript interfaces'; + final public const FILE_TYPE_VALID_VALUES = [FileType::TYPE_DECLARATION, FileType::TYPE_MODULE]; + + final public const TYPE_DEFINITION_TYPE_KEY = 'type_definition_type'; + final public const TYPE_DEFINITION_TYPE_DEFAULT = TypeDefinitionType::TYPE_INTERFACE; + final public const TYPE_DEFINITION_TYPE_DESC = 'Type definition type to use for TypeScript interfaces'; + final public const TYPE_DEFINITION_TYPE_VALID_VALUES = [TypeDefinitionType::TYPE_INTERFACE, TypeDefinitionType::TYPE_TYPE_ALIAS]; + + final public const INDENT_KEY = 'indent'; + final public const INDENT_DESC = 'Indentation used for TypeScript interfaces'; + final public const INDENT_STYLE_KEY = 'style'; + final public const INDENT_STYLE_DEFAULT = Indent::STYLE_SPACE; + final public const INDENT_STYLE_DESC = 'Indent style used for TypeScript interfaces'; + final public const INDENT_STYLE_VALID_VALUES = [Indent::STYLE_SPACE, Indent::STYLE_TAB]; + final public const INDENT_COUNT_KEY = 'count'; + final public const INDENT_COUNT_DEFAULT = 2; + final public const INDENT_COUNT_DESC = 'Number of indent style characters per indent'; + + final public const QUOTES_KEY = 'quotes'; + final public const QUOTES_DESC = 'Quote style used for strings in TypeScript interfaces'; + final public const QUOTES_DEFAULT = Quotes::STYLE_SINGLE; + final public const QUOTES_VALID_VALUES = [Quotes::STYLE_DOUBLE, Quotes::STYLE_SINGLE]; + + final public const SORT_STRATEGIES_KEY = 'sort_strategies'; + final public const SORT_STRATEGIES_DEFAULT = [ AlphabeticalAsc::class, ConstructorFirst::class, ReadonlyFirst::class, ]; - public const SORT_STRATEGIES_DESC = 'Class names of sort strategies used for TypeScript properties'; + final public const SORT_STRATEGIES_DESC = 'Class names of sort strategies used for TypeScript properties'; - public const FILE_NAME_STRATEGY_KEY = 'file_name_strategy'; - public const FILE_NAME_STRATEGY_DEFAULT = KebabCase::class; - public const FILE_NAME_STRATEGY_DESC = 'Class name of file name strategies used for TypeScript files'; + final public const FILE_NAME_STRATEGY_KEY = 'file_name_strategy'; + final public const FILE_NAME_STRATEGY_DEFAULT = KebabCase::class; + final public const FILE_NAME_STRATEGY_DESC = 'Class name of file name strategies used for TypeScript files'; public function getInputDir(): ?string; diff --git a/src/Model/Config/FileType.php b/src/Model/Config/FileType.php index b0b59de..4a1df9e 100644 --- a/src/Model/Config/FileType.php +++ b/src/Model/Config/FileType.php @@ -4,8 +4,10 @@ namespace Brainshaker95\PhpToTsBundle\Model\Config; -abstract class FileType +final class FileType { public const TYPE_DECLARATION = 'declaration'; public const TYPE_MODULE = 'module'; + + private function __construct() {} } diff --git a/src/Model/Config/TypeDefinitionType.php b/src/Model/Config/TypeDefinitionType.php index 4d7af4d..382e67c 100644 --- a/src/Model/Config/TypeDefinitionType.php +++ b/src/Model/Config/TypeDefinitionType.php @@ -4,8 +4,10 @@ namespace Brainshaker95\PhpToTsBundle\Model\Config; -abstract class TypeDefinitionType +final class TypeDefinitionType { public const TYPE_INTERFACE = 'interface'; public const TYPE_TYPE_ALIAS = 'type'; + + private function __construct() {} } diff --git a/src/Tool/Assert.php b/src/Tool/Assert.php index 53a4d07..e57dd1e 100644 --- a/src/Tool/Assert.php +++ b/src/Tool/Assert.php @@ -23,7 +23,7 @@ /** * @internal */ -abstract class Assert +final class Assert { private function __construct() {} @@ -32,7 +32,7 @@ private function __construct() {} * * @return non-empty-string */ - final public static function nonEmptyStringNonNullable(mixed $value): string + public static function nonEmptyStringNonNullable(mixed $value): string { if (!is_string($value) || !$value) { throw new AssertionFailedException(sprintf( @@ -49,7 +49,7 @@ final public static function nonEmptyStringNonNullable(mixed $value): string * * @return ?non-empty-string */ - final public static function nonEmptyStringNullable(mixed $value): ?string + public static function nonEmptyStringNullable(mixed $value): ?string { if ($value === null) { return $value; @@ -63,7 +63,7 @@ final public static function nonEmptyStringNullable(mixed $value): ?string * * @return int<0,max> */ - final public static function nonNegativeIntegerNonNullable(mixed $value): int + public static function nonNegativeIntegerNonNullable(mixed $value): int { $intval = is_numeric($value) ? (int) $value : -1; @@ -82,7 +82,7 @@ final public static function nonNegativeIntegerNonNullable(mixed $value): int * * @return ?int<0,max> */ - final public static function nonNegativeIntegerNullable(mixed $value): ?int + public static function nonNegativeIntegerNullable(mixed $value): ?int { if ($value === null) { return $value; @@ -96,7 +96,7 @@ final public static function nonNegativeIntegerNullable(mixed $value): ?int * * @return non-empty-string[] */ - final public static function nonEmptyStringArrayNonNullable(mixed $value): array + public static function nonEmptyStringArrayNonNullable(mixed $value): array { if (!is_array($value) || count(array_filter($value, static fn (mixed $val) => !is_string($val) || !$val))) { @@ -114,7 +114,7 @@ final public static function nonEmptyStringArrayNonNullable(mixed $value): array * * @return ?non-empty-string[] */ - final public static function nonEmptyStringArrayNullable(mixed $value): ?array + public static function nonEmptyStringArrayNullable(mixed $value): ?array { if ($value === null) { return $value; @@ -132,7 +132,7 @@ final public static function nonEmptyStringArrayNullable(mixed $value): ?array * * @return value-of */ - final public static function inStringArrayNonNullable(mixed $value, array $allowedStrings): string + public static function inStringArrayNonNullable(mixed $value, array $allowedStrings): string { if (!is_string($value) || !in_array($value, $allowedStrings, true)) { throw new AssertionFailedException(sprintf( @@ -154,7 +154,7 @@ final public static function inStringArrayNonNullable(mixed $value, array $allow * * @return ?value-of */ - final public static function inStringArrayNullable(mixed $value, array $allowedStrings): ?string + public static function inStringArrayNullable(mixed $value, array $allowedStrings): ?string { if ($value === null) { return $value; @@ -172,7 +172,7 @@ final public static function inStringArrayNullable(mixed $value, array $allowedS * * @return T */ - final public static function instanceOf(object $value, string $class): object + public static function instanceOf(object $value, string $class): object { if (!$value instanceof $class) { throw new AssertionFailedException(sprintf( @@ -194,7 +194,7 @@ final public static function instanceOf(object $value, string $class): object * * @return class-string */ - final public static function interfaceClassStringNonNullable(mixed $value, string $class): string + public static function interfaceClassStringNonNullable(mixed $value, string $class): string { if (!is_string($value) || !is_a($value, $class, true) @@ -218,7 +218,7 @@ final public static function interfaceClassStringNonNullable(mixed $value, strin * * @return ?class-string */ - final public static function interfaceClassStringNullable(mixed $value, string $class): ?string + public static function interfaceClassStringNullable(mixed $value, string $class): ?string { if ($value === null) { return $value; @@ -236,7 +236,7 @@ final public static function interfaceClassStringNullable(mixed $value, string $ * * @return class-string[] */ - final public static function interfaceClassStringArrayNonNullable(mixed $value, string $class): array + public static function interfaceClassStringArrayNonNullable(mixed $value, string $class): array { return array_map( static fn (string $val) => self::interfaceClassStringNonNullable($val, $class), @@ -253,7 +253,7 @@ final public static function interfaceClassStringArrayNonNullable(mixed $value, * * @return ?class-string[] */ - final public static function interfaceClassStringArrayNullable(mixed $value, string $class): ?array + public static function interfaceClassStringArrayNullable(mixed $value, string $class): ?array { if ($value === null) { return $value; @@ -265,7 +265,7 @@ final public static function interfaceClassStringArrayNullable(mixed $value, str /** * @param object|class-string $class */ - final public static function existingClassAttribute(object|string $class, string $attribute): void + public static function existingClassAttribute(object|string $class, string $attribute): void { if (!Attribute::existsOnClass($attribute, $class)) { throw new AssertionFailedException(sprintf( diff --git a/src/Tool/Attribute.php b/src/Tool/Attribute.php index e2dbc33..761e2bb 100644 --- a/src/Tool/Attribute.php +++ b/src/Tool/Attribute.php @@ -14,14 +14,14 @@ /** * @internal */ -abstract class Attribute +final class Attribute { private function __construct() {} /** * @param object|class-string $class */ - final public static function existsOnClass(string $attribute, object|string $class): bool + public static function existsOnClass(string $attribute, object|string $class): bool { return (is_string($class) && !class_exists($class)) ? false @@ -31,7 +31,7 @@ final public static function existsOnClass(string $attribute, object|string $cla /** * @param object|class-string $class */ - final public static function existsOnProperty(string $attribute, object|string $class, string $propertyName): bool + public static function existsOnProperty(string $attribute, object|string $class, string $propertyName): bool { if (is_string($class) && !class_exists($class)) { return false; diff --git a/src/Tool/Converter.php b/src/Tool/Converter.php index 2740fb1..f937b1c 100644 --- a/src/Tool/Converter.php +++ b/src/Tool/Converter.php @@ -59,7 +59,7 @@ /** * @internal */ -abstract class Converter +final class Converter { public const TYPE_ARRAY = 'array'; public const TYPE_ARRAY_KEY = 'array-key'; @@ -138,7 +138,7 @@ abstract class Converter private function __construct() {} - final public static function toInterface(Class_ $node, bool $isReadonly): TsInterface + public static function toInterface(Class_ $node, bool $isReadonly): TsInterface { $name = $node->name?->name; @@ -170,7 +170,7 @@ final public static function toInterface(Class_ $node, bool $isReadonly): TsInte /** * @throws InvalidEnumException */ - final public static function toEnum(Enum_ $node): TsEnum + public static function toEnum(Enum_ $node): TsEnum { $name = $node->name?->name; @@ -209,7 +209,7 @@ final public static function toEnum(Enum_ $node): TsEnum /** * @throws InvalidPropertyException */ - final public static function toProperty( + public static function toProperty( Param|Property|EnumCase $property, bool $isReadonly, ?Doc $docComment, @@ -275,7 +275,7 @@ classIdentifiers: $classIdentifiers, /** * @param Node[] $nodes */ - final public static function applyIndentAndQuotes( + public static function applyIndentAndQuotes( array $nodes, Indent $indent, Quotes $quotes, @@ -326,7 +326,7 @@ final public static function applyIndentAndQuotes( /** * @return Node[] */ - final public static function getNextLevelNodes(Node $node): array + public static function getNextLevelNodes(Node $node): array { return match (true) { default => [], @@ -343,7 +343,7 @@ final public static function getNextLevelNodes(Node $node): array }; } - final public static function getClassIdentifierNode(Node $node): ?IdentifierTypeNode + public static function getClassIdentifierNode(Node $node): ?IdentifierTypeNode { return match (true) { default => null, diff --git a/src/Tool/PhpStan.php b/src/Tool/PhpStan.php index a2db250..a10a260 100644 --- a/src/Tool/PhpStan.php +++ b/src/Tool/PhpStan.php @@ -41,12 +41,12 @@ /** * @internal */ -abstract class PhpStan +final class PhpStan { /** * @var array,class-string> */ - public const NODE_CLASS_MAP = [ + private const NODE_CLASS_MAP = [ PHPStanConstExpr\ConstExprFalseNode::class => ConstExpr\ConstExprFalseNode::class, PHPStanConstExpr\ConstExprFloatNode::class => ConstExpr\ConstExprFloatNode::class, PHPStanConstExpr\ConstExprIntegerNode::class => ConstExpr\ConstExprIntegerNode::class, @@ -73,7 +73,7 @@ abstract class PhpStan private function __construct() {} - final public static function toNode(PHPStanNode $node): Node + public static function toNode(PHPStanNode $node): Node { $nodeClass = self::NODE_CLASS_MAP[$node::class] ?? null; @@ -87,7 +87,7 @@ final public static function toNode(PHPStanNode $node): Node return $nodeClass::fromPhpStan($node); } - final public static function getDocNode(Doc $docComment): PhpDocNode + public static function getDocNode(Doc $docComment): PhpDocNode { self::$lexer ??= new Lexer(); self::$constExprParser ??= new ConstExprParser(); @@ -98,7 +98,7 @@ final public static function getDocNode(Doc $docComment): PhpDocNode )); } - final public static function getParamNode(PhpDocNode $docNode, string $name): ParamTagValueNode|TypelessParamTagValueNode|null + public static function getParamNode(PhpDocNode $docNode, string $name): ParamTagValueNode|TypelessParamTagValueNode|null { $values = [ ...$docNode->getParamTagValues('@param'), @@ -115,7 +115,7 @@ final public static function getParamNode(PhpDocNode $docNode, string $name): Pa )) ?: null; } - final public static function getVarNode(PhpDocNode $docNode): ?VarTagValueNode + public static function getVarNode(PhpDocNode $docNode): ?VarTagValueNode { $values = [ ...$docNode->getVarTagValues('@var'), @@ -126,7 +126,7 @@ final public static function getVarNode(PhpDocNode $docNode): ?VarTagValueNode return current($values) ?: null; } - final public static function getDeprecatedNode(PhpDocNode $docNode): ?DeprecatedTagValueNode + public static function getDeprecatedNode(PhpDocNode $docNode): ?DeprecatedTagValueNode { return current($docNode->getDeprecatedTagValues()) ?: null; } @@ -134,7 +134,7 @@ final public static function getDeprecatedNode(PhpDocNode $docNode): ?Deprecated /** * @return TemplateTagValueNode[] */ - final public static function getTemplateNodes(PhpDocNode $docNode): array + public static function getTemplateNodes(PhpDocNode $docNode): array { return [ ...$docNode->getTemplateTagValues('@template'), @@ -146,7 +146,7 @@ final public static function getTemplateNodes(PhpDocNode $docNode): array /** * @return PhpDocTextNode[] */ - final public static function getTextNodes(PhpDocNode $docNode): array + public static function getTextNodes(PhpDocNode $docNode): array { return array_filter( $docNode->children, @@ -157,7 +157,7 @@ final public static function getTextNodes(PhpDocNode $docNode): array /** * @param PhpDocTextNode[] $textNodes */ - final public static function textNodesToString(array $textNodes): string + public static function textNodesToString(array $textNodes): string { return implode("\n", array_map( static fn (PhpDocTextNode $textNode) => $textNode->text, @@ -165,7 +165,7 @@ final public static function textNodesToString(array $textNodes): string )); } - final public static function phpValueToTsType( + public static function phpValueToTsType( mixed $value, Indent $indent = new Indent(), Quotes $quotes = new Quotes(), @@ -191,7 +191,7 @@ final public static function phpValueToTsType( return $shapeNode->toString(); } - final public static function phpValueToNode(mixed $value): Node + public static function phpValueToNode(mixed $value): Node { $docComment = new Doc('/** @var ' . Str::displayType($value) . ' */'); $docNode = self::getDocNode($docComment); diff --git a/tests/DumpCommandTest.php b/tests/DumpCommandTest.php index 1bc5839..b0dd4c5 100644 --- a/tests/DumpCommandTest.php +++ b/tests/DumpCommandTest.php @@ -4,7 +4,6 @@ namespace App\Tests; -use Brainshaker95\PhpToTsBundle\Command\DumpCommand; use Brainshaker95\PhpToTsBundle\Interface\Config as C; use Brainshaker95\PhpToTsBundle\Model\Config\FileNameStrategy\PascalCase; use Brainshaker95\PhpToTsBundle\Model\Config\FileNameStrategy\SnakeCase; @@ -40,6 +39,9 @@ */ final class DumpCommandTest extends KernelTestCase { + private const INDENT_STYLE_KEY = C::INDENT_KEY . '-' . C::INDENT_STYLE_KEY; + private const INDENT_COUNT_KEY = C::INDENT_KEY . '-' . C::INDENT_COUNT_KEY; + private Filesystem $filesystem; private string $inputDir; @@ -80,15 +82,15 @@ public function testDumpDirWithAllOptionsChanged(): void { $this->assertCommandSuccess( code: self::runCommand('phptots:dump:dir', [ - Str::toKebab(C::INPUT_DIR_KEY) => $this->inputDir, - '--' . Str::toKebab(C::OUTPUT_DIR_KEY) => $this->outputDir . '/SubDir', - '--' . Str::toKebab(C::FILE_TYPE_KEY) => FileType::TYPE_DECLARATION, - '--' . Str::toKebab(C::TYPE_DEFINITION_TYPE_KEY) => TypeDefinitionType::TYPE_TYPE_ALIAS, - '--' . Str::toKebab(DumpCommand::INDENT_STYLE_KEY) => Indent::STYLE_TAB, - '--' . Str::toKebab(DumpCommand::INDENT_COUNT_KEY) => 3, - '--' . Str::toKebab(C::QUOTES_KEY) => Quotes::STYLE_DOUBLE, - '--' . Str::toKebab(C::SORT_STRATEGIES_KEY) => [AlphabeticalDesc::class], - '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => SnakeCase::class, + Str::toKebab(C::INPUT_DIR_KEY) => $this->inputDir, + '--' . Str::toKebab(C::OUTPUT_DIR_KEY) => $this->outputDir . '/SubDir', + '--' . Str::toKebab(C::FILE_TYPE_KEY) => FileType::TYPE_DECLARATION, + '--' . Str::toKebab(C::TYPE_DEFINITION_TYPE_KEY) => TypeDefinitionType::TYPE_TYPE_ALIAS, + '--' . Str::toKebab(self::INDENT_STYLE_KEY) => Indent::STYLE_TAB, + '--' . Str::toKebab(self::INDENT_COUNT_KEY) => 3, + '--' . Str::toKebab(C::QUOTES_KEY) => Quotes::STYLE_DOUBLE, + '--' . Str::toKebab(C::SORT_STRATEGIES_KEY) => [AlphabeticalDesc::class], + '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => SnakeCase::class, ], isVerbose: true), outputDir: $this->outputDir . '/SubDir', expectedFileCount: 3, @@ -99,8 +101,8 @@ public function testDumpDirWithSomeOptionsChanged(): void { $this->assertCommandSuccess( code: self::runCommand('phptots:dump:dir', [ - '--' . Str::toKebab(DumpCommand::INDENT_COUNT_KEY) => 3, - '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => PascalCase::class, + '--' . Str::toKebab(self::INDENT_COUNT_KEY) => 3, + '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => PascalCase::class, ]), outputDir: $this->outputDir, expectedFileCount: 3, @@ -159,15 +161,15 @@ public function testDumpFilesWithAllOptionsChanged(): void { $this->assertCommandSuccess( code: self::runCommand('phptots:dump:files', [ - 'input-files' => [$this->inputDir], - '--' . Str::toKebab(C::OUTPUT_DIR_KEY) => $this->outputDir . '/SubDir', - '--' . Str::toKebab(C::FILE_TYPE_KEY) => FileType::TYPE_DECLARATION, - '--' . Str::toKebab(C::TYPE_DEFINITION_TYPE_KEY) => TypeDefinitionType::TYPE_TYPE_ALIAS, - '--' . Str::toKebab(DumpCommand::INDENT_STYLE_KEY) => Indent::STYLE_TAB, - '--' . Str::toKebab(DumpCommand::INDENT_COUNT_KEY) => 3, - '--' . Str::toKebab(C::QUOTES_KEY) => Quotes::STYLE_DOUBLE, - '--' . Str::toKebab(C::SORT_STRATEGIES_KEY) => [AlphabeticalDesc::class], - '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => SnakeCase::class, + 'input-files' => [$this->inputDir], + '--' . Str::toKebab(C::OUTPUT_DIR_KEY) => $this->outputDir . '/SubDir', + '--' . Str::toKebab(C::FILE_TYPE_KEY) => FileType::TYPE_DECLARATION, + '--' . Str::toKebab(C::TYPE_DEFINITION_TYPE_KEY) => TypeDefinitionType::TYPE_TYPE_ALIAS, + '--' . Str::toKebab(self::INDENT_STYLE_KEY) => Indent::STYLE_TAB, + '--' . Str::toKebab(self::INDENT_COUNT_KEY) => 3, + '--' . Str::toKebab(C::QUOTES_KEY) => Quotes::STYLE_DOUBLE, + '--' . Str::toKebab(C::SORT_STRATEGIES_KEY) => [AlphabeticalDesc::class], + '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => SnakeCase::class, ], isVerbose: true), outputDir: $this->outputDir . '/SubDir', expectedFileCount: 3, @@ -178,9 +180,9 @@ public function testDumpFilesWithSomeOptionsChanged(): void { $this->assertCommandSuccess( code: self::runCommand('phptots:dump:files', [ - 'input-files' => [$this->inputDir], - '--' . Str::toKebab(DumpCommand::INDENT_COUNT_KEY) => 3, - '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => PascalCase::class, + 'input-files' => [$this->inputDir], + '--' . Str::toKebab(self::INDENT_COUNT_KEY) => 3, + '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => PascalCase::class, ]), outputDir: $this->outputDir, expectedFileCount: 3, @@ -211,15 +213,15 @@ public function testDumpFileWithAllOptionsChanged(): void { $this->assertCommandSuccess( code: self::runCommand('phptots:dump:file', [ - 'input-file' => $this->inputDir . '/SubDir/GenericTypes.php', - '--' . Str::toKebab(C::OUTPUT_DIR_KEY) => $this->outputDir . '/SubDir', - '--' . Str::toKebab(C::FILE_TYPE_KEY) => FileType::TYPE_DECLARATION, - '--' . Str::toKebab(C::TYPE_DEFINITION_TYPE_KEY) => TypeDefinitionType::TYPE_TYPE_ALIAS, - '--' . Str::toKebab(DumpCommand::INDENT_STYLE_KEY) => Indent::STYLE_TAB, - '--' . Str::toKebab(DumpCommand::INDENT_COUNT_KEY) => 3, - '--' . Str::toKebab(C::QUOTES_KEY) => Quotes::STYLE_DOUBLE, - '--' . Str::toKebab(C::SORT_STRATEGIES_KEY) => [AlphabeticalDesc::class], - '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => SnakeCase::class, + 'input-file' => $this->inputDir . '/SubDir/GenericTypes.php', + '--' . Str::toKebab(C::OUTPUT_DIR_KEY) => $this->outputDir . '/SubDir', + '--' . Str::toKebab(C::FILE_TYPE_KEY) => FileType::TYPE_DECLARATION, + '--' . Str::toKebab(C::TYPE_DEFINITION_TYPE_KEY) => TypeDefinitionType::TYPE_TYPE_ALIAS, + '--' . Str::toKebab(self::INDENT_STYLE_KEY) => Indent::STYLE_TAB, + '--' . Str::toKebab(self::INDENT_COUNT_KEY) => 3, + '--' . Str::toKebab(C::QUOTES_KEY) => Quotes::STYLE_DOUBLE, + '--' . Str::toKebab(C::SORT_STRATEGIES_KEY) => [AlphabeticalDesc::class], + '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => SnakeCase::class, ], isVerbose: true), outputDir: $this->outputDir . '/SubDir', expectedFileCount: 1, @@ -230,9 +232,9 @@ public function testDumpFileWithSomeOptionsChanged(): void { $this->assertCommandSuccess( code: self::runCommand('phptots:dump:file', [ - 'input-file' => $this->inputDir . '/NativeTypes.php', - '--' . Str::toKebab(DumpCommand::INDENT_COUNT_KEY) => 3, - '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => PascalCase::class, + 'input-file' => $this->inputDir . '/NativeTypes.php', + '--' . Str::toKebab(self::INDENT_COUNT_KEY) => 3, + '--' . Str::toKebab(C::FILE_NAME_STRATEGY_KEY) => PascalCase::class, ]), outputDir: $this->outputDir, expectedFileCount: 1,