Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c4e7c72

Browse filesBrowse files
committed
Reword
1 parent 61ccf8f commit c4e7c72
Copy full SHA for c4e7c72

File tree

Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed

‎validation/custom_constraint.rst

Copy file name to clipboardExpand all lines: validation/custom_constraint.rst
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ You can use ``#[HasNamedArguments]`` to make some constraint options required::
6666
}
6767
}
6868

69-
Constraint with private properties
69+
Constraint with Private Properties
7070
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7171

72-
Constraints are cached for efficiency, but private properties are not supported
73-
by default.
72+
Constraints are cached for performance reasons. To achieve this, the base
73+
``Constraint`` class uses PHP's :phpfunction:`get_object_vars()` function, which
74+
excludes private properties of child classes.
7475

75-
So if you're using private properties in your constraint, you must override default
76-
``__sleep`` method ::
76+
If your constraint defines private properties, you must explicitly include them
77+
in the ``__sleep()`` method to ensure they are serialized correctly::
7778

7879
// src/Validator/ContainsAlphanumeric.php
7980
namespace App\Validator;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.