Skip to content

php 8.5 compatibility - #225

Merged
falkenhawk merged 21 commits into
masterfrom
php85-compat
Apr 8, 2026
Merged

falkenhawk merged 21 commits into
masterfrom
php85-compat

Conversation

@falkenhawk

@falkenhawk falkenhawk commented Apr 3, 2026 •

Copy link
Copy Markdown
Member

PHP 8.5 compatibility fixes. All changes are backward-compatible with PHP 7.1+ (why 7.1+? see #218).

non-canonical casts and syntax

  • replace (boolean) → (bool), (integer) → (int), (double) → (float) across 51 files
  • [zend-soap] fix SoapClient::__doRequest() signature for new $uriParserClass parameter
  • [zend-translate] cast $originate to string when used as array key

#226 - guard deprecated functions, methods, and syntax

  • guard no-op xml_parser_free() and imagedestroy() with PHP_VERSION_ID < 80000
  • guard deprecated ReflectionProperty::setAccessible() on php 8.1+
  • [zend-pdf] replace SplObjectStorage::contains() → offsetExists(), attach() → offsetSet()
  • [zend-stdlib] add #[ReturnTypeWillChange] to SplPriorityQueue::__serialize()
  • [zend-db] use Pdo\Mysql::ATTR_USE_BUFFERED_QUERY on php 8.5+ (test-only)
  • replace semicolons with colons in case statements across 38 files

#227 - null as array offset / array_key_exists() key

  • fixes across 10 packages: zend-form, zend-rest, zend-timesync, zend-http, zend-navigation, zend-translate, zend-file-transfer, zend-filter, zend-db, zend-validate
  • [zend-test] fix mock in TestCaseTest to provide table name

#228 - remaining deprecations

  • [zend-codegenerator] replace RecursiveArrayIterator with simple recursive walk in DefaultValue::generate()
  • [zend-stdlib] add #[ReturnTypeWillChange] to SplPriorityQueue::__unserialize()
  • [zend-timesync] guard ord() against empty string from fread() in Ntp::_read()
  • guard xml_parser_free() in Zend_Log_Writer_StreamTest
  • try multiple NTP servers in testTimesync - pool.ntp.org unreachable from GitHub Actions

php 8.5 added a new $uriParserClass parameter to __doRequest().
Without it, child classes trigger a fatal error during class loading.
(boolean) -> (bool), (integer) -> (int), (double) -> (float)
applied with php-cs-fixer short_scalar_cast rule
xml_parser_free() and imagedestroy() are no-ops since php 8.0,
deprecated in php 8.5. Skip on php 8.0+ where they have no effect.
no-op since php 8.1 (all properties accessible via reflection),
deprecated in php 8.5.
SplObjectStorage::contains() -> offsetExists()
SplObjectStorage::attach() -> offsetSet()

both deprecated in php 8.5. Replacements available since php 5.1.
…ze()

php 8.5 expects return type array on __serialize().
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY deprecated in php 8.5 in favor
of the driver-specific Pdo\Mysql::ATTR_USE_BUFFERED_QUERY constant.
Test-only change.
case followed by semicolon is deprecated in php 8.5.
Applied with php-cs-fixer switch_case_semicolon_to_colon rule.
@falkenhawk
falkenhawk force-pushed the php85-compat branch 2 times, most recently from 8a92012 to 831f2ce Compare April 3, 2026 13:52
- [zend-translate] cast $originate to string when used as array key
  (null as array offset is deprecated in php 8.5)
- [zend-codegenerator] cast to array before passing to RecursiveArrayIterator
  (using object as backing array is deprecated in php 8.5)
…sion for php 8.5

The old code mutated iterator values via offsetSet during traversal,
replacing arrays with DefaultValue objects. When the iterator then
tried to descend into those replaced values, RecursiveArrayIterator
called new ArrayIterator($object) - deprecated in php 8.5. On older
PHP this silently yielded no children (protected properties aren't
iterable), so only the top-level array was ever processed by the
iterator; nested arrays were handled later by recursive generate()
calls. The new _prepareArrayValue() does the same thing explicitly.
pool.ntp.org is unreachable from GitHub Actions runners.
Try time.windows.com first (confirmed working on CI), fall back to
pool.ntp.org, only mark incomplete if both fail.
php 8.5: fix deprecation of null as array key
@falkenhawk
falkenhawk marked this pull request as ready for review April 7, 2026 16:45
@falkenhawk
falkenhawk requested a review from partikus April 7, 2026 16:45
Base automatically changed from php84-compat to master April 8, 2026 13:32
@falkenhawk
falkenhawk merged commit 03caeae into master Apr 8, 2026
10 checks passed
@falkenhawk
falkenhawk deleted the php85-compat branch April 8, 2026 13:33
@falkenhawk falkenhawk mentioned this pull request Nov 4, 2026
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.

1 participant