@@ -151,7 +151,7 @@ public function __construct(array $config = [])
151151 'method ' => self ::getMethod (),
152152 'referrer ' => self ::getVar ('HTTP_REFERER ' ),
153153 'ip ' => self ::getVar ('REMOTE_ADDR ' ),
154- 'ajax ' => ' XMLHttpRequest ' === self ::getVar ('HTTP_X_REQUESTED_WITH ' ),
154+ 'ajax ' => self ::getVar ('HTTP_X_REQUESTED_WITH ' ) === ' XMLHttpRequest ' ,
155155 'scheme ' => self ::getScheme (),
156156 'user_agent ' => self ::getVar ('HTTP_USER_AGENT ' ),
157157 'type ' => self ::getVar ('CONTENT_TYPE ' ),
@@ -160,7 +160,7 @@ public function __construct(array $config = [])
160160 'data ' => new Collection ($ _POST ),
161161 'cookies ' => new Collection ($ _COOKIE ),
162162 'files ' => new Collection ($ _FILES ),
163- 'secure ' => ' https ' === self ::getScheme (),
163+ 'secure ' => self ::getScheme () === ' https ' ,
164164 'accept ' => self ::getVar ('HTTP_ACCEPT ' ),
165165 'proxy_ip ' => self ::getProxyIpAddress (),
166166 'host ' => self ::getVar ('HTTP_HOST ' ),
@@ -188,12 +188,12 @@ public function init(array $properties = []): self
188188 // This rewrites the url in case the public url and base directories match
189189 // (such as installing on a subdirectory in a web server)
190190 // @see testInitUrlSameAsBaseDirectory
191- if (' / ' !== $ this ->base && '' !== $ this ->base && 0 === strpos ($ this ->url , $ this ->base )) {
191+ if ($ this ->base !== ' / ' && $ this ->base !== '' && strpos ($ this ->url , $ this ->base ) === 0 ) {
192192 $ this ->url = substr ($ this ->url , \strlen ($ this ->base ));
193193 }
194194
195195 // Default url
196- if (empty ($ this ->url )) {
196+ if (empty ($ this ->url ) === true ) {
197197 $ this ->url = '/ ' ;
198198 } else {
199199 // Merge URL query parameters with $_GET
@@ -203,11 +203,11 @@ public function init(array $properties = []): self
203203 }
204204
205205 // Check for JSON input
206- if (0 === strpos ($ this ->type , 'application/json ' )) {
206+ if (strpos ($ this ->type , 'application/json ' ) === 0 ) {
207207 $ body = $ this ->getBody ();
208- if ('' !== $ body ) {
208+ if ($ body !== '' ) {
209209 $ data = json_decode ($ body , true );
210- if (is_array ($ data )) {
210+ if (is_array ($ data ) === true ) {
211211 $ this ->data ->setData ($ data );
212212 }
213213 }
@@ -225,13 +225,13 @@ public function getBody(): string
225225 {
226226 $ body = $ this ->body ;
227227
228- if ('' !== $ body ) {
228+ if ($ body !== '' ) {
229229 return $ body ;
230230 }
231231
232232 $ method = $ this ->method ?? self ::getMethod ();
233233
234- if (' POST ' === $ method || ' PUT ' === $ method || ' DELETE ' === $ method || ' PATCH ' === $ method ) {
234+ if ($ method === ' POST ' || $ method === ' PUT ' || $ method === ' DELETE ' || $ method === ' PATCH ' ) {
235235 $ body = file_get_contents ($ this ->stream_path );
236236 }
237237
@@ -247,9 +247,9 @@ public static function getMethod(): string
247247 {
248248 $ method = self ::getVar ('REQUEST_METHOD ' , 'GET ' );
249249
250- if (isset ($ _SERVER ['HTTP_X_HTTP_METHOD_OVERRIDE ' ])) {
250+ if (isset ($ _SERVER ['HTTP_X_HTTP_METHOD_OVERRIDE ' ]) === true ) {
251251 $ method = $ _SERVER ['HTTP_X_HTTP_METHOD_OVERRIDE ' ];
252- } elseif (isset ($ _REQUEST ['_method ' ])) {
252+ } elseif (isset ($ _REQUEST ['_method ' ]) === true ) {
253253 $ method = $ _REQUEST ['_method ' ];
254254 }
255255
@@ -275,9 +275,9 @@ public static function getProxyIpAddress(): string
275275 $ flags = \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE ;
276276
277277 foreach ($ forwarded as $ key ) {
278- if (\array_key_exists ($ key , $ _SERVER )) {
278+ if (\array_key_exists ($ key , $ _SERVER ) === true ) {
279279 sscanf ($ _SERVER [$ key ], '%[^,] ' , $ ip );
280- if (false !== filter_var ($ ip , \FILTER_VALIDATE_IP , $ flags )) {
280+ if (filter_var ($ ip , \FILTER_VALIDATE_IP , $ flags ) !== false ) {
281281 return $ ip ;
282282 }
283283 }
@@ -322,7 +322,7 @@ public static function getHeaders(): array
322322 {
323323 $ headers = [];
324324 foreach ($ _SERVER as $ key => $ value ) {
325- if (0 === strpos ($ key , 'HTTP_ ' )) {
325+ if (strpos ($ key , 'HTTP_ ' ) === 0 ) {
326326 // converts headers like HTTP_CUSTOM_HEADER to Custom-Header
327327 $ key = str_replace (' ' , '- ' , ucwords (str_replace ('_ ' , ' ' , strtolower (substr ($ key , 5 )))));
328328 $ headers [$ key ] = $ value ;
@@ -386,7 +386,7 @@ public static function parseQuery(string $url): array
386386 $ params = [];
387387
388388 $ args = parse_url ($ url );
389- if (isset ($ args ['query ' ])) {
389+ if (isset ($ args ['query ' ]) === true ) {
390390 parse_str ($ args ['query ' ], $ params );
391391 }
392392
@@ -401,13 +401,13 @@ public static function parseQuery(string $url): array
401401 public static function getScheme (): string
402402 {
403403 if (
404- (isset ($ _SERVER ['HTTPS ' ]) && ' on ' === strtolower ($ _SERVER ['HTTPS ' ]))
404+ (isset ($ _SERVER ['HTTPS ' ]) === true && strtolower ($ _SERVER ['HTTPS ' ]) === ' on ' )
405405 ||
406- (isset ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ]) && ' https ' === $ _SERVER [ ' HTTP_X_FORWARDED_PROTO ' ] )
406+ (isset ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ]) === true && $ _SERVER [ ' HTTP_X_FORWARDED_PROTO ' ] === ' https ' )
407407 ||
408- (isset ($ _SERVER ['HTTP_FRONT_END_HTTPS ' ]) && ' on ' === $ _SERVER [ ' HTTP_FRONT_END_HTTPS ' ] )
408+ (isset ($ _SERVER ['HTTP_FRONT_END_HTTPS ' ]) === true && $ _SERVER [ ' HTTP_FRONT_END_HTTPS ' ] === ' on ' )
409409 ||
410- (isset ($ _SERVER ['REQUEST_SCHEME ' ]) && ' https ' === $ _SERVER [ ' REQUEST_SCHEME ' ] )
410+ (isset ($ _SERVER ['REQUEST_SCHEME ' ]) === true && $ _SERVER [ ' REQUEST_SCHEME ' ] === ' https ' )
411411 ) {
412412 return 'https ' ;
413413 }
0 commit comments