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
114
114
The TypeInfo component provides various methods to manipulate and check types,
115
115
depending on your needs.
116
116
117
- Checking a ** simple type ** ::
117
+ ** Identify ** a type ::
118
118
119
119
// define a simple integer type
120
120
$type = Type::int();
@@ -141,6 +141,23 @@ Checking a **simple type**::
141
141
$type->isIdentifiedBy(DummyParent::class); // true
142
142
$type->isIdentifiedBy(DummyInterface::class); // true
143
143
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
+
144
161
Using callables for **complex checks **::
145
162
146
163
class Foo
You can’t perform that action at this time.
0 commit comments