@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | public function enableExternalEntities(bool $enable = true): self |
42 | 42 | { |
43 | - $this->disableExternalEntities = !$enable; |
|
43 | + $this->disableExternalEntities = ! $enable; |
|
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | public function __construct($skipVirtualTypeInit = true, $initializeExcluded = false) |
43 | 43 | { |
44 | - $this->skipVirtualTypeInit = (bool)$skipVirtualTypeInit; |
|
45 | - $this->initializeExcluded = (bool)$initializeExcluded; |
|
44 | + $this->skipVirtualTypeInit = (bool) $skipVirtualTypeInit; |
|
45 | + $this->initializeExcluded = (bool) $initializeExcluded; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function onPreSerialize(PreSerializeEvent $event) |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | // If the set type name is not an actual class, but a faked type for which a custom handler exists, we do not |
54 | 54 | // modify it with this subscriber. Also, we forgo autoloading here as an instance of this type is already created, |
55 | 55 | // so it must be loaded if its a real class. |
56 | - $virtualType = !class_exists($type['name'], false); |
|
56 | + $virtualType = ! class_exists($type['name'], false); |
|
57 | 57 | |
58 | 58 | if ($object instanceof PersistentCollection |
59 | 59 | || $object instanceof MongoDBPersistentCollection |
60 | 60 | || $object instanceof PHPCRPersistentCollection |
61 | 61 | ) { |
62 | - if (!$virtualType) { |
|
62 | + if ( ! $virtualType) { |
|
63 | 63 | $event->setType('ArrayCollection'); |
64 | 64 | } |
65 | 65 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | if (($this->skipVirtualTypeInit && $virtualType) || |
70 | - (!$object instanceof Proxy && !$object instanceof ORMProxy) |
|
70 | + ( ! $object instanceof Proxy && ! $object instanceof ORMProxy) |
|
71 | 71 | ) { |
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | 75 | // do not initialize the proxy if is going to be excluded by-class by some exclusion strategy |
76 | - if ($this->initializeExcluded === false && !$virtualType) { |
|
76 | + if ($this->initializeExcluded === false && ! $virtualType) { |
|
77 | 77 | $context = $event->getContext(); |
78 | 78 | $exclusionStrategy = $context->getExclusionStrategy(); |
79 | 79 | $metadata = $context->getMetadataFactory()->getMetadataForClass(get_parent_class($object)); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | $object->__load(); |
86 | 86 | |
87 | - if (!$virtualType) { |
|
87 | + if ( ! $virtualType) { |
|
88 | 88 | $event->setType(get_parent_class($object), $type['params']); |
89 | 89 | } |
90 | 90 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | { |
94 | 94 | $type = $event->getType(); |
95 | 95 | // is a virtual type? then there is no need to change the event name |
96 | - if (!class_exists($type['name'], false)) { |
|
96 | + if ( ! class_exists($type['name'], false)) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | 99 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | private $namingStrategy; |
42 | 42 | |
43 | - public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, AbstractParser $typeParser = null) |
|
43 | + public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, AbstractParser $typeParser = null) |
|
44 | 44 | { |
45 | 45 | parent::__construct($locator); |
46 | 46 | $this->typeParser = $typeParser ?: new TypeParser(); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $config = Yaml::parse(file_get_contents($file)); |
53 | 53 | |
54 | - if (!isset($config[$name = $class->name])) { |
|
54 | + if ( ! isset($config[$name = $class->name])) { |
|
55 | 55 | throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file)); |
56 | 56 | } |
57 | 57 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | $metadata->fileResources[] = $file; |
61 | 61 | $metadata->fileResources[] = $class->getFileName(); |
62 | 62 | $exclusionPolicy = isset($config['exclusion_policy']) ? strtoupper($config['exclusion_policy']) : 'NONE'; |
63 | - $excludeAll = isset($config['exclude']) ? (Boolean)$config['exclude'] : false; |
|
63 | + $excludeAll = isset($config['exclude']) ? (Boolean) $config['exclude'] : false; |
|
64 | 64 | $classAccessType = isset($config['access_type']) ? $config['access_type'] : PropertyMetadata::ACCESS_TYPE_PROPERTY; |
65 | - $readOnlyClass = isset($config['read_only']) ? (Boolean)$config['read_only'] : false; |
|
65 | + $readOnlyClass = isset($config['read_only']) ? (Boolean) $config['read_only'] : false; |
|
66 | 66 | $this->addClassProperties($metadata, $config); |
67 | 67 | |
68 | 68 | $propertiesMetadata = array(); |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | |
75 | 75 | } else { |
76 | 76 | |
77 | - if (!$class->hasMethod($methodName)) { |
|
78 | - throw new RuntimeException('The method ' . $methodName . ' not found in class ' . $class->name); |
|
77 | + if ( ! $class->hasMethod($methodName)) { |
|
78 | + throw new RuntimeException('The method '.$methodName.' not found in class '.$class->name); |
|
79 | 79 | } |
80 | 80 | $virtualPropertyMetadata = new VirtualPropertyMetadata($name, $methodName); |
81 | 81 | } |
82 | 82 | |
83 | - $pName = !empty($propertySettings["name"]) ? $propertySettings["name"] : $virtualPropertyMetadata->name; |
|
83 | + $pName = ! empty($propertySettings["name"]) ? $propertySettings["name"] : $virtualPropertyMetadata->name; |
|
84 | 84 | |
85 | 85 | $propertiesMetadata[$pName] = $virtualPropertyMetadata; |
86 | 86 | $config['properties'][$pName] = $propertySettings; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | - if (!$excludeAll) { |
|
90 | + if ( ! $excludeAll) { |
|
91 | 91 | foreach ($class->getProperties() as $property) { |
92 | 92 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
93 | 93 | continue; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $pConfig = $config['properties'][$pName]; |
108 | 108 | |
109 | 109 | if (isset($pConfig['exclude'])) { |
110 | - $isExclude = (Boolean)$pConfig['exclude']; |
|
110 | + $isExclude = (Boolean) $pConfig['exclude']; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | if ($isExclude) { |
@@ -115,35 +115,35 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | if (isset($pConfig['expose'])) { |
118 | - $isExpose = (Boolean)$pConfig['expose']; |
|
118 | + $isExpose = (Boolean) $pConfig['expose']; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (isset($pConfig['skip_when_empty'])) { |
122 | - $pMetadata->skipWhenEmpty = (Boolean)$pConfig['skip_when_empty']; |
|
122 | + $pMetadata->skipWhenEmpty = (Boolean) $pConfig['skip_when_empty']; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | if (isset($pConfig['since_version'])) { |
126 | - $pMetadata->sinceVersion = (string)$pConfig['since_version']; |
|
126 | + $pMetadata->sinceVersion = (string) $pConfig['since_version']; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | if (isset($pConfig['until_version'])) { |
130 | - $pMetadata->untilVersion = (string)$pConfig['until_version']; |
|
130 | + $pMetadata->untilVersion = (string) $pConfig['until_version']; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | if (isset($pConfig['exclude_if'])) { |
134 | - $pMetadata->excludeIf = (string)$pConfig['exclude_if']; |
|
134 | + $pMetadata->excludeIf = (string) $pConfig['exclude_if']; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | if (isset($pConfig['expose_if'])) { |
138 | - $pMetadata->excludeIf = "!(" . $pConfig['expose_if'] . ")"; |
|
138 | + $pMetadata->excludeIf = "!(".$pConfig['expose_if'].")"; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | if (isset($pConfig['serialized_name'])) { |
142 | - $pMetadata->serializedName = (string)$pConfig['serialized_name']; |
|
142 | + $pMetadata->serializedName = (string) $pConfig['serialized_name']; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | if (isset($pConfig['type'])) { |
146 | - $pMetadata->setType($this->typeParser->parse((string)$pConfig['type'])); |
|
146 | + $pMetadata->setType($this->typeParser->parse((string) $pConfig['type'])); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | if (isset($pConfig['groups'])) { |
@@ -155,21 +155,21 @@ discard block |
||
155 | 155 | |
156 | 156 | $colConfig = $pConfig['xml_list']; |
157 | 157 | if (isset($colConfig['inline'])) { |
158 | - $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline']; |
|
158 | + $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline']; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | if (isset($colConfig['entry_name'])) { |
162 | - $pMetadata->xmlEntryName = (string)$colConfig['entry_name']; |
|
162 | + $pMetadata->xmlEntryName = (string) $colConfig['entry_name']; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | if (isset($colConfig['skip_when_empty'])) { |
166 | - $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean)$colConfig['skip_when_empty']; |
|
166 | + $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean) $colConfig['skip_when_empty']; |
|
167 | 167 | } else { |
168 | 168 | $pMetadata->xmlCollectionSkipWhenEmpty = true; |
169 | 169 | } |
170 | 170 | |
171 | 171 | if (isset($colConfig['namespace'])) { |
172 | - $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace']; |
|
172 | + $pMetadata->xmlEntryNamespace = (string) $colConfig['namespace']; |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | |
179 | 179 | $colConfig = $pConfig['xml_map']; |
180 | 180 | if (isset($colConfig['inline'])) { |
181 | - $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline']; |
|
181 | + $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline']; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | if (isset($colConfig['entry_name'])) { |
185 | - $pMetadata->xmlEntryName = (string)$colConfig['entry_name']; |
|
185 | + $pMetadata->xmlEntryName = (string) $colConfig['entry_name']; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | if (isset($colConfig['namespace'])) { |
189 | - $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace']; |
|
189 | + $pMetadata->xmlEntryNamespace = (string) $colConfig['namespace']; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | if (isset($colConfig['key_attribute_name'])) { |
@@ -198,33 +198,33 @@ discard block |
||
198 | 198 | if (isset($pConfig['xml_element'])) { |
199 | 199 | $colConfig = $pConfig['xml_element']; |
200 | 200 | if (isset($colConfig['cdata'])) { |
201 | - $pMetadata->xmlElementCData = (Boolean)$colConfig['cdata']; |
|
201 | + $pMetadata->xmlElementCData = (Boolean) $colConfig['cdata']; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | if (isset($colConfig['namespace'])) { |
205 | - $pMetadata->xmlNamespace = (string)$colConfig['namespace']; |
|
205 | + $pMetadata->xmlNamespace = (string) $colConfig['namespace']; |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | 209 | if (isset($pConfig['xml_attribute'])) { |
210 | - $pMetadata->xmlAttribute = (Boolean)$pConfig['xml_attribute']; |
|
210 | + $pMetadata->xmlAttribute = (Boolean) $pConfig['xml_attribute']; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | if (isset($pConfig['xml_attribute_map'])) { |
214 | - $pMetadata->xmlAttributeMap = (Boolean)$pConfig['xml_attribute_map']; |
|
214 | + $pMetadata->xmlAttributeMap = (Boolean) $pConfig['xml_attribute_map']; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if (isset($pConfig['xml_value'])) { |
218 | - $pMetadata->xmlValue = (Boolean)$pConfig['xml_value']; |
|
218 | + $pMetadata->xmlValue = (Boolean) $pConfig['xml_value']; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | if (isset($pConfig['xml_key_value_pairs'])) { |
222 | - $pMetadata->xmlKeyValuePairs = (Boolean)$pConfig['xml_key_value_pairs']; |
|
222 | + $pMetadata->xmlKeyValuePairs = (Boolean) $pConfig['xml_key_value_pairs']; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | //we need read_only before setter and getter set, because that method depends on flag being set |
226 | 226 | if (isset($pConfig['read_only'])) { |
227 | - $pMetadata->readOnly = (Boolean)$pConfig['read_only']; |
|
227 | + $pMetadata->readOnly = (Boolean) $pConfig['read_only']; |
|
228 | 228 | } else { |
229 | 229 | $pMetadata->readOnly = $pMetadata->readOnly || $readOnlyClass; |
230 | 230 | } |
@@ -236,15 +236,15 @@ discard block |
||
236 | 236 | ); |
237 | 237 | |
238 | 238 | if (isset($pConfig['inline'])) { |
239 | - $pMetadata->inline = (Boolean)$pConfig['inline']; |
|
239 | + $pMetadata->inline = (Boolean) $pConfig['inline']; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | if (isset($pConfig['max_depth'])) { |
243 | - $pMetadata->maxDepth = (int)$pConfig['max_depth']; |
|
243 | + $pMetadata->maxDepth = (int) $pConfig['max_depth']; |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - if (!$pMetadata->serializedName) { |
|
247 | + if ( ! $pMetadata->serializedName) { |
|
248 | 248 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
249 | 249 | } |
250 | 250 | |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | $pConfig = $config['properties'][$pName]; |
253 | 253 | |
254 | 254 | if (isset($pConfig['name'])) { |
255 | - $pMetadata->name = (string)$pConfig['name']; |
|
255 | + $pMetadata->name = (string) $pConfig['name']; |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
259 | + if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
260 | 260 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
261 | 261 | ) { |
262 | 262 | $metadata->addPropertyMetadata($pMetadata); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | private function addClassProperties(ClassMetadata $metadata, array $config) |
290 | 290 | { |
291 | - if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) { |
|
291 | + if (isset($config['custom_accessor_order']) && ! isset($config['accessor_order'])) { |
|
292 | 292 | $config['accessor_order'] = 'custom'; |
293 | 293 | } |
294 | 294 | |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | if (isset($config['xml_root_name'])) { |
300 | - $metadata->xmlRootName = (string)$config['xml_root_name']; |
|
300 | + $metadata->xmlRootName = (string) $config['xml_root_name']; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | if (isset($config['xml_root_namespace'])) { |
304 | - $metadata->xmlRootNamespace = (string)$config['xml_root_namespace']; |
|
304 | + $metadata->xmlRootNamespace = (string) $config['xml_root_namespace']; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | if (array_key_exists('xml_namespaces', $config)) { |
@@ -316,25 +316,25 @@ discard block |
||
316 | 316 | if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) { |
317 | 317 | $metadata->discriminatorDisabled = true; |
318 | 318 | } else { |
319 | - if (!isset($config['discriminator']['field_name'])) { |
|
319 | + if ( ! isset($config['discriminator']['field_name'])) { |
|
320 | 320 | throw new RuntimeException('The "field_name" attribute must be set for discriminators.'); |
321 | 321 | } |
322 | 322 | |
323 | - if (!isset($config['discriminator']['map']) || !\is_array($config['discriminator']['map'])) { |
|
323 | + if ( ! isset($config['discriminator']['map']) || ! \is_array($config['discriminator']['map'])) { |
|
324 | 324 | throw new RuntimeException('The "map" attribute must be set, and be an array for discriminators.'); |
325 | 325 | } |
326 | 326 | $groups = isset($config['discriminator']['groups']) ? $config['discriminator']['groups'] : array(); |
327 | 327 | $metadata->setDiscriminator($config['discriminator']['field_name'], $config['discriminator']['map'], $groups); |
328 | 328 | |
329 | 329 | if (isset($config['discriminator']['xml_attribute'])) { |
330 | - $metadata->xmlDiscriminatorAttribute = (bool)$config['discriminator']['xml_attribute']; |
|
330 | + $metadata->xmlDiscriminatorAttribute = (bool) $config['discriminator']['xml_attribute']; |
|
331 | 331 | } |
332 | 332 | if (isset($config['discriminator']['xml_element'])) { |
333 | 333 | if (isset($config['discriminator']['xml_element']['cdata'])) { |
334 | - $metadata->xmlDiscriminatorCData = (bool)$config['discriminator']['xml_element']['cdata']; |
|
334 | + $metadata->xmlDiscriminatorCData = (bool) $config['discriminator']['xml_element']['cdata']; |
|
335 | 335 | } |
336 | 336 | if (isset($config['discriminator']['xml_element']['namespace'])) { |
337 | - $metadata->xmlDiscriminatorNamespace = (string)$config['discriminator']['xml_element']['namespace']; |
|
337 | + $metadata->xmlDiscriminatorNamespace = (string) $config['discriminator']['xml_element']['namespace']; |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
@@ -346,13 +346,13 @@ discard block |
||
346 | 346 | { |
347 | 347 | if (\is_string($config)) { |
348 | 348 | $config = array($config); |
349 | - } elseif (!\is_array($config)) { |
|
349 | + } elseif ( ! \is_array($config)) { |
|
350 | 350 | throw new RuntimeException(sprintf('callback methods expects a string, or an array of strings that represent method names, but got %s.', json_encode($config['pre_serialize']))); |
351 | 351 | } |
352 | 352 | |
353 | 353 | $methods = array(); |
354 | 354 | foreach ($config as $name) { |
355 | - if (!$class->hasMethod($name)) { |
|
355 | + if ( ! $class->hasMethod($name)) { |
|
356 | 356 | throw new RuntimeException(sprintf('The method %s does not exist in class %s.', $name, $class->name)); |
357 | 357 | } |
358 | 358 |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | $classMetadata->setDiscriminator($annot->field, $annot->map, $annot->groups); |
113 | 113 | } |
114 | 114 | } elseif ($annot instanceof XmlDiscriminator) { |
115 | - $classMetadata->xmlDiscriminatorAttribute = (bool)$annot->attribute; |
|
116 | - $classMetadata->xmlDiscriminatorCData = (bool)$annot->cdata; |
|
117 | - $classMetadata->xmlDiscriminatorNamespace = $annot->namespace ? (string)$annot->namespace : null; |
|
115 | + $classMetadata->xmlDiscriminatorAttribute = (bool) $annot->attribute; |
|
116 | + $classMetadata->xmlDiscriminatorCData = (bool) $annot->cdata; |
|
117 | + $classMetadata->xmlDiscriminatorNamespace = $annot->namespace ? (string) $annot->namespace : null; |
|
118 | 118 | } elseif ($annot instanceof VirtualProperty) { |
119 | 119 | $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, $annot->name, $annot->exp); |
120 | 120 | $propertiesMetadata[] = $virtualPropertyMetadata; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - if (!$excludeAll) { |
|
151 | + if ( ! $excludeAll) { |
|
152 | 152 | foreach ($class->getProperties() as $property) { |
153 | 153 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
154 | 154 | continue; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } elseif ($annot instanceof Expose) { |
180 | 180 | $isExpose = true; |
181 | 181 | if (null !== $annot->if) { |
182 | - $propertyMetadata->excludeIf = "!(" . $annot->if . ")"; |
|
182 | + $propertyMetadata->excludeIf = "!(".$annot->if.")"; |
|
183 | 183 | } |
184 | 184 | } elseif ($annot instanceof Exclude) { |
185 | 185 | if (null !== $annot->if) { |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | $accessor = array($annot->getter, $annot->setter); |
224 | 224 | } elseif ($annot instanceof Groups) { |
225 | 225 | $propertyMetadata->groups = $annot->groups; |
226 | - foreach ((array)$propertyMetadata->groups as $groupName) { |
|
226 | + foreach ((array) $propertyMetadata->groups as $groupName) { |
|
227 | 227 | if (false !== strpos($groupName, ',')) { |
228 | 228 | throw new InvalidArgumentException(sprintf( |
229 | 229 | 'Invalid group name "%s" on "%s", did you mean to create multiple groups?', |
230 | 230 | implode(', ', $propertyMetadata->groups), |
231 | - $propertyMetadata->class . '->' . $propertyMetadata->name |
|
231 | + $propertyMetadata->class.'->'.$propertyMetadata->name |
|
232 | 232 | )); |
233 | 233 | } |
234 | 234 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | - if (!$propertyMetadata->serializedName) { |
|
244 | + if ( ! $propertyMetadata->serializedName) { |
|
245 | 245 | $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata); |
246 | 246 | } |
247 | 247 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
254 | + if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
255 | 255 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
256 | 256 | ) { |
257 | 257 | $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | private $namingStrategy; |
42 | 42 | |
43 | - public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, AbstractParser $typeParser = null) |
|
43 | + public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, AbstractParser $typeParser = null) |
|
44 | 44 | { |
45 | 45 | parent::__construct($locator); |
46 | 46 | $this->typeParser = $typeParser ?: new TypeParser(); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | $metadata = new ClassMetadata($name = $class->name); |
63 | - if (!$elems = $elem->xpath("./class[@name = '" . $name . "']")) { |
|
63 | + if ( ! $elems = $elem->xpath("./class[@name = '".$name."']")) { |
|
64 | 64 | throw new RuntimeException(sprintf('Could not find class %s inside XML element.', $name)); |
65 | 65 | } |
66 | 66 | $elem = reset($elems); |
@@ -69,88 +69,88 @@ discard block |
||
69 | 69 | $metadata->fileResources[] = $class->getFileName(); |
70 | 70 | $exclusionPolicy = strtoupper($elem->attributes()->{'exclusion-policy'}) ?: 'NONE'; |
71 | 71 | $excludeAll = null !== ($exclude = $elem->attributes()->exclude) ? 'true' === strtolower($exclude) : false; |
72 | - $classAccessType = (string)($elem->attributes()->{'access-type'} ?: PropertyMetadata::ACCESS_TYPE_PROPERTY); |
|
72 | + $classAccessType = (string) ($elem->attributes()->{'access-type'} ?: PropertyMetadata::ACCESS_TYPE_PROPERTY); |
|
73 | 73 | |
74 | 74 | $propertiesMetadata = array(); |
75 | 75 | $propertiesNodes = array(); |
76 | 76 | |
77 | 77 | if (null !== $accessorOrder = $elem->attributes()->{'accessor-order'}) { |
78 | - $metadata->setAccessorOrder((string)$accessorOrder, preg_split('/\s*,\s*/', (string)$elem->attributes()->{'custom-accessor-order'})); |
|
78 | + $metadata->setAccessorOrder((string) $accessorOrder, preg_split('/\s*,\s*/', (string) $elem->attributes()->{'custom-accessor-order'})); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | if (null !== $xmlRootName = $elem->attributes()->{'xml-root-name'}) { |
82 | - $metadata->xmlRootName = (string)$xmlRootName; |
|
82 | + $metadata->xmlRootName = (string) $xmlRootName; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | if (null !== $xmlRootNamespace = $elem->attributes()->{'xml-root-namespace'}) { |
86 | - $metadata->xmlRootNamespace = (string)$xmlRootNamespace; |
|
86 | + $metadata->xmlRootNamespace = (string) $xmlRootNamespace; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $readOnlyClass = 'true' === strtolower($elem->attributes()->{'read-only'}); |
90 | 90 | |
91 | - $discriminatorFieldName = (string)$elem->attributes()->{'discriminator-field-name'}; |
|
91 | + $discriminatorFieldName = (string) $elem->attributes()->{'discriminator-field-name'}; |
|
92 | 92 | $discriminatorMap = array(); |
93 | 93 | foreach ($elem->xpath('./discriminator-class') as $entry) { |
94 | - if (!isset($entry->attributes()->value)) { |
|
94 | + if ( ! isset($entry->attributes()->value)) { |
|
95 | 95 | throw new RuntimeException('Each discriminator-class element must have a "value" attribute.'); |
96 | 96 | } |
97 | 97 | |
98 | - $discriminatorMap[(string)$entry->attributes()->value] = (string)$entry; |
|
98 | + $discriminatorMap[(string) $entry->attributes()->value] = (string) $entry; |
|
99 | 99 | } |
100 | 100 | |
101 | - if ('true' === (string)$elem->attributes()->{'discriminator-disabled'}) { |
|
101 | + if ('true' === (string) $elem->attributes()->{'discriminator-disabled'}) { |
|
102 | 102 | $metadata->discriminatorDisabled = true; |
103 | - } elseif (!empty($discriminatorFieldName) || !empty($discriminatorMap)) { |
|
103 | + } elseif ( ! empty($discriminatorFieldName) || ! empty($discriminatorMap)) { |
|
104 | 104 | |
105 | 105 | $discriminatorGroups = array(); |
106 | 106 | foreach ($elem->xpath('./discriminator-groups/group') as $entry) { |
107 | - $discriminatorGroups[] = (string)$entry; |
|
107 | + $discriminatorGroups[] = (string) $entry; |
|
108 | 108 | } |
109 | 109 | $metadata->setDiscriminator($discriminatorFieldName, $discriminatorMap, $discriminatorGroups); |
110 | 110 | } |
111 | 111 | |
112 | 112 | foreach ($elem->xpath('./xml-namespace') as $xmlNamespace) { |
113 | - if (!isset($xmlNamespace->attributes()->uri)) { |
|
113 | + if ( ! isset($xmlNamespace->attributes()->uri)) { |
|
114 | 114 | throw new RuntimeException('The prefix attribute must be set for all xml-namespace elements.'); |
115 | 115 | } |
116 | 116 | |
117 | 117 | if (isset($xmlNamespace->attributes()->prefix)) { |
118 | - $prefix = (string)$xmlNamespace->attributes()->prefix; |
|
118 | + $prefix = (string) $xmlNamespace->attributes()->prefix; |
|
119 | 119 | } else { |
120 | 120 | $prefix = null; |
121 | 121 | } |
122 | 122 | |
123 | - $metadata->registerNamespace((string)$xmlNamespace->attributes()->uri, $prefix); |
|
123 | + $metadata->registerNamespace((string) $xmlNamespace->attributes()->uri, $prefix); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | foreach ($elem->xpath('./xml-discriminator') as $xmlDiscriminator) { |
127 | 127 | if (isset($xmlDiscriminator->attributes()->attribute)) { |
128 | - $metadata->xmlDiscriminatorAttribute = (string)$xmlDiscriminator->attributes()->attribute === 'true'; |
|
128 | + $metadata->xmlDiscriminatorAttribute = (string) $xmlDiscriminator->attributes()->attribute === 'true'; |
|
129 | 129 | } |
130 | 130 | if (isset($xmlDiscriminator->attributes()->cdata)) { |
131 | - $metadata->xmlDiscriminatorCData = (string)$xmlDiscriminator->attributes()->cdata === 'true'; |
|
131 | + $metadata->xmlDiscriminatorCData = (string) $xmlDiscriminator->attributes()->cdata === 'true'; |
|
132 | 132 | } |
133 | 133 | if (isset($xmlDiscriminator->attributes()->namespace)) { |
134 | - $metadata->xmlDiscriminatorNamespace = (string)$xmlDiscriminator->attributes()->namespace; |
|
134 | + $metadata->xmlDiscriminatorNamespace = (string) $xmlDiscriminator->attributes()->namespace; |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | 138 | foreach ($elem->xpath('./virtual-property') as $method) { |
139 | 139 | |
140 | 140 | if (isset($method->attributes()->expression)) { |
141 | - $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, (string)$method->attributes()->name, (string)$method->attributes()->expression); |
|
141 | + $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, (string) $method->attributes()->name, (string) $method->attributes()->expression); |
|
142 | 142 | } else { |
143 | - if (!isset($method->attributes()->method)) { |
|
143 | + if ( ! isset($method->attributes()->method)) { |
|
144 | 144 | throw new RuntimeException('The method attribute must be set for all virtual-property elements.'); |
145 | 145 | } |
146 | - $virtualPropertyMetadata = new VirtualPropertyMetadata($name, (string)$method->attributes()->method); |
|
146 | + $virtualPropertyMetadata = new VirtualPropertyMetadata($name, (string) $method->attributes()->method); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $propertiesMetadata[] = $virtualPropertyMetadata; |
150 | 150 | $propertiesNodes[] = $method; |
151 | 151 | } |
152 | 152 | |
153 | - if (!$excludeAll) { |
|
153 | + if ( ! $excludeAll) { |
|
154 | 154 | |
155 | 155 | foreach ($class->getProperties() as $property) { |
156 | 156 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | $propertiesMetadata[] = new PropertyMetadata($name, $pName = $property->getName()); |
161 | - $pElems = $elem->xpath("./property[@name = '" . $pName . "']"); |
|
161 | + $pElems = $elem->xpath("./property[@name = '".$pName."']"); |
|
162 | 162 | |
163 | 163 | $propertiesNodes[] = $pElems ? reset($pElems) : null; |
164 | 164 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | || $pMetadata instanceof ExpressionPropertyMetadata; |
171 | 171 | |
172 | 172 | $pElem = $propertiesNodes[$propertyKey]; |
173 | - if (!empty($pElem)) { |
|
173 | + if ( ! empty($pElem)) { |
|
174 | 174 | |
175 | 175 | if (null !== $exclude = $pElem->attributes()->exclude) { |
176 | 176 | $isExclude = 'true' === strtolower($exclude); |
@@ -193,26 +193,26 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | if (null !== $excludeIf = $pElem->attributes()->{'expose-if'}) { |
196 | - $pMetadata->excludeIf = "!(" . $excludeIf . ")"; |
|
196 | + $pMetadata->excludeIf = "!(".$excludeIf.")"; |
|
197 | 197 | $isExpose = true; |
198 | 198 | } |
199 | 199 | |
200 | 200 | if (null !== $version = $pElem->attributes()->{'since-version'}) { |
201 | - $pMetadata->sinceVersion = (string)$version; |
|
201 | + $pMetadata->sinceVersion = (string) $version; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | if (null !== $version = $pElem->attributes()->{'until-version'}) { |
205 | - $pMetadata->untilVersion = (string)$version; |
|
205 | + $pMetadata->untilVersion = (string) $version; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | if (null !== $serializedName = $pElem->attributes()->{'serialized-name'}) { |
209 | - $pMetadata->serializedName = (string)$serializedName; |
|
209 | + $pMetadata->serializedName = (string) $serializedName; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | if (null !== $type = $pElem->attributes()->type) { |
213 | - $pMetadata->setType($this->typeParser->parse((string)$type)); |
|
213 | + $pMetadata->setType($this->typeParser->parse((string) $type)); |
|
214 | 214 | } elseif (isset($pElem->type)) { |
215 | - $pMetadata->setType($this->typeParser->parse((string)$pElem->type)); |
|
215 | + $pMetadata->setType($this->typeParser->parse((string) $pElem->type)); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | if (null !== $groups = $pElem->attributes()->groups) { |
@@ -227,21 +227,21 @@ discard block |
||
227 | 227 | |
228 | 228 | $colConfig = $pElem->{'xml-list'}; |
229 | 229 | if (isset($colConfig->attributes()->inline)) { |
230 | - $pMetadata->xmlCollectionInline = 'true' === (string)$colConfig->attributes()->inline; |
|
230 | + $pMetadata->xmlCollectionInline = 'true' === (string) $colConfig->attributes()->inline; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if (isset($colConfig->attributes()->{'entry-name'})) { |
234 | - $pMetadata->xmlEntryName = (string)$colConfig->attributes()->{'entry-name'}; |
|
234 | + $pMetadata->xmlEntryName = (string) $colConfig->attributes()->{'entry-name'}; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | if (isset($colConfig->attributes()->{'skip-when-empty'})) { |
238 | - $pMetadata->xmlCollectionSkipWhenEmpty = 'true' === (string)$colConfig->attributes()->{'skip-when-empty'}; |
|
238 | + $pMetadata->xmlCollectionSkipWhenEmpty = 'true' === (string) $colConfig->attributes()->{'skip-when-empty'}; |
|
239 | 239 | } else { |
240 | 240 | $pMetadata->xmlCollectionSkipWhenEmpty = true; |
241 | 241 | } |
242 | 242 | |
243 | 243 | if (isset($colConfig->attributes()->namespace)) { |
244 | - $pMetadata->xmlEntryNamespace = (string)$colConfig->attributes()->namespace; |
|
244 | + $pMetadata->xmlEntryNamespace = (string) $colConfig->attributes()->namespace; |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
@@ -250,51 +250,51 @@ discard block |
||
250 | 250 | |
251 | 251 | $colConfig = $pElem->{'xml-map'}; |
252 | 252 | if (isset($colConfig->attributes()->inline)) { |
253 | - $pMetadata->xmlCollectionInline = 'true' === (string)$colConfig->attributes()->inline; |
|
253 | + $pMetadata->xmlCollectionInline = 'true' === (string) $colConfig->attributes()->inline; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if (isset($colConfig->attributes()->{'entry-name'})) { |
257 | - $pMetadata->xmlEntryName = (string)$colConfig->attributes()->{'entry-name'}; |
|
257 | + $pMetadata->xmlEntryName = (string) $colConfig->attributes()->{'entry-name'}; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | if (isset($colConfig->attributes()->namespace)) { |
261 | - $pMetadata->xmlEntryNamespace = (string)$colConfig->attributes()->namespace; |
|
261 | + $pMetadata->xmlEntryNamespace = (string) $colConfig->attributes()->namespace; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | if (isset($colConfig->attributes()->{'key-attribute-name'})) { |
265 | - $pMetadata->xmlKeyAttribute = (string)$colConfig->attributes()->{'key-attribute-name'}; |
|
265 | + $pMetadata->xmlKeyAttribute = (string) $colConfig->attributes()->{'key-attribute-name'}; |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | 269 | if (isset($pElem->{'xml-element'})) { |
270 | 270 | $colConfig = $pElem->{'xml-element'}; |
271 | 271 | if (isset($colConfig->attributes()->cdata)) { |
272 | - $pMetadata->xmlElementCData = 'true' === (string)$colConfig->attributes()->cdata; |
|
272 | + $pMetadata->xmlElementCData = 'true' === (string) $colConfig->attributes()->cdata; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | if (isset($colConfig->attributes()->namespace)) { |
276 | - $pMetadata->xmlNamespace = (string)$colConfig->attributes()->namespace; |
|
276 | + $pMetadata->xmlNamespace = (string) $colConfig->attributes()->namespace; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | 280 | if (isset($pElem->attributes()->{'xml-attribute'})) { |
281 | - $pMetadata->xmlAttribute = 'true' === (string)$pElem->attributes()->{'xml-attribute'}; |
|
281 | + $pMetadata->xmlAttribute = 'true' === (string) $pElem->attributes()->{'xml-attribute'}; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | if (isset($pElem->attributes()->{'xml-attribute-map'})) { |
285 | - $pMetadata->xmlAttributeMap = 'true' === (string)$pElem->attributes()->{'xml-attribute-map'}; |
|
285 | + $pMetadata->xmlAttributeMap = 'true' === (string) $pElem->attributes()->{'xml-attribute-map'}; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | if (isset($pElem->attributes()->{'xml-value'})) { |
289 | - $pMetadata->xmlValue = 'true' === (string)$pElem->attributes()->{'xml-value'}; |
|
289 | + $pMetadata->xmlValue = 'true' === (string) $pElem->attributes()->{'xml-value'}; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | if (isset($pElem->attributes()->{'xml-key-value-pairs'})) { |
293 | - $pMetadata->xmlKeyValuePairs = 'true' === (string)$pElem->attributes()->{'xml-key-value-pairs'}; |
|
293 | + $pMetadata->xmlKeyValuePairs = 'true' === (string) $pElem->attributes()->{'xml-key-value-pairs'}; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | if (isset($pElem->attributes()->{'max-depth'})) { |
297 | - $pMetadata->maxDepth = (int)$pElem->attributes()->{'max-depth'}; |
|
297 | + $pMetadata->maxDepth = (int) $pElem->attributes()->{'max-depth'}; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | //we need read-only before setter and getter set, because that method depends on flag being set |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | $getter = $pElem->attributes()->{'accessor-getter'}; |
308 | 308 | $setter = $pElem->attributes()->{'accessor-setter'}; |
309 | 309 | $pMetadata->setAccessor( |
310 | - (string)($pElem->attributes()->{'access-type'} ?: $classAccessType), |
|
311 | - $getter ? (string)$getter : null, |
|
312 | - $setter ? (string)$setter : null |
|
310 | + (string) ($pElem->attributes()->{'access-type'} ?: $classAccessType), |
|
311 | + $getter ? (string) $getter : null, |
|
312 | + $setter ? (string) $setter : null |
|
313 | 313 | ); |
314 | 314 | |
315 | 315 | if (null !== $inline = $pElem->attributes()->inline) { |
@@ -317,16 +317,16 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - if (!$pMetadata->serializedName) { |
|
320 | + if ( ! $pMetadata->serializedName) { |
|
321 | 321 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
322 | 322 | } |
323 | 323 | |
324 | - if (!empty($pElem) && null !== $name = $pElem->attributes()->name) { |
|
325 | - $pMetadata->name = (string)$name; |
|
324 | + if ( ! empty($pElem) && null !== $name = $pElem->attributes()->name) { |
|
325 | + $pMetadata->name = (string) $name; |
|
326 | 326 | } |
327 | 327 | |
328 | - if ((ExclusionPolicy::NONE === (string)$exclusionPolicy && !$isExclude) |
|
329 | - || (ExclusionPolicy::ALL === (string)$exclusionPolicy && $isExpose) |
|
328 | + if ((ExclusionPolicy::NONE === (string) $exclusionPolicy && ! $isExclude) |
|
329 | + || (ExclusionPolicy::ALL === (string) $exclusionPolicy && $isExpose) |
|
330 | 330 | ) { |
331 | 331 | |
332 | 332 | |
@@ -336,31 +336,31 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | foreach ($elem->xpath('./callback-method') as $method) { |
339 | - if (!isset($method->attributes()->type)) { |
|
339 | + if ( ! isset($method->attributes()->type)) { |
|
340 | 340 | throw new RuntimeException('The type attribute must be set for all callback-method elements.'); |
341 | 341 | } |
342 | - if (!isset($method->attributes()->name)) { |
|
342 | + if ( ! isset($method->attributes()->name)) { |
|
343 | 343 | throw new RuntimeException('The name attribute must be set for all callback-method elements.'); |
344 | 344 | } |
345 | 345 | |
346 | - switch ((string)$method->attributes()->type) { |
|
346 | + switch ((string) $method->attributes()->type) { |
|
347 | 347 | case 'pre-serialize': |
348 | - $metadata->addPreSerializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
348 | + $metadata->addPreSerializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
349 | 349 | break; |
350 | 350 | |
351 | 351 | case 'post-serialize': |
352 | - $metadata->addPostSerializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
352 | + $metadata->addPostSerializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
353 | 353 | break; |
354 | 354 | |
355 | 355 | case 'post-deserialize': |
356 | - $metadata->addPostDeserializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
356 | + $metadata->addPostDeserializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
357 | 357 | break; |
358 | 358 | |
359 | 359 | case 'handler': |
360 | - if (!isset($method->attributes()->format)) { |
|
360 | + if ( ! isset($method->attributes()->format)) { |
|
361 | 361 | throw new RuntimeException('The format attribute must be set for "handler" callback methods.'); |
362 | 362 | } |
363 | - if (!isset($method->attributes()->direction)) { |
|
363 | + if ( ! isset($method->attributes()->direction)) { |
|
364 | 364 | throw new RuntimeException('The direction attribute must be set for "handler" callback methods.'); |
365 | 365 | } |
366 | 366 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | public function startVisiting($object): void |
54 | 54 | { |
55 | - if (!\is_object($object)) { |
|
55 | + if ( ! \is_object($object)) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | $this->visitingSet->attach($object); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function stopVisiting($object): void |
63 | 63 | { |
64 | - if (!\is_object($object)) { |
|
64 | + if ( ! \is_object($object)) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | 67 | $this->visitingSet->detach($object); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function isVisiting($object): bool |
76 | 76 | { |
77 | - if (!\is_object($object)) { |
|
77 | + if ( ! \is_object($object)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $path[] = \get_class($obj); |
89 | 89 | } |
90 | 90 | |
91 | - if (!$path) { |
|
91 | + if ( ! $path) { |
|
92 | 92 | return null; |
93 | 93 | } |
94 | 94 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function getObject() |
109 | 109 | { |
110 | - return !$this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
110 | + return ! $this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | public function getVisitingStack() |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | public function createRoot(ClassMetadata $metadata = null, $rootName = null, $rootNamespace = null) |
90 | 90 | { |
91 | - if ($metadata !== null && !empty($metadata->xmlRootName)) { |
|
91 | + if ($metadata !== null && ! empty($metadata->xmlRootName)) { |
|
92 | 92 | $rootName = $metadata->xmlRootName; |
93 | 93 | $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata); |
94 | 94 | } else { |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | { |
122 | 122 | $doCData = null !== $this->currentMetadata ? $this->currentMetadata->xmlElementCData : true; |
123 | 123 | |
124 | - return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string)$data); |
|
124 | + return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string) $data); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | public function visitSimpleString($data, array $type) |
128 | 128 | { |
129 | - return $this->document->createTextNode((string)$data); |
|
129 | + return $this->document->createTextNode((string) $data); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | public function visitBoolean(bool $data, array $type) |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | public function visitInteger(int $data, array $type) |
138 | 138 | { |
139 | - return $this->document->createTextNode((string)$data); |
|
139 | + return $this->document->createTextNode((string) $data); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function visitDouble(float $data, array $type) |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | if (floor($data) === $data) { |
145 | 145 | return $this->document->createTextNode($data.".0"); |
146 | 146 | } else { |
147 | - return $this->document->createTextNode((string)$data); |
|
147 | + return $this->document->createTextNode((string) $data); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $this->setCurrentNode($entryNode); |
173 | 173 | |
174 | 174 | if (null !== $keyAttributeName) { |
175 | - $entryNode->setAttribute($keyAttributeName, (string)$k); |
|
175 | + $entryNode->setAttribute($keyAttributeName, (string) $k); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | try { |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $node = $this->navigator->accept($v, $metadata->type, $this->context); |
214 | 214 | $this->revertCurrentMetadata(); |
215 | 215 | |
216 | - if (!$node instanceof \DOMCharacterData) { |
|
216 | + if ( ! $node instanceof \DOMCharacterData) { |
|
217 | 217 | throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v))); |
218 | 218 | } |
219 | 219 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | if (($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
226 | - || (!$metadata->xmlValue && $this->hasValue) |
|
226 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
227 | 227 | ) { |
228 | 228 | throw new RuntimeException(sprintf('If you make use of @XmlValue, all other properties in the class must have the @XmlAttribute annotation. Invalid usage detected in class %s.', $metadata->class)); |
229 | 229 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $node = $this->navigator->accept($v, $metadata->type, $this->context); |
236 | 236 | $this->revertCurrentMetadata(); |
237 | 237 | |
238 | - if (!$node instanceof \DOMCharacterData) { |
|
238 | + if ( ! $node instanceof \DOMCharacterData) { |
|
239 | 239 | throw new RuntimeException(sprintf('Unsupported value for property %s::$%s. Expected character data, but got %s.', $metadata->reflection->class, $metadata->reflection->name, \is_object($node) ? \get_class($node) : \gettype($node))); |
240 | 240 | } |
241 | 241 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | if ($metadata->xmlAttributeMap) { |
248 | - if (!\is_array($v)) { |
|
248 | + if ( ! \is_array($v)) { |
|
249 | 249 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v))); |
250 | 250 | } |
251 | 251 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $node = $this->navigator->accept($value, null, $this->context); |
255 | 255 | $this->revertCurrentMetadata(); |
256 | 256 | |
257 | - if (!$node instanceof \DOMCharacterData) { |
|
257 | + if ( ! $node instanceof \DOMCharacterData) { |
|
258 | 258 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
259 | 259 | } |
260 | 260 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
267 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
268 | 268 | |
269 | 269 | $namespace = null !== $metadata->xmlNamespace |
270 | 270 | ? $metadata->xmlNamespace |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | private function isSkippableEmptyObject($node, PropertyMetadata $metadata) |
316 | 316 | { |
317 | - return $node === null && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
317 | + return $node === null && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | private function isSkippableCollection(PropertyMetadata $metadata) |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | private function isElementEmpty(\DOMElement $element) |
326 | 326 | { |
327 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
327 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | public function endVisitingObject(ClassMetadata $metadata, object $data, array $type) |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
432 | 432 | $attribute = 'xmlns'; |
433 | 433 | if ($prefix !== '') { |
434 | - $attribute .= ':' . $prefix; |
|
434 | + $attribute .= ':'.$prefix; |
|
435 | 435 | } elseif ($element->namespaceURI === $uri) { |
436 | 436 | continue; |
437 | 437 | } |
@@ -447,19 +447,19 @@ discard block |
||
447 | 447 | if ($this->currentNode->isDefaultNamespace($namespace)) { |
448 | 448 | return $this->document->createElementNS($namespace, $tagName); |
449 | 449 | } |
450 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
451 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
450 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
451 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
452 | 452 | } |
453 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
453 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null) |
457 | 457 | { |
458 | 458 | if (null !== $namespace) { |
459 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
460 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
459 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
460 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
461 | 461 | } |
462 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
462 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
463 | 463 | } else { |
464 | 464 | $node->setAttribute($name, $value); |
465 | 465 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $context = $this->serializationContextFactory->createSerializationContext(); |
151 | 151 | } |
152 | 152 | |
153 | - if (!isset($this->serializationVisitors[$format])) { |
|
153 | + if ( ! isset($this->serializationVisitors[$format])) { |
|
154 | 154 | throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for serialization.', $format)); |
155 | 155 | } |
156 | 156 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $context = $this->deserializationContextFactory->createDeserializationContext(); |
170 | 170 | } |
171 | 171 | |
172 | - if (!isset($this->deserializationVisitors[$format])) { |
|
172 | + if ( ! isset($this->deserializationVisitors[$format])) { |
|
173 | 173 | throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for deserialization.', $format)); |
174 | 174 | } |
175 | 175 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $context = $this->serializationContextFactory->createSerializationContext(); |
190 | 190 | } |
191 | 191 | |
192 | - if (!isset($this->serializationVisitors['json'])) { |
|
192 | + if ( ! isset($this->serializationVisitors['json'])) { |
|
193 | 193 | throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for fromArray.', 'json')); |
194 | 194 | } |
195 | 195 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $result = $this->visit($this->serializationNavigator, $visitor, $context, $preparedData, 'json', $type); |
202 | 202 | $result = $this->convertArrayObjects($result); |
203 | 203 | |
204 | - if (!\is_array($result)) { |
|
204 | + if ( ! \is_array($result)) { |
|
205 | 205 | throw new RuntimeException(sprintf( |
206 | 206 | 'The input data of type "%s" did not convert to an array, but got a result of type "%s".', |
207 | 207 | \is_object($data) ? \get_class($data) : \gettype($data), |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $context = $this->deserializationContextFactory->createDeserializationContext(); |
222 | 222 | } |
223 | 223 | |
224 | - if (!isset($this->deserializationVisitors['json'])) { |
|
224 | + if ( ! isset($this->deserializationVisitors['json'])) { |
|
225 | 225 | throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for fromArray.', 'json')); |
226 | 226 | } |
227 | 227 | $visitor = $this->deserializationVisitors['json']->getVisitor($this->deserializationNavigator, $this->accessorStrategy, $context); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | private function convertArrayObjects($data) |
245 | 245 | { |
246 | 246 | if ($data instanceof \ArrayObject || $data instanceof \stdClass) { |
247 | - $data = (array)$data; |
|
247 | + $data = (array) $data; |
|
248 | 248 | } |
249 | 249 | if (\is_array($data)) { |
250 | 250 | foreach ($data as $k => $v) { |
@@ -95,8 +95,7 @@ |
||
95 | 95 | ExpressionEvaluatorInterface $expressionEvaluator = null, |
96 | 96 | SerializationContextFactoryInterface $serializationContextFactory = null, |
97 | 97 | DeserializationContextFactoryInterface $deserializationContextFactory = null |
98 | - ) |
|
99 | - { |
|
98 | + ) { |
|
100 | 99 | $this->factory = $factory; |
101 | 100 | $this->handlerRegistry = $handlerRegistry; |
102 | 101 | $this->objectConstructor = $objectConstructor; |
@@ -41,7 +41,7 @@ |
||
41 | 41 | */ |
42 | 42 | public function translateName(PropertyMetadata $property):string |
43 | 43 | { |
44 | - $name = preg_replace('/[A-Z]+/', $this->separator . '\\0', $property->name); |
|
44 | + $name = preg_replace('/[A-Z]+/', $this->separator.'\\0', $property->name); |
|
45 | 45 | |
46 | 46 | if ($this->lowerCase) { |
47 | 47 | return strtolower($name); |