Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle type importation from interface #507

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

romm
Copy link
Member

@romm romm commented Mar 27, 2024

Allows usage of @phpstan-import-type and @psalm-import-type from interfaces:

/**
 * @phpstan-type SomeAlias = array{foo: string, bar: int}
 */
interface InterfaceWithPhpStanLocalAlias { }

/**
 * @phpstan-import-type SomeAlias from InterfaceWithPhpStanLocalAlias
 */
final class SomeClass
{
    /** @var SomeAlias */
    public $value;
}

(new \CuyZ\Valinor\MapperBuilder())
    ->mapper()
    ->map(SomeClass::class, [
        'foo' => 'bar',
        'bar' => 42,
    ]);

Fixes #353

Allows usage of `@phpstan-import-type` and `@psalm-import-type` from
interfaces:

```php
/**
 * @phpstan-type SomeAlias = array{foo: string, bar: int}
 */
interface InterfaceWithPhpStanLocalAlias { }

/**
 * @phpstan-import-type SomeAlias from InterfaceWithPhpStanLocalAlias
 */
final class SomeClass
{
    /** @var SomeAlias */
    public $value;
}

(new \CuyZ\Valinor\MapperBuilder())
    ->mapper()
    ->map(SomeClass::class, [
        'foo' => 'bar',
        'bar' => 42,
    ]);
```
@romm romm enabled auto-merge (rebase) March 27, 2024 20:35
@romm romm merged commit 3af22d1 into CuyZ:master Mar 27, 2024
11 checks passed
@romm romm deleted the feat/handle-interface-type-import branch March 27, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interfaces should support type aliases
1 participant