PHP 8.1: LDAP: resources migrated to LDAP\Connection, LDAP\Result, and LDAP\ResultEntry objects
All resource types used in the LDAP extension are converted to use standard PHP classes in PHP 8.1.
Resource to Object Migration PHP is gradually phasing out all
resourcetypes with class objects, and this migration is part of the Resource to Object Migration plan.Extension Namespace Changes This migration follows the PHP's new proposed convention on using namespaces for bundled extensions.
All functions from the LDAP extension that accepted/returned resource objects prior to PHP 8.1 accept/return standard PHP class instances from PHP 8.1. There are three resource object types that are transitioned seamless to new class instances.
ldap linkresource type to\LDAP\Connectionldap resultresource type to\LDAP\Resultldap result entryresource type to\LDAP\ResultEntry
LDAP\Connection
From PHP 8.1, \LDAP\Connection class replace ldap link resource objects.
\LDAP\Connection class synopsis
namespace LDAP;
final class Connection {}
LDAP\Result
In PHP 8.1 and later, the new \LDAP\Result class instances are returned/accepted in lieu of ldap result resource objects.
\LDAP\Result class synopsis
namespace LDAP;
final class LDAPResult {}
LDAP\ResultEntry
\LDAP\ResultEntry class instances in PHP 8.1 replace ldap result entry resource objects.
\LDAP\ResultEntry class synopsis
namespace LDAP;
final class LDAPResultEntry {}
Backwards Compatibility Impact
This is an opaque transition of resource objects to class objects, which means all functions that previously accepted or returned resource objects are updated to accept the new class objects.
is_resource function no longer returns true for LDAP extension function return values, and may need to be updated to either account for the new objects, or to use !== false comparison.
For example:
- if (is_resource($ldap_connection)) {}
+ if ($ldap_connection !== false) {}