File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ Advanced Usages
114114The TypeInfo component provides various methods to manipulate and check types,
115115depending on your needs.
116116
117- Checking a ** simple type ** ::
117+ ** Identify ** a type ::
118118
119119 // define a simple integer type
120120 $type = Type::int();
@@ -141,6 +141,23 @@ Checking a **simple type**::
141141 $type->isIdentifiedBy(DummyParent::class); // true
142142 $type->isIdentifiedBy(DummyInterface::class); // true
143143
144+ Checking if a type **accepts a value **::
145+
146+ $type = Type::int();
147+ // check if the type accepts a given value
148+ $type->accepts(123); // true
149+ $type->accepts('z'); // false
150+
151+ $type = Type::union(Type::string(), Type::int());
152+ // now the second check is true because the union type accepts either a int and a string value
153+ $type->accepts(123); // true
154+ $type->accepts('z'); // true
155+
156+ .. versionadded :: 7.3
157+
158+ The :method: `Symfony\\ Component\\ TypeInfo\\ Type::accepts `
159+ method was introduced in Symfony 7.3.
160+
144161Using callables for **complex checks **::
145162
146163 class Foo
You can’t perform that action at this time.
0 commit comments