Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Php Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-php-knowledge-patch-nevaberry-plugins)
---
name: php-knowledge-patch
description: PHP
version: "8.6.0"
license: MIT
metadata:
author: Nevaberry
---
# PHP Knowledge Patch
Use this skill when migrating PHP code, updating extension integrations,
investigating changed runtime behavior, or configuring PHP builds, CLI, and FPM.
It covers compatibility changes, deprecations, extension APIs, and configuration.
Use the topic references for complete guidance, version attribution, and library
or platform conditions; the quick reference below highlights common migration work.
## Topic index
| Reference | Topics |
| --- | --- |
| [Language and runtime](references/language-and-runtime.md) | Types, constants, cloning, reflection, lazy objects, containers, diagnostics, filtering, serialization |
| [Database, sessions, and persistence](references/database-sessions-and-persistence.md) | PDO parsing and fetching, MySQLi, PostgreSQL, SQLite, session settings and handlers |
| [Extensions, system APIs, and builds](references/extensions-system-and-builds.md) | Security upgrades, build dependencies, OPcache, INI, CLI, FPM, PCNTL, FFI, LDAP, dates, GMP, SNMP |
| [Networking, crypto, patterns, and I/O](references/networking-crypto-patterns-and-io.md) | cURL, OpenSSL, TLS, Sodium, PCRE, sockets, streams, CSV, URI, mail, archives, compression |
| [XML, SOAP, text, and media](references/xml-soap-text-and-media.md) | DOM, SimpleXML, XML, XSL, SOAP, Intl, MBString, GD, EXIF, image formats |
## Breaking changes and deprecations
### Build and deployment changes
PHP 8.5 builds in and loads OPcache. Remove `--enable-opcache` and
`--disable-opcache` from build scripts and the `zend_extension` line that loads
`opcache.so` or `php_opcache.dll`. Control caching with `opcache.enable` and
`opcache.enable_cli`.
PHP 8.5 removes the `-z` flag from CLI and CGI. Load external Zend extensions
with `zend_extension` in INI configuration.
PHP 8.5.9 fixes a BCMath out-of-bounds write (CVE-2026-17544,
GHSA-x692-q9x7-8c3f). See the system reference for the branch-specific security
upgrade targets.
### Language and runtime checks
In PHP 8.4, comparisons that encounter recursion throw a catchable `Error`.
`__clone()` can still reinitialize a `readonly` property by direct assignment,
but indirect modification, including binding a reference, is forbidden during cloning.
`PHP_DEBUG` and `PHP_ZTS` are booleans; update strict comparisons expecting integers.
In PHP 8.5, destructuring a non-array with `[]` or `list()` emits a warning;
a `null` right-hand side is exempt. Explicit and implicit casts to `int` warn
when a float or float-like string falls outside the integer range. Casting
`NAN` to another type also warns.
Emitting output inside a user output handler is deprecated in PHP 8.5.
Return the transformed text. The deprecation diagnostic bypasses that handler
and can still pass through the next outer handler.
Rename classes, functions, constants, and aliases named `let` or `is`, including
aliases created with `class_alias()`. The language reference also covers the
deprecated uses of `_`, `namespace`, and `readonly` as identifiers.
A `return` inside `finally` is deprecated. Keep cleanup in `finally` and return
from the enclosing function after the block. Returning a value from `__construct()`
or `__destruct()` and declaring a nullable return type on `__debugInfo()` are deprecated.
### Reflection and containers
In PHP 8.5, guard `ReflectionClass::getConstant()` for an absent constant with
`hasConstant()`, and `ReflectionProperty::getDefaultValue()` for a property without
a default with `hasDefaultValue()`; the unguarded missing-value calls are deprecated.
Using an object as backing storage for `ArrayObject` or `ArrayIterator` is
deprecated in PHP 8.5, and `ArrayObject` rejects enum cases.
Replace `SplObjectStorage::contains()`, `attach()`, and `detach()` with
`offsetExists()`, `offsetSet()`, and `offsetUnset()` respectively.
`spl_classes()` and `spl_object_hash()` are deprecated. Use
`(new ReflectionExtension('SPL'))->getClassNames()` for class names and
`spl_object_id($object)` for object identity. The language reference lists the
deprecated `ArrayIterator` methods.
### Database connections and fetching
In PHP 8.4, PostgreSQL DSN credentials take precedence over the corresponding
`PDO` constructor arguments. Inside dollar-quoted SQL strings, use a single `?`
for a literal question mark; the old `??` escape there is deprecated.
The `uri:` PDO DSN scheme is deprecated in PHP 8.5; pass the driver's DSN directly.
`PDO::FETCH_CLASS` treats string keys in constructor arguments as parameter names
and requires explicit references for by-reference parameters. Use named PDO fetch
constants because several flag values changed.
Calling `setFetchMode()` inside `fetch()`, `fetchObject()`, or `fetchAll()` throws
`Error`. `FETCH_PROPS_LATE` outside `FETCH_CLASS`, and `FETCH_INTO` with
`fetchAll()`, throw `ValueError`. PDO_SQLITE quoting of a string containing a NUL
byte raises an exception or warning according to the connection's error mode.
`mysqli_stmt_init()`, `mysqli::stmt_init()`, and constructing `mysqli_stmt` without
a query are deprecated. Prepare directly with `$mysqli->prepare($sql)`.
`mysqli_get_charset()` and `mysqli::get_charset()` are also deprecated.
### Session configuration and handlers
Changing `session.sid_length` or `session.sid_bits_per_character` is deprecated
in PHP 8.4. Prepare storage for 32-character hexadecimal IDs and remove overrides.
Calling `session_set_save_handler()` with more than two arguments is deprecated;
migrate individual callbacks to the two-argument handler form.
In PHP 8.5, `session_start()` throws `ValueError` if its options array is not a map
and `TypeError` if `read_and_close` has a value incompatible with `int`.
Session defaults enable strict mode and the HttpOnly cookie flag, with SameSite
set to Lax: `session.use_strict_mode=1`, `session.cookie_httponly=1`, and
`session.cookie_samesite=Lax`. Custom save handler objects must provide both
`create_sid()` and `validateId()` to avoid deprecation, including implementations
of `SessionHandlerInterface`.
### Text, patterns, and I/O
PHP 8.4.25 and 8.5.10 forbid `\C` in UTF-8 regex patterns such as `/\C/u`.
Use `.` for a Unicode character, with `s` if it should also match newlines.
Use byte mode when a pattern needs to consume individual bytes.
`SplFileObject::fgetcsv()`, `fputcsv()`, `setCsvControl()`, and `getCsvControl()`
are deprecated. Use standalone CSV functions with an open stream for reads and
writes. The I/O reference also covers escape defaults and `str_getcsv()` validation.
The mbregex API and passing objects to `mb_convert_variables()` are deprecated.
`strcoll()` and `SORT_LOCALE_STRING` are deprecated; use `Collator::compare()`,
`Collator::sort()`, `Collator::asort()`, or `Collator::sortWithSortKeys()` as appropriate.
`trim()`, `ltrim()`, and `rtrim()` strip form feed (`\f`) by default. Supply an
explicit character mask when those bytes need to be retained.
### XML and SOAP integration
In PHP 8.4, `xml_set_object()`, bare method-name strings, and empty-string handler
removal are deprecated. Register object methods as callables and pass `null` to
clear a handler. Cloning a `DOMXPath` throws `Error`.
In PHP 8.5, `SoapClient::__doRequest()` adds optional `?string $uriParserClass = null`.
Update subclass overrides to accept it. Pass `Uri\Rfc3986\Uri::class` or
`Uri\WhatWg\Url::class` to select the corresponding parser, or leave it `null`
to use `parse_url()`.
## Frequently used features and controls
### Constants, cloning, and lazy initialization
PHP 8.5 permits closures and first-class callables in constants, attribute arguments,
and property or parameter defaults:
```php
const DOUBLE = static function (int $n): int { return $n * 2; };
const LENGTH = strlen(...);
```
Pass a property map as the second argument to `clone()` to set values on the clone,
including readonly properties during cloning.
Use `ReflectionProperty::skipLazyInitialization()` or
`setRawValueWithoutLazyInitialization()` to exempt a property from triggering
initialization. `ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE` keeps
serialization from triggering initialization. `ReflectionClass::SKIP_DESTRUCTOR`
skips the destructor when resetting an object as a lazy ghost or proxy.
### CLI configuration and PostgreSQL fetching
Run `php --ini=diff` in PHP 8.5 to list settings whose effective values differ
from their built-in defaults. Set `opcache.file_cache_read_only` to `1` when
deploying with a prebuilt file cache that PHP should only read.
PHP 8.5 lets `Pdo\Pgsql` fetch without buffering the whole result set. Set
`PDO::ATTR_PREFETCH` to `0` on the connection or an individual statement.
### cURL callbacks and diagnostics
`curl_version()['feature_list']` maps feature names to booleans, including `false`
for known but unsupported features. The networking reference gives the libcurl
requirements for HTTP/3 and transfer diagnostic fields.
The callback passed to `CURLOPT_DEBUGFUNCTION` receives a `CurlHandle`, an integer
message type such as `CURLINFO_HEADER_OUT`, and the message string. Leave the
separate `CURLINFO_HEADER_OUT` option unset on handles that use this callback.
Register `CURLOPT_SEEKFUNCTION` to let cURL rewind a streamed body for redirects,
multi-pass authentication, or retries on reused connections. Return
`CURL_SEEKFUNC_OK`, `CURL_SEEKFUNC_FAIL`, or `CURL_SEEKFUNC_CANTSEEK`.
### URI handling and stream errors
The URI extension is always enabled and handles RFC 3986 URIs and WHATWG URLs.
Use `Uri\Rfc3986\Uri::getUriType()` for URI classification and
`Uri\WhatWg\Url::isSpecialScheme()` for WHATWG special schemes; both expose
`getHostType()`. `Uri\Rfc3986\UriBuilder` constructs RFC 3986 URIs.
Configure stream context options `error_mode`, `error_store`, and `error_handler`
to control stream errors. The API adds `StreamError`, `StreamException`, the enums
`StreamErrorMode`, `StreamErrorStore`, and `StreamErrorCode`, and the functions
`stream_last_errors()` and `stream_clear_errors()`.