comparison vendor/symfony/validator/DataCollector/ValidatorDataCollector.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
43 // Everything is collected once, on kernel terminate. 43 // Everything is collected once, on kernel terminate.
44 } 44 }
45 45
46 public function reset() 46 public function reset()
47 { 47 {
48 $this->data = array( 48 $this->data = [
49 'calls' => $this->cloneVar(array()), 49 'calls' => $this->cloneVar([]),
50 'violations_count' => 0, 50 'violations_count' => 0,
51 ); 51 ];
52 } 52 }
53 53
54 /** 54 /**
55 * {@inheritdoc} 55 * {@inheritdoc}
56 */ 56 */
57 public function lateCollect() 57 public function lateCollect()
58 { 58 {
59 $collected = $this->validator->getCollectedData(); 59 $collected = $this->validator->getCollectedData();
60 $this->data['calls'] = $this->cloneVar($collected); 60 $this->data['calls'] = $this->cloneVar($collected);
61 $this->data['violations_count'] = array_reduce($collected, function ($previous, $item) { 61 $this->data['violations_count'] = array_reduce($collected, function ($previous, $item) {
62 return $previous + count($item['violations']); 62 return $previous + \count($item['violations']);
63 }, 0); 63 }, 0);
64 } 64 }
65 65
66 /** 66 /**
67 * @return Data 67 * @return Data
87 return 'validator'; 87 return 'validator';
88 } 88 }
89 89
90 protected function getCasters() 90 protected function getCasters()
91 { 91 {
92 return parent::getCasters() + array( 92 return parent::getCasters() + [
93 \Exception::class => function (\Exception $e, array $a, Stub $s) { 93 \Exception::class => function (\Exception $e, array $a, Stub $s) {
94 foreach (array("\0Exception\0previous", "\0Exception\0trace") as $k) { 94 foreach (["\0Exception\0previous", "\0Exception\0trace"] as $k) {
95 if (isset($a[$k])) { 95 if (isset($a[$k])) {
96 unset($a[$k]); 96 unset($a[$k]);
97 ++$s->cut; 97 ++$s->cut;
98 } 98 }
99 } 99 }
100 100
101 return $a; 101 return $a;
102 }, 102 },
103 FormInterface::class => function (FormInterface $f, array $a) { 103 FormInterface::class => function (FormInterface $f, array $a) {
104 return array( 104 return [
105 Caster::PREFIX_VIRTUAL.'name' => $f->getName(), 105 Caster::PREFIX_VIRTUAL.'name' => $f->getName(),
106 Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())), 106 Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(\get_class($f->getConfig()->getType()->getInnerType())),
107 Caster::PREFIX_VIRTUAL.'data' => $f->getData(), 107 Caster::PREFIX_VIRTUAL.'data' => $f->getData(),
108 ); 108 ];
109 }, 109 },
110 ); 110 ];
111 } 111 }
112 } 112 }