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

php 8.1 compatibility fixes #149

Merged
merged 13 commits into from
Dec 12, 2022
Merged

php 8.1 compatibility fixes #149

merged 13 commits into from
Dec 12, 2022

Conversation

falkenhawk
Copy link
Member

@falkenhawk falkenhawk commented Nov 28, 2022

@falkenhawk falkenhawk changed the base branch from php81-compat-returntypewillchange to master November 28, 2022 17:23
@falkenhawk falkenhawk assigned falkenhawk and unassigned falkenhawk Dec 2, 2022
@falkenhawk
Copy link
Member Author

falkenhawk commented Dec 2, 2022

236 errors, 9 failures to go... 😵‍💫
(starting from 1141 errors and 33 failures after #147)

@falkenhawk falkenhawk force-pushed the php81-compat branch 4 times, most recently from 879582e to 403e4b2 Compare December 4, 2022 09:30
@falkenhawk falkenhawk changed the base branch from master to fix-zend-timesync-ntp December 4, 2022 09:31
@falkenhawk
Copy link
Member Author

only 6 errors left. all in zend-db

Base automatically changed from fix-zend-timesync-ntp to master December 5, 2022 21:38
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)

https://php.watch/versions/8.1/serializable-deprecated
when they are being serialized same as PHP <8.1

In PHP 8.1, the order of properties is the same as in the class definition, but properties from parent class
always go after properties from the current class.
From PHP upgrade notes: https://github.com/php/php-src/blob/578b67da49af51b2f796a48782e51ceb62860943/UPGRADING#L334-L341

Copied the `correlationId` property definition from `Zend_Amf_Value_Messaging_AsyncMessage` to parent `Zend_Amf_Value_Messaging_AbstractMessage`.
`correlationId` prop is expected to be at the beginning of serialized messages, otherwise it breaks Zend_Amf_ResponseTest cases for php 8.1+.
Method name was not set in constructor, but it was being read in tests (there is no property defined for it, but `__set` magic method is defined in the base class)
resulting in `substr(): Passing null to parameter #1 ($string) of type string is deprecated` and similar errors in various places
where null is not valid, string is expected
- substr(): Passing null to parameter #1 ($string) of type string is deprecated
- strtolower(): Passing null to parameter #1 ($string) of type string is deprecated
- strlen(): Passing null to parameter #1 ($string) of type string is deprecated
- trim(): Passing null to parameter #1 ($string) of type string is deprecated
- str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated
- strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated
- http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated
- current(): Calling current() on an object is deprecated
- preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated
- preg_match(): Passing null to parameter #4 ($flags) of type int is deprecated
- always construct Zend_Exception with string message, avoid null
- Implicit conversion from float-string "x.xyz" to int loses precision
- PDOStatement::fetch(): Passing null to parameter #2 ($cursorOrientation) of type int is deprecated
- ctype_space(): Argument of type null will be interpreted as string in the future
- file_get_contents(): Passing null to parameter #2 ($use_include_path) of type bool is deprecated
- imagefilledpolygon(): Using the $num_points parameter is deprecated
- Implicit conversion from float to int loses precision
- PDOStatement::bindParam(): Passing null to parameter #4 ($maxLength) of type int is deprecated
- preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated
- ctype_print(): Argument of type int will be interpreted as string in the future
- trim(): Passing null to parameter #1 ($string) of type string is deprecated
etc.
* [zend-date] fix calculating sunrise, sunset and twilight times

When php 8.1.0 deprecated date_sunset() and date_sunrise() functions,
switched to recommended date_sun_info() function is used instead (which is available in php since v5.1)
but that function yields slightly different results since zenith angles are internally fixed
and they are different to what zf used before. (see $horizonDeclination in Zend_Date::calcSun() - moved from Zend_Date::_checkLocation())

Yet ONLY NOW they are accurate! (calculations for civil / nautical / astronomical twilight were totally wrong before)

Still values returned by date_sun_info() are slightly different in php 8.0+, (but only for sunrise/sunset, not for twilight)
so yet another set of conditions have to be added to test suites.
for zf components. They are not needed since composer autoloader takes care of that. And they were breaking individual test runs e.g. `./vendor/bin/phpunit tests/Zend/Db/Adapter/MysqliTest.php`
@falkenhawk falkenhawk marked this pull request as ready for review December 7, 2022 05:35
@falkenhawk
Copy link
Member Author

@glensc would you like to review this PR?

Copy link
Contributor

@partikus partikus left a comment

Choose a reason for hiding this comment

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

@falkenhawk looks really good, few minor CRs added

replace conditionals with type-casting where they are not needed
@falkenhawk falkenhawk merged commit efbaac5 into master Dec 12, 2022
@falkenhawk falkenhawk deleted the php81-compat branch December 12, 2022 10:17
@falkenhawk falkenhawk mentioned this pull request Dec 12, 2022
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