@@ -23,10 +23,10 @@ class XmlHandler extends MimeHandlerAdapter
2323 /**
2424 * @param array $conf sets configuration options
2525 */
26- public function __construct (array $ conf = array () )
26+ public function __construct (array $ conf = [] )
2727 {
28- $ this ->namespace = isset ( $ conf ['namespace ' ]) ? $ conf [ ' namespace ' ] : '' ;
29- $ this ->libxml_opts = isset ( $ conf ['libxml_opts ' ]) ? $ conf [ ' libxml_opts ' ] : 0 ;
28+ $ this ->namespace = $ conf ['namespace ' ] ?? '' ;
29+ $ this ->libxml_opts = $ conf ['libxml_opts ' ] ?? 0 ;
3030 }
3131
3232 /**
@@ -50,9 +50,9 @@ public function parse($body)
5050 * @return string
5151 * @throws \Exception if unable to serialize
5252 */
53- public function serialize ($ payload )
53+ public function serialize ($ payload ): string
5454 {
55- list ( $ _ , $ dom) = $ this ->_future_serializeAsXml ($ payload );
55+ [ $ _ , $ dom] = $ this ->_future_serializeAsXml ($ payload );
5656 return $ dom ->saveXml ();
5757 }
5858
@@ -61,7 +61,7 @@ public function serialize($payload)
6161 * @return string
6262 * @author Ted Zellers
6363 */
64- public function serialize_clean ($ payload )
64+ public function serialize_clean ($ payload ): string
6565 {
6666 $ xml = new \XMLWriter ;
6767 $ xml ->openMemory ();
@@ -75,7 +75,7 @@ public function serialize_clean($payload)
7575 * @param mixed $node to serialize
7676 * @author Ted Zellers
7777 */
78- public function serialize_node (&$ xmlw , $ node ){
78+ public function serialize_node (&$ xmlw , $ node ) {
7979 if (!is_array ($ node )){
8080 $ xmlw ->text ($ node );
8181 } else {
@@ -90,7 +90,7 @@ public function serialize_node(&$xmlw, $node){
9090 /**
9191 * @author Zack Douglas <zack@zackerydouglas.info>
9292 */
93- private function _future_serializeAsXml ($ value , $ node = null , $ dom = null )
93+ private function _future_serializeAsXml ($ value , $ node = null , $ dom = null ): array
9494 {
9595 if (!$ dom ) {
9696 $ dom = new \DOMDocument ;
@@ -107,21 +107,21 @@ private function _future_serializeAsXml($value, $node = null, $dom = null)
107107 $ objNode = $ dom ->createElement (get_class ($ value ));
108108 $ node ->appendChild ($ objNode );
109109 $ this ->_future_serializeObjectAsXml ($ value , $ objNode , $ dom );
110- } else if (is_array ($ value )) {
110+ } elseif (is_array ($ value )) {
111111 $ arrNode = $ dom ->createElement ('array ' );
112112 $ node ->appendChild ($ arrNode );
113113 $ this ->_future_serializeArrayAsXml ($ value , $ arrNode , $ dom );
114- } else if (is_bool ($ value )) {
114+ } elseif (is_bool ($ value )) {
115115 $ node ->appendChild ($ dom ->createTextNode ($ value ?'TRUE ' :'FALSE ' ));
116116 } else {
117117 $ node ->appendChild ($ dom ->createTextNode ($ value ));
118118 }
119- return array ( $ node , $ dom) ;
119+ return [ $ node , $ dom] ;
120120 }
121121 /**
122122 * @author Zack Douglas <zack@zackerydouglas.info>
123123 */
124- private function _future_serializeArrayAsXml ($ value , &$ parent , &$ dom )
124+ private function _future_serializeArrayAsXml ($ value , &$ parent , &$ dom ): array
125125 {
126126 foreach ($ value as $ k => &$ v ) {
127127 $ n = $ k ;
@@ -132,12 +132,12 @@ private function _future_serializeArrayAsXml($value, &$parent, &$dom)
132132 $ parent ->appendChild ($ el );
133133 $ this ->_future_serializeAsXml ($ v , $ el , $ dom );
134134 }
135- return array ( $ parent , $ dom) ;
135+ return [ $ parent , $ dom] ;
136136 }
137137 /**
138138 * @author Zack Douglas <zack@zackerydouglas.info>
139139 */
140- private function _future_serializeObjectAsXml ($ value , &$ parent , &$ dom )
140+ private function _future_serializeObjectAsXml ($ value , &$ parent , &$ dom ): array
141141 {
142142 $ refl = new \ReflectionObject ($ value );
143143 foreach ($ refl ->getProperties () as $ pr ) {
@@ -147,6 +147,6 @@ private function _future_serializeObjectAsXml($value, &$parent, &$dom)
147147 $ this ->_future_serializeAsXml ($ pr ->getValue ($ value ), $ el , $ dom );
148148 }
149149 }
150- return array ( $ parent , $ dom) ;
150+ return [ $ parent , $ dom] ;
151151 }
152152}
0 commit comments