Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA: use strict comparisons #404

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions library/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ protected static function set_defaults(&$url, &$headers, &$data, &$type, &$optio
$type = strtoupper($type);

if (!isset($options['data_format'])) {
if (in_array($type, array(self::HEAD, self::GET, self::DELETE))) {
if (in_array($type, array(self::HEAD, self::GET, self::DELETE), true)) {
$options['data_format'] = 'query';
}
else {
Expand Down Expand Up @@ -865,7 +865,7 @@ public static function decompress($data) {
public static function compatible_gzinflate($gzData) {
// Compressed data might contain a full zlib header, if so strip it for
// gzinflate()
if (substr($gzData, 0, 3) == "\x1f\x8b\x08") {
if (substr($gzData, 0, 3) === "\x1f\x8b\x08") {
$i = 10;
$flg = ord(substr($gzData, 3, 1));
if ($flg > 0) {
Expand Down Expand Up @@ -905,7 +905,7 @@ public static function compatible_gzinflate($gzData) {
// First 2 bytes should be divisible by 0x1F
list(, $first_two_bytes) = unpack('n', $gzData);

if (0x08 == $first_nibble && 0 == ($first_two_bytes % 0x1F)) {
if (0x08 === $first_nibble && 0 === ($first_two_bytes % 0x1F)) {
$huffman_encoded = true;
}

Expand All @@ -915,7 +915,7 @@ public static function compatible_gzinflate($gzData) {
}
}

if ("\x50\x4b\x03\x04" == substr($gzData, 0, 4)) {
if ("\x50\x4b\x03\x04" === substr($gzData, 0, 4)) {
// ZIP file format header
// Offset 6: 2 bytes, General-purpose field
// Offset 26: 2 bytes, filename length
Expand All @@ -927,7 +927,7 @@ public static function compatible_gzinflate($gzData) {
// If the file has been compressed on the fly, 0x08 bit is set of
// the general purpose field. We can use this to differentiate
// between a compressed document, and a ZIP file
$zip_compressed_on_the_fly = (0x08 == (0x08 & $general_purpose_flag));
$zip_compressed_on_the_fly = (0x08 === (0x08 & $general_purpose_flag));

if (!$zip_compressed_on_the_fly) {
// Don't attempt to decode a compressed zip file
Expand Down
4 changes: 2 additions & 2 deletions library/Requests/Proxy/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public function __construct($args = null) {
$this->proxy = $args;
}
elseif (is_array($args)) {
if (count($args) == 1) {
if (count($args) === 1) {
list($this->proxy) = $args;
}
elseif (count($args) == 3) {
elseif (count($args) === 3) {
list($this->proxy, $this->user, $this->pass) = $args;
$this->use_authentication = true;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Requests/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function __construct() {
*/
public function is_redirect() {
$code = $this->status_code;
return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400;
return in_array($code, array(300, 301, 302, 303, 307), true) || $code > 307 && $code < 400;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/Requests/Transport/fsockopen.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function request($url, $headers = array(), $data = array(), $options = ar
}

$timeout_sec = (int) floor($options['timeout']);
if ($timeout_sec == $options['timeout']) {
if ($timeout_sec === $options['timeout']) {
$timeout_msec = 0;
}
else {
Expand Down