@@ -84,11 +84,11 @@ public function __construct($code, $duration, array $headers = array(), $body =
8484 $ this ->body = $ body ;
8585 $ this ->error = $ error ;
8686 $ this ->jsonData = null ;
87- if ($ error != null ) {
87+ if ($ error !== null ) {
8888 return ;
8989 }
9090
91- if ($ body == null ) {
91+ if ($ body === null ) {
9292 if ($ code >= 400 ) {
9393 $ this ->error = self ::$ statusTexts [$ code ];
9494 }
@@ -98,18 +98,16 @@ public function __construct($code, $duration, array $headers = array(), $body =
9898 try {
9999 $ jsonData = self ::bodyJson ($ body );
100100 if ($ code >=400 ) {
101- if ($ jsonData ['error ' ] != null ) {
101+ $ this ->error = $ body ;
102+ if ($ jsonData ['error ' ] !== null ) {
102103 $ this ->error = $ jsonData ['error ' ];
103- } else {
104- $ this ->error = $ body ;
105104 }
106105 }
107106 $ this ->jsonData = $ jsonData ;
108107 } catch (\InvalidArgumentException $ e ) {
108+ $ this ->error = $ body ;
109109 if ($ code >= 200 && $ code < 300 ) {
110110 $ this ->error = $ e ->getMessage ();
111- } else {
112- $ this ->error = $ body ;
113111 }
114112 }
115113 } elseif ($ code >=400 ) {
@@ -127,19 +125,19 @@ private static function bodyJson($body, array $config = array())
127125 {
128126 return \Qiniu \json_decode (
129127 (string ) $ body ,
130- isset ( $ config [ 'object ' ] ) ? !$ config ['object ' ] : true ,
128+ array_key_exists ( 'object ' , $ config ) ? !$ config ['object ' ] : true ,
131129 512 ,
132- isset ( $ config [ 'big_int_strings ' ] ) ? JSON_BIGINT_AS_STRING : 0
130+ array_key_exists ( 'big_int_strings ' , $ config ) ? JSON_BIGINT_AS_STRING : 0
133131 );
134132 }
135133
136134 public function xVia ()
137135 {
138136 $ via = $ this ->headers ['X-Via ' ];
139- if ($ via == null ) {
137+ if ($ via === null ) {
140138 $ via = $ this ->headers ['X-Px ' ];
141139 }
142- if ($ via == null ) {
140+ if ($ via === null ) {
143141 $ via = $ this ->headers ['Fw-Via ' ];
144142 }
145143 return $ via ;
@@ -157,20 +155,20 @@ public function xReqId()
157155
158156 public function ok ()
159157 {
160- return $ this ->statusCode >= 200 && $ this ->statusCode < 300 && $ this ->error == null ;
158+ return $ this ->statusCode >= 200 && $ this ->statusCode < 300 && $ this ->error === null ;
161159 }
162160
163161 public function needRetry ()
164162 {
165163 $ code = $ this ->statusCode ;
166- if ($ code < 0 || ($ code / 100 == 5 and $ code != 579 ) || $ code == 996 ) {
164+ if ($ code < 0 || ($ code / 100 === 5 and $ code !== 579 ) || $ code = == 996 ) {
167165 return true ;
168166 }
169167 }
170168
171169 private static function isJson ($ headers )
172170 {
173- return isset ( $ headers [ 'Content-Type ' ] ) &&
171+ return array_key_exists ( 'Content-Type ' , $ headers ) &&
174172 strpos ($ headers ['Content-Type ' ], 'application/json ' ) === 0 ;
175173 }
176174}
0 commit comments