Bladeren bron

fixed some styling issues, rebased, merged master

Jens Hassler 11 jaren geleden
bovenliggende
commit
6517be0332

+ 6 - 3
src/JMS/Serializer/AbstractVisitor.php

@@ -44,13 +44,16 @@ abstract class AbstractVisitor implements VisitorInterface
      */
      */
     protected function getElementType($typeArray)
     protected function getElementType($typeArray)
     {
     {
-        if (false === isset($typeArray['params'][0]))
+        if (false === isset($typeArray['params'][0])) {
             return null;
             return null;
+        }
 
 
-        if (isset($typeArray['params'][1]) && is_array($typeArray['params'][1]))
+        if (isset($typeArray['params'][1]) && is_array($typeArray['params'][1])) {
             return $typeArray['params'][1];
             return $typeArray['params'][1];
-        else
+        }
+        else {
             return $typeArray['params'][0];
             return $typeArray['params'][0];
+        }
     }
     }
 
 
 }
 }

+ 9 - 4
tests/JMS/Serializer/Tests/Serializer/BaseSerializationTest.php

@@ -274,10 +274,13 @@ abstract class BaseSerializationTest extends \PHPUnit_Framework_TestCase
             $deserializedObject = $this->deserialize($this->getContent('array_datetimes_object'), 'Jms\Serializer\Tests\Fixtures\DateTimeArraysObject');
             $deserializedObject = $this->deserialize($this->getContent('array_datetimes_object'), 'Jms\Serializer\Tests\Fixtures\DateTimeArraysObject');
 
 
             /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */
             /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */
-            foreach ($deserializedObject->getArrayWithDefaultDateTime() as $dateTime)
+            foreach ($deserializedObject->getArrayWithDefaultDateTime() as $dateTime) {
                 $dateTime->setTimezone(new \DateTimeZone('UTC'));
                 $dateTime->setTimezone(new \DateTimeZone('UTC'));
-            foreach ($deserializedObject->getArrayWithFormattedDateTime() as $dateTime)
+            }
+
+            foreach ($deserializedObject->getArrayWithFormattedDateTime() as $dateTime) {
                 $dateTime->setTimezone(new \DateTimeZone('UTC'));
                 $dateTime->setTimezone(new \DateTimeZone('UTC'));
+            }
 
 
             $this->assertEquals($object, $deserializedObject);
             $this->assertEquals($object, $deserializedObject);
         }
         }
@@ -298,15 +301,17 @@ abstract class BaseSerializationTest extends \PHPUnit_Framework_TestCase
         if ($this->hasDeserializer()) {
         if ($this->hasDeserializer()) {
 
 
             // skip XML deserialization
             // skip XML deserialization
-            if ($this->getFormat() === 'xml')
+            if ($this->getFormat() === 'xml') {
                 return;
                 return;
+            }
 
 
             /** @var DateTimeArraysObject $deserializedObject */
             /** @var DateTimeArraysObject $deserializedObject */
             $deserializedObject = $this->deserialize($this->getContent('array_named_datetimes_object'), 'Jms\Serializer\Tests\Fixtures\NamedDateTimeArraysObject');
             $deserializedObject = $this->deserialize($this->getContent('array_named_datetimes_object'), 'Jms\Serializer\Tests\Fixtures\NamedDateTimeArraysObject');
 
 
             /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */
             /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */
-            foreach ($deserializedObject->getNamedArrayWithFormattedDate() as $dateTime)
+            foreach ($deserializedObject->getNamedArrayWithFormattedDate() as $dateTime) {
                 $dateTime->setTimezone(new \DateTimeZone('UTC'));
                 $dateTime->setTimezone(new \DateTimeZone('UTC'));
+            }
 
 
             $this->assertEquals($object, $deserializedObject);
             $this->assertEquals($object, $deserializedObject);
         }
         }

+ 3 - 3
tests/JMS/Serializer/Tests/Serializer/JsonSerializationTest.php

@@ -49,10 +49,10 @@ class JsonSerializationTest extends BaseSerializationTest
             $outputs['array_floats'] = '[1.34,3,6.42]';
             $outputs['array_floats'] = '[1.34,3,6.42]';
             $outputs['array_objects'] = '[{"foo":"foo","moo":"bar","camel_case":"boo"},{"foo":"baz","moo":"boo","camel_case":"boo"}]';
             $outputs['array_objects'] = '[{"foo":"foo","moo":"bar","camel_case":"boo"},{"foo":"baz","moo":"boo","camel_case":"boo"}]';
             $outputs['array_mixed'] = '["foo",1,true,{"foo":"foo","moo":"bar","camel_case":"boo"},[1,3,true]]';
             $outputs['array_mixed'] = '["foo",1,true,{"foo":"foo","moo":"bar","camel_case":"boo"},[1,3,true]]';
-            $outputs['array_datetimes_object'] = '{"array_with_default_date_time":["2047-01-01T12:47:47+0000","2013-12-05T00:00:00+0000"],"array_with_formatted_date_time":["01.01.2047 12:47:47","05.12.2013 00:00:00"],"named_array_with_formatted_date":{"testdate1":"01.01.2047 12:47:47","testdate2":"05.12.2013 00:00:00"}}';
+            $outputs['array_datetimes_object'] = '{"array_with_default_date_time":["2047-01-01T12:47:47+0000","2013-12-05T00:00:00+0000"],"array_with_formatted_date_time":["01.01.2047 12:47:47","05.12.2013 00:00:00"]}';
             $outputs['array_named_datetimes_object'] = '{"named_array_with_formatted_date":{"testdate1":"01.01.2047 12:47:47","testdate2":"05.12.2013 00:00:00"}}';
             $outputs['array_named_datetimes_object'] = '{"named_array_with_formatted_date":{"testdate1":"01.01.2047 12:47:47","testdate2":"05.12.2013 00:00:00"}}';
-            $outputs['blog_post'] = '{"id":"what_a_nice_id","title":"This is a nice title.","created_at":"2011-07-30T00:00:00+0000","is_published":false,"comments":[{"author":{"full_name":"Foo Bar"},"text":"foo"}],"comments2":[{"author":{"full_name":"Foo Bar"},"text":"foo"}],"metadata":{"foo":"bar"},"author":{"full_name":"Foo Bar"}}';
-            $outputs['blog_post_unauthored'] = '{"id":"what_a_nice_id","title":"This is a nice title.","created_at":"2011-07-30T00:00:00+0000","is_published":false,"comments":[],"comments2":[],"metadata":{"foo":"bar"},"author":null}';
+            $outputs['blog_post'] = '{"id":"what_a_nice_id","title":"This is a nice title.","created_at":"2011-07-30T00:00:00+0000","is_published":false,"etag":"1edf9bf60a32d89afbb85b2be849e3ceed5f5b10","comments":[{"author":{"full_name":"Foo Bar"},"text":"foo"}],"comments2":[{"author":{"full_name":"Foo Bar"},"text":"foo"}],"metadata":{"foo":"bar"},"author":{"full_name":"Foo Bar"},"publisher":{"pub_name":"Bar Foo"}}';
+            $outputs['blog_post_unauthored'] = '{"id":"what_a_nice_id","title":"This is a nice title.","created_at":"2011-07-30T00:00:00+0000","is_published":false,"etag":"1edf9bf60a32d89afbb85b2be849e3ceed5f5b10","comments":[],"comments2":[],"metadata":{"foo":"bar"},"author":null,"publisher":null}';
             $outputs['price'] = '{"price":3}';
             $outputs['price'] = '{"price":3}';
             $outputs['currency_aware_price'] = '{"currency":"EUR","amount":2.34}';
             $outputs['currency_aware_price'] = '{"currency":"EUR","amount":2.34}';
             $outputs['order'] = '{"cost":{"price":12.34}}';
             $outputs['order'] = '{"cost":{"price":12.34}}';