From bc49787d691441bd7b645961f4235d57342a3f9d Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 9 Jun 2019 15:22:26 -0400 Subject: [PATCH] Add more information about class-string --- docs/annotating_code/type_syntax/scalar_types.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/annotating_code/type_syntax/scalar_types.md b/docs/annotating_code/type_syntax/scalar_types.md index bd94e5ee1..20eeda0c3 100644 --- a/docs/annotating_code/type_syntax/scalar_types.md +++ b/docs/annotating_code/type_syntax/scalar_types.md @@ -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`](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.