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

Fix for php 8.1 compatibility #330

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

xtremevision
Copy link

Fixed array notation curly brackets

composer.json Outdated Show resolved Hide resolved
@@ -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...

@aik099
Copy link
Contributor

aik099 commented Jan 23, 2025

Please also remove // MM PHP 8 compatibility fix comments from the code. It's always possible to review the cause of these changes through GitHub instead of explaining them across the code base.

@xtremevision
Copy link
Author

Please also remove // MM PHP 8 compatibility fix comments from the code. It's always possible to review the cause of these changes through GitHub instead of explaining them across the code base.

Done.

@aik099
Copy link
Contributor

aik099 commented Jan 23, 2025

Looks perfect to me.

@xtremevision , Have you tested these changes in a production environment (e.g. in a project that runs on PHP 8.1+, where this library is used)?

@xtremevision
Copy link
Author

Tbh I can't remember. A lot of time has passed since I placed this PR. I can't remember if I used it and/or where. I'll check.

@@ -433,8 +433,8 @@ static public function decode($str, $for_qbxml = true)
'&quot;' => '"',
'&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);

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the last change. Please remove this trailing space.

@aik099
Copy link
Contributor

aik099 commented Jan 23, 2025

I hope that once this PR is merged. The library would be work on PHP 8.1+. For people using this library, that should be a big relief.

If possible, consider switching to the official QuickBooks API client for PHP: https://github.com/intuit/QuickBooks-V3-PHP-SDK .

@xtremevision
Copy link
Author

xtremevision commented Jan 23, 2025

Done. Removed trailing space.

@aik099
Copy link
Contributor

aik099 commented Jan 23, 2025

Done. Removed trailing space.

You've removed the wrong trailing space. There should be one empty file at the end of each file.

I was talking about the empty line above the return str_replace(array_keys($transform), array_values($transform), isset($str) ? $str : ''); code in the XML.php file, that had some tabs/space on it. The line should stay, but there shouldn't be anything space-alike in it.

@xtremevision
Copy link
Author

Sorry, try now.

@aik099
Copy link
Contributor

aik099 commented Jan 23, 2025

Great. Thank you @xtremevision .

@tvaughan73
Copy link
Contributor

I hope that once this PR is merged. The library would be work on PHP 8.1+. For people using this library, that should be a big relief.

If possible, consider switching to the official QuickBooks API client for PHP: https://github.com/intuit/QuickBooks-V3-PHP-SDK .

Many people probably would if this SDK supported QB Desktop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants