From 2c0f7e04e08a6bbb550992f7f964c17ed68c8a65 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sat, 25 Sep 2021 20:09:43 +0200 Subject: [PATCH] [LDAP] Fix resource type checks & docblocks on PHP 8.1 --- .../Ldap/Adapter/ExtLdap/Connection.php | 9 ++++----- .../Component/Ldap/Adapter/ExtLdap/Query.php | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php index 2e400d29c9283..49e465d3f791c 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Ldap\Adapter\ExtLdap; +use LDAP\Connection as LDAPConnection; use Symfony\Component\Ldap\Adapter\AbstractConnection; use Symfony\Component\Ldap\Exception\AlreadyExistsException; use Symfony\Component\Ldap\Exception\ConnectionException; @@ -32,7 +33,7 @@ class Connection extends AbstractConnection /** @var bool */ private $bound = false; - /** @var resource */ + /** @var resource|LDAPConnection */ private $connection; /** @@ -89,9 +90,7 @@ public function bind($dn = null, $password = null) } /** - * Returns a link resource. - * - * @return resource + * @return resource|LDAPConnection * * @internal */ @@ -165,7 +164,7 @@ private function connect() private function disconnect() { - if ($this->connection && \is_resource($this->connection)) { + if ($this->connection) { ldap_unbind($this->connection); } diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index 4abcff763aaac..3fcf9bee16018 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Ldap\Adapter\ExtLdap; +use LDAP\Connection as LDAPConnection; +use LDAP\Result; use Symfony\Component\Ldap\Adapter\AbstractQuery; use Symfony\Component\Ldap\Exception\LdapException; use Symfony\Component\Ldap\Exception\NotBoundException; @@ -27,7 +29,7 @@ class Query extends AbstractQuery /** @var Connection */ protected $connection; - /** @var resource[] */ + /** @var resource[]|Result[] */ private $results; /** @var array */ @@ -156,7 +158,7 @@ public function execute() * Returns an LDAP search resource. If this query resulted in multiple searches, only the first * page will be returned. * - * @return resource + * @return resource|Result * * @internal */ @@ -172,7 +174,7 @@ public function getResource($idx = 0) /** * Returns all LDAP search resources. * - * @return resource[] + * @return resource[]|Result[] * * @internal */ @@ -215,7 +217,7 @@ private function resetPagination() /** * Sets LDAP pagination controls. * - * @param resource $con + * @param resource|LDAPConnection $con */ private function controlPagedResult($con, int $pageSize, bool $critical, string $cookie): bool { @@ -239,8 +241,8 @@ private function controlPagedResult($con, int $pageSize, bool $critical, string /** * Retrieve LDAP pagination cookie. * - * @param resource $con - * @param resource $result + * @param resource|LDAPConnection $con + * @param resource|Result $result */ private function controlPagedResultResponse($con, $result, string $cookie = ''): string { @@ -257,9 +259,9 @@ private function controlPagedResultResponse($con, $result, string $cookie = ''): /** * Calls actual LDAP search function with the prepared options and parameters. * - * @param resource $con + * @param resource|LDAPConnection $con * - * @return resource + * @return resource|Result */ private function callSearchFunction($con, string $func, int $sizeLimit) {