comparison vendor/symfony/validator/Constraints/Composite.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
59 59
60 /* @var Constraint[] $nestedConstraints */ 60 /* @var Constraint[] $nestedConstraints */
61 $compositeOption = $this->getCompositeOption(); 61 $compositeOption = $this->getCompositeOption();
62 $nestedConstraints = $this->$compositeOption; 62 $nestedConstraints = $this->$compositeOption;
63 63
64 if (!is_array($nestedConstraints)) { 64 if (!\is_array($nestedConstraints)) {
65 $nestedConstraints = array($nestedConstraints); 65 $nestedConstraints = [$nestedConstraints];
66 } 66 }
67 67
68 foreach ($nestedConstraints as $constraint) { 68 foreach ($nestedConstraints as $constraint) {
69 if (!$constraint instanceof Constraint) { 69 if (!$constraint instanceof Constraint) {
70 if (is_object($constraint)) { 70 if (\is_object($constraint)) {
71 $constraint = get_class($constraint); 71 $constraint = \get_class($constraint);
72 } 72 }
73 73
74 throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s', $constraint, get_class($this))); 74 throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s', $constraint, \get_class($this)));
75 } 75 }
76 76
77 if ($constraint instanceof Valid) { 77 if ($constraint instanceof Valid) {
78 throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint %s. You can only declare the Valid constraint directly on a field or method.', get_class($this))); 78 throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint %s. You can only declare the Valid constraint directly on a field or method.', \get_class($this)));
79 } 79 }
80 } 80 }
81 81
82 if (!property_exists($this, 'groups')) { 82 if (!property_exists($this, 'groups')) {
83 $mergedGroups = array(); 83 $mergedGroups = [];
84 84
85 foreach ($nestedConstraints as $constraint) { 85 foreach ($nestedConstraints as $constraint) {
86 foreach ($constraint->groups as $group) { 86 foreach ($constraint->groups as $group) {
87 $mergedGroups[$group] = true; 87 $mergedGroups[$group] = true;
88 } 88 }
96 96
97 foreach ($nestedConstraints as $constraint) { 97 foreach ($nestedConstraints as $constraint) {
98 if (property_exists($constraint, 'groups')) { 98 if (property_exists($constraint, 'groups')) {
99 $excessGroups = array_diff($constraint->groups, $this->groups); 99 $excessGroups = array_diff($constraint->groups, $this->groups);
100 100
101 if (count($excessGroups) > 0) { 101 if (\count($excessGroups) > 0) {
102 throw new ConstraintDefinitionException(sprintf( 102 throw new ConstraintDefinitionException(sprintf('The group(s) "%s" passed to the constraint %s should also be passed to its containing constraint %s', implode('", "', $excessGroups), \get_class($constraint), \get_class($this)));
103 'The group(s) "%s" passed to the constraint %s '.
104 'should also be passed to its containing constraint %s',
105 implode('", "', $excessGroups),
106 get_class($constraint),
107 get_class($this)
108 ));
109 } 103 }
110 } else { 104 } else {
111 $constraint->groups = $this->groups; 105 $constraint->groups = $this->groups;
112 } 106 }
113 } 107 }