diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index 519357ad4c6a5..63c55330b5a3e 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -24,9 +24,6 @@ class Query extends AbstractQuery // As of PHP 7.2, we can use LDAP_CONTROL_PAGEDRESULTS instead of this public const PAGINATION_OID = '1.2.840.113556.1.4.319'; - /** @var Connection */ - protected $connection; - /** @var resource[] */ private $results; @@ -156,17 +153,13 @@ 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|null * * @internal */ public function getResource(int $idx = 0) { - if (null === $this->results || $idx >= \count($this->results)) { - return null; - } - - return $this->results[$idx]; + return $this->results[$idx] ?? null; } /** @@ -259,9 +252,9 @@ private function controlPagedResultResponse($con, $result, string $cookie = ''): * * @param resource $con * - * @return resource + * @return resource|false */ - private function callSearchFunction($con, string $func, int $sizeLimit) + private function callSearchFunction($con, callable $func, int $sizeLimit) { if (\PHP_VERSION_ID < 70300) { return @$func($con, $this->dn, $this->query, $this->options['filter'], $this->options['attrsOnly'], $sizeLimit, $this->options['timeout'], $this->options['deref']); diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php index 4ef536efc689c..cb57c1d6296ea 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php @@ -19,7 +19,7 @@ class UpdateOperation private $values; private $attribute; - private $validOperationTypes = [ + private const VALID_OPERATION_TYPES = [ \LDAP_MODIFY_BATCH_ADD, \LDAP_MODIFY_BATCH_REMOVE, \LDAP_MODIFY_BATCH_REMOVE_ALL, @@ -34,7 +34,7 @@ class UpdateOperation */ public function __construct(int $operationType, string $attribute, ?array $values) { - if (!\in_array($operationType, $this->validOperationTypes, true)) { + if (!\in_array($operationType, self::VALID_OPERATION_TYPES, true)) { throw new UpdateOperationException(sprintf('"%s" is not a valid modification type.', $operationType)); } if (\LDAP_MODIFY_BATCH_REMOVE_ALL === $operationType && null !== $values) { diff --git a/src/Symfony/Component/Ldap/Entry.php b/src/Symfony/Component/Ldap/Entry.php index 71b675aa7006c..51477a5a51a01 100644 --- a/src/Symfony/Component/Ldap/Entry.php +++ b/src/Symfony/Component/Ldap/Entry.php @@ -18,14 +18,23 @@ class Entry { private $dn; - private $attributes; - private $lowerMap; + /** + * @var array + */ + private $attributes = []; + + /** + * @var array + */ + private $lowerMap = []; + + /** + * @param array $attributes + */ public function __construct(string $dn, array $attributes = []) { $this->dn = $dn; - $this->attributes = []; - $this->lowerMap = []; foreach ($attributes as $key => $attribute) { $this->setAttribute($key, $attribute);