-
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
How to use pseudo scalar type trait-string
#3865
Comments
I found these snippets: https://psalm.dev/r/615d86ff95<?php
namespace Bar;
trait Foo {}
/**
* @param trait-string $traitString
* @return trait-string
*/
function takesTraitString(string $traitString) {
return $traitString;
}
takesTraitString('Bar\Foo');
takesTraitString(Foo::class);
|
I think trait-string is inferred when you pass through trait_exists: |
I found these snippets: https://psalm.dev/r/3bff912a5b<?php
namespace Bar;
trait Foo {}
/**
* @param trait-string $traitString
* @return trait-string
*/
function takesTraitString(string $traitString) {
return $traitString;
}
$a = Foo::class;
if(trait_exists($a)){
takesTraitString($a);
}
|
Interesting 🤔 Thank you @orklah |
I would say |
Hi, phpunit 11.2 introduced CoversTrait attribute, and it uses the
Can we do something about it? |
trait-string simply does not work in psalm, vimeo/psalm#3865
Unfortunately I couldn't find much documentation about
trait-string
and couldn't get it running as I thought it should be used:https://psalm.dev/r/615d86ff95
Probably there is a bug or documentation needs to be updated.
The text was updated successfully, but these errors were encountered: