8000 bug #43179 [Ldap] Fix `resource` type checks & docblocks on PHP 8.1 (… · symfony/symfony@3c2c716 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c2c716

Browse files
committed
bug #43179 [Ldap] Fix resource type checks & docblocks on PHP 8.1 (chalasr)
This PR was merged into the 4.4 branch. Discussion ---------- [Ldap] Fix `resource` type checks & docblocks on PHP 8.1 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - From https://www.php.net/manual/en/migration81.incompatible.php: > Several resources have been migrated to objects. Return value checks using is_resource() should be replaced with checks for false. The LDAP functions now accept and return, respectively, LDAP\ResultEntry objects instead of ldap result entry resources. The LDAP functions now accept and return, respectively, LDAP\Connection objects instead of ldap link resources. The LDAP functions now accept and return, respectively, LDAP\Result objects instead of ldap result resources. The LDAP functions now accept and return, respectively, LDAP\ResultEntry objects instead of ldap result entry resources. See also php/php-src#6770 Commits ------- 2c0f7e0 [LDAP] Fix resource type checks & docblocks on PHP 8.1
2 parents 1636a26 + 2c0f7e0 commit 3c2c716

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Ldap\Adapter\ExtLdap;
1313

14+
use LDAP\Connection as LDAPConnection;
1415
use Symfony\Component\Ldap\Adapter\AbstractConnection;
1516
use Symfony\Component\Ldap\Exception\AlreadyExistsException;
1617
use Symfony\Component\Ldap\Exception\ConnectionException;
@@ -32,7 +33,7 @@ class Connection extends AbstractConnection
3233
/** @var bool */
3334
private $bound = false;
3435

35-
/** @var resource */
36+
/** @var resource|LDAPConnection */
3637
private $connection;
3738

3839
/**
@@ -89,9 +90,7 @@ public function bind($dn = null, $password = null)
8990
}
9091

9192
/**
92-
* Returns a link resource.
93-
*
94-
* @return resource
93+
* @return resource|LDAPConnection
9594
*
9695
* @internal
9796
*/
@@ -165,7 +164,7 @@ private function connect()
165164

166165
private function disconnect()
167166
{
168-
if ($this->connection && \is_resource($this->connection)) {
167+
if ($this->connection) {
169168
ldap_unbind($this->connection);
170169
}
171170

src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Ldap\Adapter\ExtLdap;
1313

14+
use LDAP\Connection as LDAPConnection;
15+
use LDAP\Result;
1416
use Symfony\Component\Ldap\Adapter\AbstractQuery;
1517
use Symfony\Component\Ldap\Exception\LdapException;
1618
use Symfony\Component\Ldap\Exception\NotBoundException;
@@ -27,7 +29,7 @@ class Query extends AbstractQuery
2729
/** @var Connection */
2830
protected $connection;
2931

30-
/** @var resource[] */
32+
/** @var resource[]|Result[] */
3133
private $results;
3234

3335
/** @var array */
@@ -156,7 +158,7 @@ public function execute()
156158
* Returns an LDAP search resource. If this query resulted in multiple searches, only the first
157159
* page will be returned.
158160
*
159-
* @return resource
161+
* @return resource|Result
160162
*
161163
* @internal
162164
*/
@@ -172,7 +174,7 @@ public function getResource($idx = 0)
172174
/**
173175
* Returns all LDAP search resources.
174176
*
175-
* @return resource[]
177+
* @return resource[]|Result[]
176178
*
177179
* @internal
178180
*/
@@ -215,7 +217,7 @@ private function resetPagination()
215217
/**
216218
* Sets LDAP pagination controls.
217219
*
218-
* @param resource $con
220+
* @param resource|LDAPConnection $con
219221
*/
220222
private function controlPagedResult($con, int $pageSize, bool $critical, string $cookie): bool
221223
{
@@ -239,8 +241,8 @@ private function controlPagedResult($con, int $pageSize, bool $critical, string
239241
/**
240242
* Retrieve LDAP pagination cookie.
241243
*
242-
* @param resource $con
243-
* @param resource $result
244+
* @param resource|LDAPConnection $con
245+
* @param resource|Result $result
244246
*/
245247
private function controlPagedResultResponse($con, $result, string $cookie = ''): string
246248
{
@@ -257,9 +259,9 @@ private function controlPagedResultResponse($con, $result, string $cookie = ''):
257259
/**
258260
* Calls actual LDAP search function with the prepared options and parameters.
259261
*
260-
* @param resource $con
262+
* @param resource|LDAPConnection $con
261263
*
262-
* @return resource
264+
* @return resource|Result
263265
*/
264266
private function callSearchFunction($con, string $func, int $sizeLimit)
265267
{

0 commit comments

Comments
 (0)
0