### Defining a PHP Enum Source: https://github.com/spatie/laravel-typescript-transformer/blob/main/README.md Shows a basic PHP enum definition using `const`. This serves as an initial example before applying the package's transformation features. ```php class Languages extends Enum { const TYPESCRIPT = 'typescript'; const PHP = 'php'; } ``` -------------------------------- ### Running Package Tests Source: https://github.com/spatie/laravel-typescript-transformer/blob/main/README.md Provides the command-line instruction to execute the test suite for the package using Composer. ```bash composer test ``` -------------------------------- ### Defining TypeScript Interface for Collections and DTOs Source: https://github.com/spatie/laravel-typescript-transformer/blob/main/tests/__snapshots__/DtoTransformerTest__it_can_transform_a_dto__1.txt This snippet defines a TypeScript interface structure. It includes properties for a standard array of DTOs, a custom collection type, a non-typed Laravel collection, a typed Laravel collection of DTOs, and a typed Laravel Eloquent collection of DTOs. The `{}` syntax likely indicates placeholders for generated type references. ```TypeScript { other_dto_array: Array<{%Spatie\LaravelTypeScriptTransformer\Tests\FakeClasses\Dto\OtherDto%}>; other_dto_collection: {%Spatie\TypeScriptTransformer\Tests\FakeClasses\Integration\OtherDtoCollection%}; non_typed_laravel_collection: Array; other_dto_laravel_collection: Array<{%Spatie\LaravelTypeScriptTransformer\Tests\FakeClasses\Dto\OtherDto%}>; other_dto_laravel_eloquent_collection: Array<{%Spatie\LaravelTypeScriptTransformer\Tests\FakeClasses\Dto\OtherDto%}>; } ``` -------------------------------- ### Annotating PHP Class for Transformation Source: https://github.com/spatie/laravel-typescript-transformer/blob/main/README.md Shows how to add the `@typescript` annotation to a PHP class with public properties, allowing the package to generate a corresponding TypeScript object type. ```php /** @typescript */ class User { public int $id; public string $name; public ?string $address; } ``` -------------------------------- ### Annotating PHP Enum for Transformation Source: https://github.com/spatie/laravel-typescript-transformer/blob/main/README.md Demonstrates how to add the `@typescript` annotation to a PHP enum class, enabling the package to automatically generate its TypeScript definition. ```php /** @typescript **/ class Languages extends Enum { const TYPESCRIPT = 'typescript'; const PHP = 'php'; } ``` -------------------------------- ### Generated TypeScript Type for Class Source: https://github.com/spatie/laravel-typescript-transformer/blob/main/README.md Displays the TypeScript object type automatically generated by the package from the annotated PHP class, including the correct mapping for nullable properties. ```ts export type User = { id: number; name: string; address: string | null; } ``` -------------------------------- ### Defining TypeScript Interface for Collections Source: https://github.com/spatie/laravel-typescript-transformer/blob/main/tests/Transformers/__snapshots__/DtoTransformerTest__it_can_transform_a_dto__1.txt This TypeScript interface outlines properties that map to different collection types (standard arrays, custom collections, Laravel collections, Eloquent collections), demonstrating how the transformer handles various collection structures containing DTOs. ```TypeScript { other_dto_array: Array<{%Spatie\LaravelTypeScriptTransformer\Tests\FakeClasses\Dto\OtherDto%}>; other_dto_collection: {%Spatie\TypeScriptTransformer\Tests\FakeClasses\Integration\OtherDtoCollection%}>; non_typed_laravel_collection: Array; other_dto_laravel_collection: Array<{%Spatie\LaravelTypeScriptTransformer\Tests\FakeClasses\Dto\OtherDto%}>; other_dto_laravel_eloquent_collection: Array<{%Spatie\LaravelTypeScriptTransformer\Tests\FakeClasses\Dto\OtherDto%}>; } ``` -------------------------------- ### Generated TypeScript Type for Enum Source: https://github.com/spatie/laravel-typescript-transformer/blob/main/README.md Illustrates the expected TypeScript union type that the package automatically generates from the corresponding PHP enum. ```ts export type Languages = 'typescript' | 'php'; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.