@@ -46,24 +46,10 @@ public function __construct(
4646 *
4747 * @return TypeDoc
4848 */
49- public function transform (Constraint $ constraint )
50- {
51- return $ this ->docFromConstraint ($ constraint );
52- }
53-
54- /**
55- * @param Constraint $constraintOrConstraintList
56- * @param string|int|null $paramNameOrIndex
57- *
58- * @return TypeDoc
59- */
60- private function docFromConstraint (Constraint $ constraint , $ paramNameOrIndex = null )
49+ public function transform (Constraint $ constraint ) : TypeDoc
6150 {
6251 $ constraintList = [$ constraint ];
6352 $ constraintDoc = $ this ->docTypeHelper ->guess ($ constraintList );
64- if (null !== $ paramNameOrIndex ) {
65- $ constraintDoc ->setName ($ paramNameOrIndex );
66- }
6753
6854 foreach ($ constraintList as $ constraint ) {
6955 $ this ->appendToDoc ($ constraintDoc , $ constraint );
@@ -76,7 +62,7 @@ private function docFromConstraint(Constraint $constraint, $paramNameOrIndex = n
7662 * @param TypeDoc $doc
7763 * @param Constraint $constraint
7864 */
79- private function appendToDoc (TypeDoc $ doc , Constraint $ constraint )
65+ private function appendToDoc (TypeDoc $ doc , Constraint $ constraint ) : void
8066 {
8167 if ($ doc instanceof ArrayDoc && $ constraint instanceof Assert \All) {
8268 $ this ->appendAllConstraintToDoc ($ doc , $ constraint );
@@ -105,7 +91,7 @@ private function appendToDoc(TypeDoc $doc, Constraint $constraint)
10591 * @param TypeDoc $doc
10692 * @param Constraint $constraint
10793 */
108- private function appendCollectionDoc (TypeDoc $ doc , Constraint $ constraint )
94+ private function appendCollectionDoc (TypeDoc $ doc , Constraint $ constraint ) : void
10995 {
11096 // If not a collection => give up
11197 if (!$ doc instanceof CollectionDoc) {
@@ -115,7 +101,8 @@ private function appendCollectionDoc(TypeDoc $doc, Constraint $constraint)
115101 if ($ constraint instanceof Assert \Collection) {
116102 foreach ($ constraint ->fields as $ fieldName => $ constraintOrConstrainList ) {
117103 $ doc ->addSibling (
118- $ this ->docFromConstraint ($ constraintOrConstrainList , $ fieldName )
104+ $ this ->transform ($ constraintOrConstrainList )
105+ ->setName ($ fieldName )
119106 );
120107 }
121108
@@ -128,7 +115,7 @@ private function appendCollectionDoc(TypeDoc $doc, Constraint $constraint)
128115 * @param TypeDoc $doc
129116 * @param Constraint $constraint
130117 */
131- private function appendValidItemListDoc (TypeDoc $ doc , Constraint $ constraint )
118+ private function appendValidItemListDoc (TypeDoc $ doc , Constraint $ constraint ) : void
132119 {
133120 if ($ constraint instanceof Assert \Choice) {
134121 if ($ constraint ->callback && is_callable ($ constraint ->callback )) {
@@ -146,7 +133,7 @@ private function appendValidItemListDoc(TypeDoc $doc, Constraint $constraint)
146133 * @param ArrayDoc $doc
147134 * @param Assert\All $constraint
148135 */
149- private function appendAllConstraintToDoc (ArrayDoc $ doc , Assert \All $ constraint )
136+ private function appendAllConstraintToDoc (ArrayDoc $ doc , Assert \All $ constraint ) : void
150137 {
151138 $ itemDoc = $ this ->docTypeHelper ->guess ($ constraint ->constraints );
152139 foreach ($ constraint ->constraints as $ subConstraint ) {
0 commit comments