@@ -654,8 +654,8 @@ You can add new encoders to a Serializer instance by using its second constructo
654654 use Symfony\Component\Serializer\Encoder\XmlEncoder;
655655 use Symfony\Component\Serializer\Encoder\JsonEncoder;
656656
657- $encoders = array( new XmlEncoder(), new JsonEncoder()) ;
658- $serializer = new Serializer(array() , $encoders);
657+ $encoders = [ new XmlEncoder(), new JsonEncoder()] ;
658+ $serializer = new Serializer([] , $encoders);
659659
660660Built-in Encoders
661661~~~~~~~~~~~~~~~~~
@@ -702,7 +702,7 @@ This encoder transforms arrays into XML and vice versa.
702702
703703For example, take an object normalized as following::
704704
705- array( 'foo' => array( 1, 2) , 'bar' => true) ;
705+ [ 'foo' => [ 1, 2] , 'bar' => true] ;
706706
707707The ``XmlEncoder `` will encode this object like that::
708708
@@ -716,7 +716,7 @@ The ``XmlEncoder`` will encode this object like that::
716716Be aware that this encoder will consider keys beginning with ``@ `` as attributes::
717717
718718 $encoder = new XmlEncoder();
719- $encoder->encode(array( 'foo' => array( '@bar' => 'value')) , 'xml');
719+ $encoder->encode([ 'foo' => [ '@bar' => 'value']] , 'xml');
720720 // will return:
721721 // <?xml version="1.0"?>
722722 // <response>
@@ -970,17 +970,17 @@ having unique identifiers::
970970 return '/foos/'.$foo->id;
971971 });
972972
973- $serializer = new Serializer(array( $normalizer) );
973+ $serializer = new Serializer([ $normalizer] );
974974
975- $result = $serializer->normalize($level1, null, array( ObjectNormalizer::ENABLE_MAX_DEPTH => true) );
975+ $result = $serializer->normalize($level1, null, [ ObjectNormalizer::ENABLE_MAX_DEPTH => true] );
976976 /*
977- $result = array(
977+ $result = [
978978 'id' => 1,
979- 'child' => array(
979+ 'child' => [
980980 'id' => 2,
981981 'child' => '/foos/3',
982- ) ,
983- ) ;
982+ ] ,
983+ ] ;
984984 */
985985
986986.. versionadded :: 4.1
@@ -1126,15 +1126,15 @@ context option::
11261126 }
11271127
11281128 $normalizer = new ObjectNormalizer($classMetadataFactory);
1129- $serializer = new Serializer(array( $normalizer) );
1129+ $serializer = new Serializer([ $normalizer] );
11301130
11311131 $data = $serializer->denormalize(
1132- array( 'foo' => 'Hello') ,
1132+ [ 'foo' => 'Hello'] ,
11331133 'MyObj',
1134- array( 'default_constructor_arguments' => array(
1135- 'MyObj' => array( 'foo' => '', 'bar' => '') ,
1136- )
1137- )) ;
1134+ [ 'default_constructor_arguments' => [
1135+ 'MyObj' => [ 'foo' => '', 'bar' => ''] ,
1136+ ]]
1137+ );
11381138 // $data = new MyObj('Hello', '');
11391139
11401140Recursive Denormalization and Type Safety
@@ -1240,8 +1240,8 @@ this is already set up and you only need to provide the configuration. Otherwise
12401240 $discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
12411241
12421242 $serializer = new Serializer(
1243- array( new ObjectNormalizer($classMetadataFactory, null, null, null, $discriminator)) ,
1244- array( 'json' => new JsonEncoder())
1243+ [ new ObjectNormalizer($classMetadataFactory, null, null, null, $discriminator)] ,
1244+ [ 'json' => new JsonEncoder()]
12451245 );
12461246
12471247Now configure your discriminator class mapping. Consider an application that
0 commit comments