-
Notifications
You must be signed in to change notification settings - Fork 668
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
@psalm-import-type doesn't work with autoloaded files? #3999
Labels
Comments
I found these snippets: https://psalm.dev/r/531fd85425<?php declare(strict_types=1);
namespace DL2\PsalmIssue;
/**
* @psalm-type TFoo = 'A'|'B'|'C'
*/
class A
{
}
/**
* @psalm-import-type TFoo from A
*
* @psalm-type TError = array{
* foo: TFoo
* }
*/
class B
{
/**
* @var array
* @psalm-var ?TError
*/
public $error;
}
|
douggr
changed the title
[question] how does
[question] how does Aug 17, 2020
@psalm-import-type
behave?@psalm-import-type
works/import types?
douggr
changed the title
[question] how does
@psalm-import-type doesn't work with autoloaded files?
Aug 17, 2020
@psalm-import-type
works/import types?
I think this is related to #3807 |
Reproduced in https://psalm.dev/r/e856fbf28d – removing the namespace fixes the issue, so it's something trivial around that. |
I found these snippets: https://psalm.dev/r/e856fbf28d<?php
namespace Bar;
/**
* @psalm-type TFoo = 'A'|'B'|'C'
*/
class A
{
}
/**
* @psalm-import-type TFoo from A as TFoo2
*
* @psalm-type TError = array{
* foo: TFoo2
* }
*/
class B
{
/**
* @var ?TError $error
*/
public $error = null;
}
|
Awesome! Thank you :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have this (working) example: https://psalm.dev/r/531fd85425, which have only one file.
BUT, when we try to use
@psalm-import-type
among several files, psalm fails withERROR: UndefinedDocblockClass - src/Error.php:16:19 - Docblock-defined class or interface DL2\PsalmIssue\TFoo does not exist (see https://psalm.dev/200)
.Funny thing, it'll work if I add a constant within the class, but I don't want to.
I've created a simple example here: https://github.com/douggr/psalm-issues (clone, composer install && composer psalm)
So, my question is: how should I expect
@psalm-import-type
to work? Am I missing something?I'm using psalm@dev-master:
refs #3816
The text was updated successfully, but these errors were encountered: