I found these snippets:
https://psalm.dev/r/3fa54f51a1
<?php
namespace AA;
/**
* @psalm-type _A=array{a:string}
*/
class A {}
namespace BB;
use AA;
/**
* @psalm-import-type _A from A
*/
class B {
/**
* @psalm-param _A $a
* @return void
*/
public function ff(array $a){
if (!empty($a)) {echo 'ss';}
}
}
Psalm output (using commit eaae243):
ERROR: MismatchingDocblockParamType - 18:20 - Parameter $a has wrong type 'type-alias(BB\A::_A)', should be 'array<array-key, mixed>'
ERROR: RedundantConditionGivenDocblockType - 22:8 - Found a redundant condition when evaluating docblock-defined type $a and trying to reconcile type 'type-alias(BB\A::_A)' to !empty
You're using use incorrectly: https://psalm.dev/r/c95369392b
I found these snippets:
https://psalm.dev/r/c95369392b
<?php
namespace AA {
/**
* @psalm-type _A=array{a:string}
*/
class A {}
}
namespace BB {
use AA;
/**
* @psalm-import-type _A from AA\A
*/
class B {
/**
* @psalm-param _A $a
* @return void
*/
public function ff(array $a){
if (!empty($a)) {echo 'ss';}
}
}
}
Psalm output (using commit eaae243):
No issues!
ie use AA; doesn't import all the symbols in AA automatically
Most helpful comment
ie
use AA;doesn't import all the symbols inAAautomatically