Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,5 @@ pip-log.txt

# Mac crap
.DS_Store

*.code-workspace
2 changes: 1 addition & 1 deletion QuickBooks/Cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static public function cast($type_or_action, $field, $value, $use_abbrevs = true
$dh = opendir(dirname(__FILE__) . '/QBXML/Schema/Object');
while (false !== ($file = readdir($dh)))
{
if ($file{0} == '.' or substr($file, -6, 6) != 'Rq.php')
if ($file[0] == '.' or substr($file, -6, 6) != 'Rq.php')
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion QuickBooks/Driver/Sql/Mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ protected function _escape($str)
$str = '';
}

return $this->_conn->real_escape_string($str);
return $this->_conn->real_escape_string($str ?? '');
Copy link
Contributor

@aik099 aik099 Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Please do this place and similar places in this PR, where ?? is used.

Usage of the null coalescing operator (??) on the PHP < 7.0 would result in a syntax error.

Please adjust the code to also work on PHP 5.x (according to composer.json this library supports PHP 5.x).

For this particular place maybe it's better to return NULL, when $str === null, but since there are no automated tests, this might break things :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used isset() ? : instead...

}

/**
Expand Down
2 changes: 1 addition & 1 deletion QuickBooks/MerchantService/CheckingAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct($routing, $account, $info, $type, $first_name, $last

$phone = trim(str_replace(array('(', ')', '+', ' ', '.', '-'), '', $phone));
if (strlen($phone) == 11 and
$phone{0} == '1')
$phone[0] == '1')
{
$phone = substr($phone, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion QuickBooks/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static public function mask($message)
// It's an XML tag
$contents = QuickBooks_Utilities::_extractTagContents(trim($key, '<> '), $message);

$masked = str_repeat('x', min(strlen($contents), 12)) . substr($contents, 12);
$masked = str_repeat('x', min(strlen($contents ?? ''), 12)) . substr($contents ?? '', 12);

$message = str_replace($key . $contents . '</' . trim($key, '<> ') . '>', $key . $masked . '</' . trim($key, '<> ') . '>', $message);
}
Expand Down
2 changes: 1 addition & 1 deletion QuickBooks/WebConnector/Handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public function authenticate($obj)
$customauth_wait_before_next_update = null;
$customauth_min_run_every_n_seconds = null;

if (is_array($override_dsn) or strlen($override_dsn)) // Custom autj
if (is_array($override_dsn) or strlen($override_dsn ?? '')) // Custom autj
{
//if ($auth->authenticate($obj->strUserName, $obj->strPassword, $customauth_company_file, $customauth_wait_before_next_update, $customauth_min_run_every_n_seconds) and

Expand Down
2 changes: 1 addition & 1 deletion QuickBooks/XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ static public function decode($str, $for_qbxml = true)
'&amp;' => '&', // Make sure that this is *the last* transformation to run, otherwise we end up double-un-encoding things
);

return str_replace(array_keys($transform), array_values($transform), $str);
return str_replace(array_keys($transform), array_values($transform), $str ?? '');
}
}

2 changes: 1 addition & 1 deletion QuickBooks/XML/Backend/Builtin.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ protected function _parseHelper($xml, &$Root, &$errnum, &$errmsg, $indent = 0)
$Node->addAttribute($key, $value);
}

if (false !== strpos($payload, '<'))
if (false !== strpos($payload ?? '', '<'))
{
// The tag contains child tags

Expand Down