mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Add more information about class-string
This commit is contained in:
parent
9c18dfed43
commit
bc49787d69
@ -31,6 +31,8 @@ function takesClassName(string $s) : void {}
|
||||
|
||||
`takesClassName("A");` would trigger a `TypeCoercion` issue (or a `PossiblyInvalidArgument` issue if [`allowCoercionFromStringToClassConst`](../running_psalm/configuration.md#coding-style) was set to `false` in your config), whereas `takesClassName(A::class)` is fine.
|
||||
|
||||
You can also parameterize `class-string` with an object name e.g. [`class-string<Foo>`](value_types.md#regular-class-constants). This tells Psalm that any matching type must either be a class string of `Foo` or one of its descendants.
|
||||
|
||||
### trait-string
|
||||
|
||||
Psalm also supports a `trait-string` annotation denote a trait that exists.
|
||||
|
Loading…
Reference in New Issue
Block a user