From 6ee1c97d11516199ff9866ddd231e92f76d0732a Mon Sep 17 00:00:00 2001 From: Ruben Van Assche Date: Thu, 29 Aug 2024 12:55:37 +0200 Subject: [PATCH] wip --- README.md | 8 ++-- composer.json | 2 +- src/Actions/ConnectReferencesAction.php | 2 +- src/Actions/DiscoverTypesAction.php | 2 - src/Actions/FindClassNameFqcnAction.php | 8 +++- src/Actions/ParseUseDefinitionsAction.php | 45 ------------------- src/Actions/ParseUserDefinedTypeAction.php | 2 +- ...spilePhpStanTypeToTypeScriptNodeAction.php | 34 +++++++------- ...leReflectionTypeToTypeScriptNodeAction.php | 28 ++++++------ src/Attributes/LiteralTypeScriptType.php | 8 ++-- src/Attributes/TypeScriptType.php | 6 +-- .../TypeScriptTypeAttributeContract.php | 2 +- ...ayLikeStructuresClassPropertyProcessor.php | 14 +++--- src/Collections/ImportsCollection.php | 2 +- src/Data/ImportLocation.php | 2 +- .../DataClassPropertyProcessor.php | 8 ++-- src/Laravel/LaravelDataTypesProvider.php | 8 ++-- .../LaravelNamedRouteTypesProvider.php | 34 +++++++------- .../LaravelRouteActionTypesProvider.php | 38 ++++++++-------- .../LaravelTypeScriptTransformerExtension.php | 2 +- src/Laravel/LaravelTypesProvider.php | 22 ++++----- src/Laravel/SpatieLaravelTypesProvider.php | 12 ++--- src/Transformed/Transformed.php | 8 ++-- .../ClassPropertyProcessor.php | 2 +- src/Transformers/ClassTransformer.php | 12 ++--- src/Transformers/EnumTransformer.php | 12 ++--- src/Transformers/InterfaceTransformer.php | 16 +++---- .../TypeReference.php | 2 +- .../TypeScriptAlias.php | 2 +- .../TypeScriptAny.php | 2 +- .../TypeScriptArray.php | 2 +- .../TypeScriptBoolean.php | 2 +- .../TypeScriptConditional.php | 2 +- .../TypeScriptEnum.php | 2 +- .../TypeScriptExport.php | 2 +- .../TypeScriptForwardingNamedNode.php | 2 +- .../TypeScriptFunction.php | 2 +- .../TypeScriptFunctionDefinition.php | 2 +- .../TypeScriptGeneric.php | 2 +- .../TypeScriptGenericTypeVariable.php | 2 +- .../TypeScriptIdentifier.php | 2 +- .../TypeScriptImport.php | 2 +- .../TypeScriptIndexSignature.php | 2 +- .../TypeScriptIndexedAccess.php | 2 +- .../TypeScriptInterface.php | 2 +- .../TypeScriptInterfaceMethod.php | 2 +- .../TypeScriptIntersection.php | 2 +- .../TypeScriptLiteral.php | 2 +- .../TypeScriptNamedNode.php | 2 +- .../TypeScriptNamespace.php | 2 +- .../TypeScriptNode.php | 3 +- .../TypeScriptNull.php | 2 +- .../TypeScriptNumber.php | 2 +- .../TypeScriptObject.php | 2 +- .../TypeScriptOperator.php | 2 +- .../TypeScriptParameter.php | 2 +- .../TypeScriptProperty.php | 2 +- .../TypeScriptRaw.php | 2 +- .../TypeScriptString.php | 2 +- .../TypeScriptUndefined.php | 2 +- .../TypeScriptUnion.php | 2 +- .../TypeScriptUnknown.php | 2 +- .../TypeScriptVisitableNode.php | 2 +- .../TypeScriptVoid.php | 2 +- src/TypeScriptTransformerConfigFactory.php | 6 +-- .../Common/ReplaceTypesVisitorClosure.php | 4 +- src/Visitor/Visitor.php | 4 +- src/Visitor/VisitorClosure.php | 2 +- src/Visitor/VisitorOperation.php | 2 +- src/Writers/NamespaceWriter.php | 2 +- tests/Actions/ConnectReferencesActionTest.php | 2 +- .../ParseUserDefinedTypeActionTest.php | 6 +-- tests/Actions/ProvideTypesActionTest.php | 2 +- .../ResolveModuleImportsActionTest.php | 6 +-- .../SplitTransformedPerLocationActionTest.php | 2 +- ...ePhpStanTypeToTypeScriptNodeActionTest.php | 34 +++++++------- ...flectionTypeToTypeScriptNodeActionTest.php | 26 +++++------ ...keStructuresClassPropertyProcessorTest.php | 20 ++++----- tests/Factories/TransformedFactory.php | 6 +-- .../LaravelRouteActionTypesProviderTest.php | 14 ++++++ tests/Support/MemoryWriter.php | 2 +- tests/Transformers/ClassTransformerTest.php | 16 +++---- .../TransformerTypesProviderTest.php | 10 ++--- tests/TypeReplacements.php | 18 ++++---- tests/TypeScript/TypeScriptEnumTest.php | 2 +- tests/Visitor/VisitorTest.php | 10 ++--- tests/VisitorClosures.php | 8 ++-- tests/Writers/FlatWriterTest.php | 8 ++-- tests/Writers/ModuleWriterTest.php | 8 ++-- tests/Writers/NamespaceWriterTest.php | 8 ++-- 90 files changed, 307 insertions(+), 335 deletions(-) delete mode 100644 src/Actions/ParseUseDefinitionsAction.php rename src/{TypeScript => TypeScriptNodes}/TypeReference.php (94%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptAlias.php (93%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptAny.php (78%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptArray.php (92%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptBoolean.php (79%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptConditional.php (92%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptEnum.php (94%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptExport.php (91%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptForwardingNamedNode.php (72%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptFunction.php (80%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptFunctionDefinition.php (95%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptGeneric.php (94%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptGenericTypeVariable.php (94%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptIdentifier.php (89%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptImport.php (90%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptIndexSignature.php (91%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptIndexedAccess.php (93%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptInterface.php (95%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptInterfaceMethod.php (94%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptIntersection.php (92%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptLiteral.php (84%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptNamedNode.php (59%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptNamespace.php (91%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptNode.php (63%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptNull.php (79%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptNumber.php (79%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptObject.php (93%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptOperator.php (96%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptParameter.php (93%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptProperty.php (95%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptRaw.php (84%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptString.php (79%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptUndefined.php (79%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptUnion.php (94%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptUnknown.php (79%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptVisitableNode.php (73%) rename src/{TypeScript => TypeScriptNodes}/TypeScriptVoid.php (79%) create mode 100644 tests/Laravel/LaravelRouteActionTypesProviderTest.php diff --git a/README.md b/README.md index 5102593..78a2470 100644 --- a/README.md +++ b/README.md @@ -567,7 +567,7 @@ $config->replaceType(DateTimeInterface::class, new TypeScriptString()); Or use a closure to define the replacement: ```php -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; $config->replaceType(DateTimeInterface::class, function (TypeReference $reference) { return new TypeScriptString(); @@ -582,7 +582,7 @@ types and it is possible to create your own nodes. For example, a TypeScript alias is representing a User object looks like this: ```php -use Spatie\TypeScriptTransformer\TypeScript; +use Spatie\TypeScriptTransformer\TypeScriptNodes; new TypeScriptAlias( new TypeScriptIdentifier('User'), @@ -1012,8 +1012,8 @@ A TypeScript node is a regular PHP class that implements the `TypeScriptNode` in ```php use Spatie\TypeScriptTransformer\Support\WritingContext; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNamedNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNamedNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; class PickNode implements TypeScriptNode, TypeScriptNamedNode { diff --git a/composer.json b/composer.json index 177905c..323cf27 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "phpstan/phpdoc-parser": "^1.13", "spatie/file-system-watcher": "^1.1", "spatie/laravel-package-tools": "^1.14.0", - "spatie/php-structure-discoverer": "^2.1", + "spatie/php-structure-discoverer": "^2.2", "spatie/temporary-directory": "^2.1" }, "require-dev": { diff --git a/src/Actions/ConnectReferencesAction.php b/src/Actions/ConnectReferencesAction.php index dc7283c..ba11f1d 100644 --- a/src/Actions/ConnectReferencesAction.php +++ b/src/Actions/ConnectReferencesAction.php @@ -6,7 +6,7 @@ use Spatie\TypeScriptTransformer\Support\TransformedCollection; use Spatie\TypeScriptTransformer\Support\TypeScriptTransformerLog; use Spatie\TypeScriptTransformer\Transformed\Transformed; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; use Spatie\TypeScriptTransformer\Visitor\Visitor; class ConnectReferencesAction diff --git a/src/Actions/DiscoverTypesAction.php b/src/Actions/DiscoverTypesAction.php index 80f2310..21d24a5 100644 --- a/src/Actions/DiscoverTypesAction.php +++ b/src/Actions/DiscoverTypesAction.php @@ -14,8 +14,6 @@ class DiscoverTypesAction public function execute( array $directories = [], ): array { - // Idea / TODO : make it possible for other packages to hook in to find types in other directories, like their vendor dir - return Discover::in(...$directories) ->types( DiscoveredStructureType::ClassDefinition, diff --git a/src/Actions/FindClassNameFqcnAction.php b/src/Actions/FindClassNameFqcnAction.php index 7d2a4c3..411ad35 100644 --- a/src/Actions/FindClassNameFqcnAction.php +++ b/src/Actions/FindClassNameFqcnAction.php @@ -4,12 +4,18 @@ use ReflectionClass; use Spatie\StructureDiscoverer\Collections\UsageCollection; +use Spatie\StructureDiscoverer\Support\UseDefinitionsResolver; class FindClassNameFqcnAction { /** @var array */ protected static array $cache = []; + public function __construct( + protected UseDefinitionsResolver $useDefinitionsResolver = new UseDefinitionsResolver() + ) { + } + public function execute(ReflectionClass $reflectionClass, string $className): ?string { $usages = $this->loadUsages($reflectionClass); @@ -38,7 +44,7 @@ protected function loadUsages(ReflectionClass $reflectionClass): UsageCollection $filename = $reflectionClass->getFileName(); if (! array_key_exists($filename, static::$cache)) { - static::$cache[$filename] = (new ParseUseDefinitionsAction())->execute($filename); + static::$cache[$filename] = $this->useDefinitionsResolver->execute($filename); } return static::$cache[$filename]; diff --git a/src/Actions/ParseUseDefinitionsAction.php b/src/Actions/ParseUseDefinitionsAction.php deleted file mode 100644 index 8ec6a17..0000000 --- a/src/Actions/ParseUseDefinitionsAction.php +++ /dev/null @@ -1,45 +0,0 @@ -reject(fn (PhpToken $token) => $token->is([T_COMMENT, T_DOC_COMMENT, T_WHITESPACE])) - ->values() - ->pipe(fn (Collection $collection): TokenCollection => new TokenCollection($collection->all())); - } catch (ParseError) { - return new UsageCollection(); - } - - $usages = new UsageCollection(); - - for ($index = 0; $index < $tokens->count(); $index++) { - if ($tokens->get($index)->is(T_USE)) { - $usages->add(...$this->useResolver->execute($index + 1, $tokens)); - } - } - - return $usages; - } -} diff --git a/src/Actions/ParseUserDefinedTypeAction.php b/src/Actions/ParseUserDefinedTypeAction.php index a1f1b31..5499a63 100644 --- a/src/Actions/ParseUserDefinedTypeAction.php +++ b/src/Actions/ParseUserDefinedTypeAction.php @@ -8,7 +8,7 @@ use PHPStan\PhpDocParser\Parser\TypeParser; use ReflectionClass; use Spatie\TypeScriptTransformer\Support\Concerns\Instanceable; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; class ParseUserDefinedTypeAction { diff --git a/src/Actions/TranspilePhpStanTypeToTypeScriptNodeAction.php b/src/Actions/TranspilePhpStanTypeToTypeScriptNodeAction.php index f387248..3d2db07 100644 --- a/src/Actions/TranspilePhpStanTypeToTypeScriptNodeAction.php +++ b/src/Actions/TranspilePhpStanTypeToTypeScriptNodeAction.php @@ -16,23 +16,23 @@ use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; use ReflectionClass; use Spatie\TypeScriptTransformer\References\ClassStringReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAny; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptArray; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptBoolean; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptFunction; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIntersection; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNull; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnknown; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptVoid; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAny; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptArray; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptBoolean; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptFunction; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIntersection; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNull; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnknown; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptVoid; class TranspilePhpStanTypeToTypeScriptNodeAction { diff --git a/src/Actions/TranspileReflectionTypeToTypeScriptNodeAction.php b/src/Actions/TranspileReflectionTypeToTypeScriptNodeAction.php index 200921f..0ab938c 100644 --- a/src/Actions/TranspileReflectionTypeToTypeScriptNodeAction.php +++ b/src/Actions/TranspileReflectionTypeToTypeScriptNodeAction.php @@ -8,20 +8,20 @@ use ReflectionType; use ReflectionUnionType; use Spatie\TypeScriptTransformer\References\ClassStringReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAny; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptArray; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptBoolean; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIntersection; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNull; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUndefined; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnknown; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptVoid; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAny; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptArray; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptBoolean; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIntersection; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNull; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUndefined; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnknown; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptVoid; class TranspileReflectionTypeToTypeScriptNodeAction { diff --git a/src/Attributes/LiteralTypeScriptType.php b/src/Attributes/LiteralTypeScriptType.php index c217977..acb9b30 100644 --- a/src/Attributes/LiteralTypeScriptType.php +++ b/src/Attributes/LiteralTypeScriptType.php @@ -4,10 +4,10 @@ use Attribute; use ReflectionClass; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptRaw; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptRaw; #[Attribute] class LiteralTypeScriptType implements TypeScriptTypeAttributeContract diff --git a/src/Attributes/TypeScriptType.php b/src/Attributes/TypeScriptType.php index db53384..435b167 100644 --- a/src/Attributes/TypeScriptType.php +++ b/src/Attributes/TypeScriptType.php @@ -6,9 +6,9 @@ use ReflectionClass; use Spatie\TypeScriptTransformer\Actions\TranspilePhpStanTypeToTypeScriptNodeAction; use Spatie\TypeScriptTransformer\TypeResolvers\DocTypeResolver; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; #[Attribute] class TypeScriptType implements TypeScriptTypeAttributeContract diff --git a/src/Attributes/TypeScriptTypeAttributeContract.php b/src/Attributes/TypeScriptTypeAttributeContract.php index 098d55b..c205f7f 100644 --- a/src/Attributes/TypeScriptTypeAttributeContract.php +++ b/src/Attributes/TypeScriptTypeAttributeContract.php @@ -3,7 +3,7 @@ namespace Spatie\TypeScriptTransformer\Attributes; use ReflectionClass; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; interface TypeScriptTypeAttributeContract { diff --git a/src/ClassPropertyProcessors/FixArrayLikeStructuresClassPropertyProcessor.php b/src/ClassPropertyProcessors/FixArrayLikeStructuresClassPropertyProcessor.php index c7bf051..997308c 100644 --- a/src/ClassPropertyProcessors/FixArrayLikeStructuresClassPropertyProcessor.php +++ b/src/ClassPropertyProcessors/FixArrayLikeStructuresClassPropertyProcessor.php @@ -6,13 +6,13 @@ use ReflectionProperty; use Spatie\TypeScriptTransformer\References\ClassStringReference; use Spatie\TypeScriptTransformer\Transformers\ClassPropertyProcessors\ClassPropertyProcessor; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptArray; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptArray; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; use Spatie\TypeScriptTransformer\Visitor\Visitor; use Spatie\TypeScriptTransformer\Visitor\VisitorOperation; diff --git a/src/Collections/ImportsCollection.php b/src/Collections/ImportsCollection.php index 5db7903..60d7486 100644 --- a/src/Collections/ImportsCollection.php +++ b/src/Collections/ImportsCollection.php @@ -6,7 +6,7 @@ use Spatie\TypeScriptTransformer\Data\ImportLocation; use Spatie\TypeScriptTransformer\References\Reference; use Spatie\TypeScriptTransformer\Support\ImportName; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptImport; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptImport; use Traversable; class ImportsCollection implements IteratorAggregate diff --git a/src/Data/ImportLocation.php b/src/Data/ImportLocation.php index a53ffd7..31a945e 100644 --- a/src/Data/ImportLocation.php +++ b/src/Data/ImportLocation.php @@ -4,7 +4,7 @@ use Spatie\TypeScriptTransformer\References\Reference; use Spatie\TypeScriptTransformer\Support\ImportName; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptImport; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptImport; class ImportLocation { diff --git a/src/Laravel/ClassPropertyProcessors/DataClassPropertyProcessor.php b/src/Laravel/ClassPropertyProcessors/DataClassPropertyProcessor.php index 5743f44..257e347 100644 --- a/src/Laravel/ClassPropertyProcessors/DataClassPropertyProcessor.php +++ b/src/Laravel/ClassPropertyProcessors/DataClassPropertyProcessor.php @@ -8,10 +8,10 @@ use Spatie\LaravelData\Support\DataConfig; use Spatie\TypeScriptTransformer\References\ClassStringReference; use Spatie\TypeScriptTransformer\Transformers\ClassPropertyProcessors\ClassPropertyProcessor; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; class DataClassPropertyProcessor implements ClassPropertyProcessor { diff --git a/src/Laravel/LaravelDataTypesProvider.php b/src/Laravel/LaravelDataTypesProvider.php index d8a2dec..71d1b4f 100644 --- a/src/Laravel/LaravelDataTypesProvider.php +++ b/src/Laravel/LaravelDataTypesProvider.php @@ -10,10 +10,10 @@ use Spatie\TypeScriptTransformer\Support\TransformedCollection; use Spatie\TypeScriptTransformer\Transformed\Transformed; use Spatie\TypeScriptTransformer\TypeProviders\TypesProvider; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig; class LaravelDataTypesProvider implements TypesProvider diff --git a/src/Laravel/LaravelNamedRouteTypesProvider.php b/src/Laravel/LaravelNamedRouteTypesProvider.php index a962c59..3c94bb6 100644 --- a/src/Laravel/LaravelNamedRouteTypesProvider.php +++ b/src/Laravel/LaravelNamedRouteTypesProvider.php @@ -15,22 +15,22 @@ use Spatie\TypeScriptTransformer\Support\TransformedCollection; use Spatie\TypeScriptTransformer\Transformed\Transformed; use Spatie\TypeScriptTransformer\TypeProviders\TypesProvider; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptFunctionDefinition; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGenericTypeVariable; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIndexedAccess; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptOperator; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptParameter; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptRaw; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptFunctionDefinition; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGenericTypeVariable; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIndexedAccess; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptOperator; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptParameter; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptRaw; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig; class LaravelNamedRouteTypesProvider implements TypesProvider @@ -41,7 +41,7 @@ class LaravelNamedRouteTypesProvider implements TypesProvider */ public function __construct( protected ResolveLaravelRoutControllerCollectionsAction $resolveLaravelRoutControllerCollectionsAction = new ResolveLaravelRoutControllerCollectionsAction(), - protected array $location = [], + protected array $location = ['App'], protected array $filters = [], ) { } diff --git a/src/Laravel/LaravelRouteActionTypesProvider.php b/src/Laravel/LaravelRouteActionTypesProvider.php index 00cfea5..5011cd6 100644 --- a/src/Laravel/LaravelRouteActionTypesProvider.php +++ b/src/Laravel/LaravelRouteActionTypesProvider.php @@ -14,24 +14,24 @@ use Spatie\TypeScriptTransformer\Support\TransformedCollection; use Spatie\TypeScriptTransformer\Transformed\Transformed; use Spatie\TypeScriptTransformer\TypeProviders\TypesProvider; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptArray; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptConditional; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptFunctionDefinition; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGenericTypeVariable; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIndexedAccess; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptOperator; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptParameter; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptRaw; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptArray; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptConditional; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptFunctionDefinition; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGenericTypeVariable; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIndexedAccess; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptOperator; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptParameter; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptRaw; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig; class LaravelRouteActionTypesProvider implements TypesProvider @@ -43,7 +43,7 @@ class LaravelRouteActionTypesProvider implements TypesProvider public function __construct( protected ResolveLaravelRoutControllerCollectionsAction $resolveLaravelRoutControllerCollectionsAction = new ResolveLaravelRoutControllerCollectionsAction(), protected ?string $defaultNamespace = null, - protected array $location = [], + protected array $location = ['App'], protected array $filters = [], ) { } diff --git a/src/Laravel/LaravelTypeScriptTransformerExtension.php b/src/Laravel/LaravelTypeScriptTransformerExtension.php index 4eaf22f..2dde856 100644 --- a/src/Laravel/LaravelTypeScriptTransformerExtension.php +++ b/src/Laravel/LaravelTypeScriptTransformerExtension.php @@ -6,7 +6,7 @@ use Spatie\TypeScriptTransformer\Laravel\Transformers\LaravelAttributedClassTransformer; use Spatie\TypeScriptTransformer\Support\Extensions\TypeScriptTransformerExtension; use Spatie\TypeScriptTransformer\Transformers\AttributedClassTransformer; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; use Spatie\TypeScriptTransformer\TypeScriptTransformerConfigFactory; class LaravelTypeScriptTransformerExtension implements TypeScriptTransformerExtension diff --git a/src/Laravel/LaravelTypesProvider.php b/src/Laravel/LaravelTypesProvider.php index 5b8d419..68791a1 100644 --- a/src/Laravel/LaravelTypesProvider.php +++ b/src/Laravel/LaravelTypesProvider.php @@ -10,17 +10,17 @@ use Spatie\TypeScriptTransformer\Support\TransformedCollection; use Spatie\TypeScriptTransformer\Transformed\Transformed; use Spatie\TypeScriptTransformer\TypeProviders\TypesProvider; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptBoolean; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNull; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptBoolean; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNull; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig; class LaravelTypesProvider implements TypesProvider diff --git a/src/Laravel/SpatieLaravelTypesProvider.php b/src/Laravel/SpatieLaravelTypesProvider.php index 6fe8249..7f09210 100644 --- a/src/Laravel/SpatieLaravelTypesProvider.php +++ b/src/Laravel/SpatieLaravelTypesProvider.php @@ -6,12 +6,12 @@ use Spatie\TypeScriptTransformer\Support\TransformedCollection; use Spatie\TypeScriptTransformer\Transformed\Transformed; use Spatie\TypeScriptTransformer\TypeProviders\TypesProvider; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGenericTypeVariable; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGenericTypeVariable; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig; class SpatieLaravelTypesProvider implements TypesProvider diff --git a/src/Transformed/Transformed.php b/src/Transformed/Transformed.php index e94d9de..20d80c5 100644 --- a/src/Transformed/Transformed.php +++ b/src/Transformed/Transformed.php @@ -4,10 +4,10 @@ use Spatie\TypeScriptTransformer\References\Reference; use Spatie\TypeScriptTransformer\Support\TypeScriptTransformerLog; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptExport; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptForwardingNamedNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNamedNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptExport; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptForwardingNamedNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNamedNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; class Transformed { diff --git a/src/Transformers/ClassPropertyProcessors/ClassPropertyProcessor.php b/src/Transformers/ClassPropertyProcessors/ClassPropertyProcessor.php index 729e3a1..46f6f09 100644 --- a/src/Transformers/ClassPropertyProcessors/ClassPropertyProcessor.php +++ b/src/Transformers/ClassPropertyProcessors/ClassPropertyProcessor.php @@ -4,7 +4,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode; use ReflectionProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; interface ClassPropertyProcessor { diff --git a/src/Transformers/ClassTransformer.php b/src/Transformers/ClassTransformer.php index 03563ed..121db7a 100644 --- a/src/Transformers/ClassTransformer.php +++ b/src/Transformers/ClassTransformer.php @@ -17,12 +17,12 @@ use Spatie\TypeScriptTransformer\Transformed\Untransformable; use Spatie\TypeScriptTransformer\Transformers\ClassPropertyProcessors\ClassPropertyProcessor; use Spatie\TypeScriptTransformer\TypeResolvers\DocTypeResolver; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnknown; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnknown; abstract class ClassTransformer implements Transformer { diff --git a/src/Transformers/EnumTransformer.php b/src/Transformers/EnumTransformer.php index 0e8768e..c50c65d 100644 --- a/src/Transformers/EnumTransformer.php +++ b/src/Transformers/EnumTransformer.php @@ -9,12 +9,12 @@ use Spatie\TypeScriptTransformer\Transformed\Untransformable; use Spatie\TypeScriptTransformer\Transformers\EnumProviders\EnumProvider; use Spatie\TypeScriptTransformer\Transformers\EnumProviders\PhpEnumProvider; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptEnum; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptLiteral; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptEnum; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptLiteral; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; class EnumTransformer implements Transformer { diff --git a/src/Transformers/InterfaceTransformer.php b/src/Transformers/InterfaceTransformer.php index d64baaf..1da7209 100644 --- a/src/Transformers/InterfaceTransformer.php +++ b/src/Transformers/InterfaceTransformer.php @@ -14,14 +14,14 @@ use Spatie\TypeScriptTransformer\TypeResolvers\Data\ParsedMethod; use Spatie\TypeScriptTransformer\TypeResolvers\Data\ParsedNameAndType; use Spatie\TypeScriptTransformer\TypeResolvers\DocTypeResolver; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptInterface; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptInterfaceMethod; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptParameter; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnknown; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptVoid; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptInterface; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptInterfaceMethod; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptParameter; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnknown; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptVoid; abstract class InterfaceTransformer implements Transformer { diff --git a/src/TypeScript/TypeReference.php b/src/TypeScriptNodes/TypeReference.php similarity index 94% rename from src/TypeScript/TypeReference.php rename to src/TypeScriptNodes/TypeReference.php index b7c817c..24fd89b 100644 --- a/src/TypeScript/TypeReference.php +++ b/src/TypeScriptNodes/TypeReference.php @@ -1,6 +1,6 @@ action = new ResolveModuleImportsAction(); diff --git a/tests/Actions/SplitTransformedPerLocationActionTest.php b/tests/Actions/SplitTransformedPerLocationActionTest.php index a4bab93..ffa23e6 100644 --- a/tests/Actions/SplitTransformedPerLocationActionTest.php +++ b/tests/Actions/SplitTransformedPerLocationActionTest.php @@ -4,7 +4,7 @@ use Spatie\TypeScriptTransformer\Support\Location; use Spatie\TypeScriptTransformer\Support\TransformedCollection; use Spatie\TypeScriptTransformer\Tests\Factories\TransformedFactory; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; it('can split per location', function () { $transformedCollection = new TransformedCollection([ diff --git a/tests/Actions/TranspilePhpStanTypeToTypeScriptNodeActionTest.php b/tests/Actions/TranspilePhpStanTypeToTypeScriptNodeActionTest.php index 273163c..d30849f 100644 --- a/tests/Actions/TranspilePhpStanTypeToTypeScriptNodeActionTest.php +++ b/tests/Actions/TranspilePhpStanTypeToTypeScriptNodeActionTest.php @@ -5,23 +5,23 @@ use Spatie\TypeScriptTransformer\References\ClassStringReference; use Spatie\TypeScriptTransformer\Tests\Fakes\PropertyTypes\PhpDocTypesStub; use Spatie\TypeScriptTransformer\TypeResolvers\DocTypeResolver; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAny; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptArray; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptBoolean; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptFunction; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIntersection; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNull; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnknown; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptVoid; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAny; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptArray; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptBoolean; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptFunction; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIntersection; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNull; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnknown; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptVoid; it('can transpile PHPStan doc types', function ( string $property, diff --git a/tests/Actions/TranspileReflectionTypeToTypeScriptNodeActionTest.php b/tests/Actions/TranspileReflectionTypeToTypeScriptNodeActionTest.php index d90d500..922844b 100644 --- a/tests/Actions/TranspileReflectionTypeToTypeScriptNodeActionTest.php +++ b/tests/Actions/TranspileReflectionTypeToTypeScriptNodeActionTest.php @@ -5,19 +5,19 @@ use Spatie\TypeScriptTransformer\Actions\TranspileReflectionTypeToTypeScriptNodeAction; use Spatie\TypeScriptTransformer\References\ClassStringReference; use Spatie\TypeScriptTransformer\Tests\Fakes\PropertyTypes\PhpTypesStub; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAny; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptArray; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptBoolean; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIntersection; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNull; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnknown; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptVoid; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAny; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptArray; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptBoolean; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIntersection; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNull; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnknown; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptVoid; it('can transpile php types', function ( string $property, diff --git a/tests/ClassPropertyProcessors/FixArrayLikeStructuresClassPropertyProcessorTest.php b/tests/ClassPropertyProcessors/FixArrayLikeStructuresClassPropertyProcessorTest.php index 092315f..bca6289 100644 --- a/tests/ClassPropertyProcessors/FixArrayLikeStructuresClassPropertyProcessorTest.php +++ b/tests/ClassPropertyProcessors/FixArrayLikeStructuresClassPropertyProcessorTest.php @@ -3,16 +3,16 @@ use Illuminate\Support\Collection; use Spatie\TypeScriptTransformer\ClassPropertyProcessors\FixArrayLikeStructuresClassPropertyProcessor; use Spatie\TypeScriptTransformer\References\ClassStringReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptArray; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptBoolean; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptGeneric; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnion; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptArray; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptBoolean; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptGeneric; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnion; it('replaces array like structures', function ( string $property, diff --git a/tests/Factories/TransformedFactory.php b/tests/Factories/TransformedFactory.php index 3b3776b..ad8519f 100644 --- a/tests/Factories/TransformedFactory.php +++ b/tests/Factories/TransformedFactory.php @@ -6,9 +6,9 @@ use Spatie\TypeScriptTransformer\References\CustomReference; use Spatie\TypeScriptTransformer\References\Reference; use Spatie\TypeScriptTransformer\Transformed\Transformed; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; class TransformedFactory { diff --git a/tests/Laravel/LaravelRouteActionTypesProviderTest.php b/tests/Laravel/LaravelRouteActionTypesProviderTest.php new file mode 100644 index 0000000..55d0c60 --- /dev/null +++ b/tests/Laravel/LaravelRouteActionTypesProviderTest.php @@ -0,0 +1,14 @@ +getActionTypes($route); + + expect($actionTypes)->toBe([ + 'controller' => 'TestController', + 'method' => 'test', + ]); +}); diff --git a/tests/Support/MemoryWriter.php b/tests/Support/MemoryWriter.php index 7c2293b..3e9f830 100644 --- a/tests/Support/MemoryWriter.php +++ b/tests/Support/MemoryWriter.php @@ -4,7 +4,7 @@ use Spatie\TypeScriptTransformer\Collections\ReferenceMap; use Spatie\TypeScriptTransformer\Support\TransformedCollection; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; use Spatie\TypeScriptTransformer\Writers\FlatWriter; use Spatie\TypeScriptTransformer\Writers\Writer; diff --git a/tests/Transformers/ClassTransformerTest.php b/tests/Transformers/ClassTransformerTest.php index 9a33f65..8376d62 100644 --- a/tests/Transformers/ClassTransformerTest.php +++ b/tests/Transformers/ClassTransformerTest.php @@ -15,14 +15,14 @@ use Spatie\TypeScriptTransformer\Tests\Support\AllClassTransformer; use Spatie\TypeScriptTransformer\Transformers\ClassPropertyProcessors\ClassPropertyProcessor; use Spatie\TypeScriptTransformer\Transformers\ClassTransformer; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptRaw; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptUnknown; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptRaw; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptUnknown; it('can transform a class', function () { $transformed = transformSingle(SimpleClass::class); diff --git a/tests/TypeProviders/TransformerTypesProviderTest.php b/tests/TypeProviders/TransformerTypesProviderTest.php index 7834863..4495161 100644 --- a/tests/TypeProviders/TransformerTypesProviderTest.php +++ b/tests/TypeProviders/TransformerTypesProviderTest.php @@ -14,11 +14,11 @@ use Spatie\TypeScriptTransformer\Transformed\Transformed; use Spatie\TypeScriptTransformer\Transformers\EnumTransformer; use Spatie\TypeScriptTransformer\TypeProviders\TransformerTypesProvider; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; use Spatie\TypeScriptTransformer\TypeScriptTransformerConfigFactory; function getTestProvidedTypes( diff --git a/tests/TypeReplacements.php b/tests/TypeReplacements.php index 68594b7..8fc5384 100644 --- a/tests/TypeReplacements.php +++ b/tests/TypeReplacements.php @@ -5,15 +5,15 @@ use Spatie\TypeScriptTransformer\Tests\Factories\TransformedFactory; use Spatie\TypeScriptTransformer\Tests\Support\InlineTypesProvider; use Spatie\TypeScriptTransformer\Tests\Support\MemoryWriter; -use Spatie\TypeScriptTransformer\TypeScript\TypeReference; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptAlias; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptIdentifier; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNode; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptNumber; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptObject; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptProperty; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptRaw; -use Spatie\TypeScriptTransformer\TypeScript\TypeScriptString; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeReference; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptAlias; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptIdentifier; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNode; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptNumber; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptObject; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptProperty; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptRaw; +use Spatie\TypeScriptTransformer\TypeScriptNodes\TypeScriptString; use Spatie\TypeScriptTransformer\TypeScriptTransformer; use Spatie\TypeScriptTransformer\TypeScriptTransformerConfigFactory; diff --git a/tests/TypeScript/TypeScriptEnumTest.php b/tests/TypeScript/TypeScriptEnumTest.php index dcee8a6..1201381 100644 --- a/tests/TypeScript/TypeScriptEnumTest.php +++ b/tests/TypeScript/TypeScriptEnumTest.php @@ -1,7 +1,7 @@