comparison vendor/symfony/serializer/Normalizer/PropertyNormalizer.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
28 * @author Matthieu Napoli <matthieu@mnapoli.fr> 28 * @author Matthieu Napoli <matthieu@mnapoli.fr>
29 * @author Kévin Dunglas <dunglas@gmail.com> 29 * @author Kévin Dunglas <dunglas@gmail.com>
30 */ 30 */
31 class PropertyNormalizer extends AbstractObjectNormalizer 31 class PropertyNormalizer extends AbstractObjectNormalizer
32 { 32 {
33 private $cache = array(); 33 private $cache = [];
34 34
35 /** 35 /**
36 * {@inheritdoc} 36 * {@inheritdoc}
37 */ 37 */
38 public function supportsNormalization($data, $format = null) 38 public function supportsNormalization($data, $format = null)
72 } 72 }
73 73
74 /** 74 /**
75 * {@inheritdoc} 75 * {@inheritdoc}
76 */ 76 */
77 protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = array()) 77 protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = [])
78 { 78 {
79 if (!parent::isAllowedAttribute($classOrObject, $attribute, $format, $context)) { 79 if (!parent::isAllowedAttribute($classOrObject, $attribute, $format, $context)) {
80 return false; 80 return false;
81 } 81 }
82 82
93 } 93 }
94 94
95 /** 95 /**
96 * {@inheritdoc} 96 * {@inheritdoc}
97 */ 97 */
98 protected function extractAttributes($object, $format = null, array $context = array()) 98 protected function extractAttributes($object, $format = null, array $context = [])
99 { 99 {
100 $reflectionObject = new \ReflectionObject($object); 100 $reflectionObject = new \ReflectionObject($object);
101 $attributes = array(); 101 $attributes = [];
102 102
103 do { 103 do {
104 foreach ($reflectionObject->getProperties() as $property) { 104 foreach ($reflectionObject->getProperties() as $property) {
105 if (!$this->isAllowedAttribute($reflectionObject->getName(), $property->name)) { 105 if (!$this->isAllowedAttribute($reflectionObject->getName(), $property->name)) {
106 continue; 106 continue;
114 } 114 }
115 115
116 /** 116 /**
117 * {@inheritdoc} 117 * {@inheritdoc}
118 */ 118 */
119 protected function getAttributeValue($object, $attribute, $format = null, array $context = array()) 119 protected function getAttributeValue($object, $attribute, $format = null, array $context = [])
120 { 120 {
121 try { 121 try {
122 $reflectionProperty = $this->getReflectionProperty($object, $attribute); 122 $reflectionProperty = $this->getReflectionProperty($object, $attribute);
123 } catch (\ReflectionException $reflectionException) { 123 } catch (\ReflectionException $reflectionException) {
124 return; 124 return;
133 } 133 }
134 134
135 /** 135 /**
136 * {@inheritdoc} 136 * {@inheritdoc}
137 */ 137 */
138 protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = array()) 138 protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = [])
139 { 139 {
140 try { 140 try {
141 $reflectionProperty = $this->getReflectionProperty($object, $attribute); 141 $reflectionProperty = $this->getReflectionProperty($object, $attribute);
142 } catch (\ReflectionException $reflectionException) { 142 } catch (\ReflectionException $reflectionException) {
143 return; 143 return;