Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f95b1ac

Browse filesBrowse files
committed
[Ldap] [5.0] add type-hint to interface and implementation
1 parent a25848b commit f95b1ac
Copy full SHA for f95b1ac

File tree

10 files changed

+26
-48
lines changed
Filter options

10 files changed

+26
-48
lines changed

‎src/Symfony/Component/Ldap/Adapter/AdapterInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/AdapterInterface.php
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ public function getConnection();
2626
/**
2727
* Creates a new Query.
2828
*
29-
* @param string $dn
30-
* @param string $query
31-
* @param array $options
32-
*
3329
* @return QueryInterface
3430
*/
35-
public function createQuery($dn, $query, array $options = []);
31+
public function createQuery(string $dn, string $query, array $options = []);
3632

3733
/**
3834
* Fetches the entry manager instance.
@@ -44,11 +40,7 @@ public function getEntryManager();
4440
/**
4541
* Escape a string for use in an LDAP filter or DN.
4642
*
47-
* @param string $subject
48-
* @param string $ignore
49-
* @param int $flags
50-
*
5143
* @return string
5244
*/
53-
public function escape($subject, $ignore = '', $flags = 0);
45+
public function escape(string $subject, ?string $ignore = '', int $flags = 0);
5446
}

‎src/Symfony/Component/Ldap/Adapter/ConnectionInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ConnectionInterface.php
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ interface ConnectionInterface
2424
public function isBound();
2525

2626
/**
27-
* Binds the connection against a DN and password.
28-
*
29-
* @param string $dn The user's DN
30-
* @param string $password The associated password
27+
* Binds the connection against a user's DN and password.
3128
*/
32-
public function bind($dn = null, $password = null);
29+
public function bind(string $dn = null, string $password = null);
3330
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public function getEntryManager()
5959
/**
6060
* {@inheritdoc}
6161
*/
62-
public function createQuery($dn, $query, array $options = [])
62+
public function createQuery(string $dn, string $query, array $options = [])
6363
{
6464
return new Query($this->getConnection(), $dn, $query, $options);
6565
}
6666

6767
/**
6868
* {@inheritdoc}
6969
*/
70-
public function escape($subject, $ignore = '', $flags = 0)
70+
public function escape(string $subject, ?string $ignore = '', int $flags = 0)
7171
{
7272
$value = ldap_escape($subject, $ignore, $flags);
7373

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function isBound()
5151
/**
5252
* {@inheritdoc}
5353
*/
54-
public function bind($dn = null, $password = null)
54+
public function bind(string $dn = null, string $password = null)
5555
{
5656
if (!$this->connection) {
5757
$this->connect();
@@ -85,14 +85,14 @@ public function getResource()
8585
return $this->connection;
8686
}
8787

88-
public function setOption($name, $value)
88+
public function setOption(string $name, $value)
8989
{
9090
if (!@ldap_set_option($this->connection, ConnectionOptions::getOption($name), $value)) {
9191
throw new LdapException(sprintf('Could not set value "%s" for option "%s".', $value, $name));
9292
}
9393
}
9494

95-
public function getOption($name)
95+
public function getOption(string $name)
9696
{
9797
if (!@ldap_get_option($this->connection, ConnectionOptions::getOption($name), $ret)) {
9898
throw new LdapException(sprintf('Could not retrieve value for option "%s".', $name));

‎src/Symfony/Component/Ldap/Adapter/ExtLdap/ConnectionOptions.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ExtLdap/ConnectionOptions.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class ConnectionOptions
4545
const X_SASL_AUTHCID = 0x6102;
4646
const X_SASL_AUTHZID = 0x6103;
4747

48-
public static function getOptionName($name): string
48+
public static function getOptionName(string $name): string
4949
{
5050
return sprintf('%s::%s', self::class, strtoupper($name));
5151
}
@@ -58,7 +58,7 @@ public static function getOptionName($name): string
5858
*
5959
* @throws LdapException
6060
*/
61-
public static function getOption($name): int
61+
public static function getOption(string $name): int
6262
{
6363
// Convert
6464
$constantName = self::getOptionName($name);
@@ -70,7 +70,7 @@ public static function getOption($name): int
7070
return \constant($constantName);
7171
}
7272

73-
public static function isOption($name): bool
73+
public static function isOption(string $name): bool
7474
{
7575
return \defined(self::getOptionName($name));
7676
}

‎src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function removeAttributeValues(Entry $entry, string $attribute, array $va
101101
/**
102102
* {@inheritdoc}
103103
*/
104-
public function rename(Entry $entry, $newRdn, $removeOldRdn = true)
104+
public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true)
105105
{
106106
$con = $this->getConnectionResource();
107107

‎src/Symfony/Component/Ldap/Entry.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Entry.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getDn()
4242
*
4343
* @return bool
4444
*/
45-
public function hasAttribute($name)
45+
public function hasAttribute(string $name)
4646
{
4747
return isset($this->attributes[$name]);
4848
}
@@ -57,7 +57,7 @@ public function hasAttribute($name)
5757
*
5858
* @return array|null
5959
*/
60-
public function getAttribute($name)
60+
public function getAttribute(string $name)
6161
{
6262
return isset($this->attributes[$name]) ? $this->attributes[$name] : null;
6363
}
@@ -78,7 +78,7 @@ public function getAttributes()
7878
* @param string $name
7979
* @param array $value
8080
*/
81-
public function setAttribute($name, array $value)
81+
public function setAttribute(string $name, array $value)
8282
{
8383
$this->attributes[$name] = $value;
8484
}
@@ -88,7 +88,7 @@ public function setAttribute($name, array $value)
8888
*
8989
* @param string $name
9090
*/
91-
public function removeAttribute($name)
91+
public function removeAttribute(string $name)
9292
{
9393
unset($this->attributes[$name]);
9494
}

‎src/Symfony/Component/Ldap/Ldap.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Ldap.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function __construct(AdapterInterface $adapter)
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function bind($dn = null, $password = null)
38+
public function bind(string $dn = null, string $password = null)
3939
{
4040
$this->adapter->getConnection()->bind($dn, $password);
4141
}
4242

4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function query($dn, $query, array $options = []): ?QueryInterface
46+
public function query(string $dn, string $query, array $options = []): ?QueryInterface
4747
{
4848
return $this->adapter->createQuery($dn, $query, $options);
4949
}
@@ -59,7 +59,7 @@ public function getEntryManager(): ?EntryManagerInterface
5959
/**
6060
* {@inheritdoc}
6161
*/
62-
public function escape($subject, $ignore = '', $flags = 0): ?string
62+
public function escape(string $subject, ?string $ignore = '', int $flags = 0): ?string
6363
{
6464
return $this->adapter->escape($subject, $ignore, $flags);
6565
}
@@ -72,7 +72,7 @@ public function escape($subject, $ignore = '', $flags = 0): ?string
7272
*
7373
* @return static
7474
*/
75-
public static function create($adapter, array $config = []): self
75+
public static function create(string $adapter, array $config = []): self
7676
{
7777
if (!isset(self::$adapterMap[$adapter])) {
7878
throw new DriverNotFoundException(sprintf(

‎src/Symfony/Component/Ldap/LdapInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/LdapInterface.php
+3-14Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,16 @@ interface LdapInterface
2828
/**
2929
* Return a connection bound to the ldap.
3030
*
31-
* @param string $dn A LDAP dn
32-
* @param string $password A password
33-
*
3431
* @throws ConnectionException if dn / password could not be bound
3532
*/
36-
public function bind($dn = null, $password = null);
33+
public function bind(string $dn = null, string $password = null);
3734

3835
/**
3936
* Queries a ldap server for entries matching the given criteria.
4037
*
41-
* @param string $dn
42-
* @param string $query
43-
* @param array $options
44-
*
4538
* @return QueryInterface
4639
*/
47-
public function query($dn, $query, array $options = []);
40+
public function query(string $dn, string $query, array $options = []);
4841

4942
/**
5043
* @return EntryManagerInterface
@@ -54,11 +47,7 @@ public function getEntryManager();
5447
/**
5548
* Escape a string for use in an LDAP filter or DN.
5649
*
57-
* @param string $subject
58-
* @param string $ignore
59-
* @param int $flags
60-
*
6150
* @return string
6251
*/
63-
public function escape($subject, $ignore = '', $flags = 0);
52+
public function escape(string $subject, string $ignore = '', int $flags = 0);
6453
}

‎src/Symfony/Component/Ldap/Tests/LdapTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Tests/LdapTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public function testLdapEscape()
5252
$this->adapter
5353
->expects($this->once())
5454
->method('escape')
55-
->with('foo', 'bar', 'baz')
55+
->with('foo', 'bar', 0)
5656
;
57-
$this->ldap->escape('foo', 'bar', 'baz');
57+
$this->ldap->escape('foo', 'bar', 0);
5858
}
5959

6060
public function testLdapQuery()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.