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

[Ldap] [5.0] add type-hint to interface and implementation #32253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions 12 src/Symfony/Component/Ldap/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ public function getConnection();
/**
* Creates a new Query.
*
* @param string $dn
* @param string $query
* @param array $options
*
* @return QueryInterface
*/
public function createQuery($dn, $query, array $options = []);
public function createQuery(string $dn, string $query, array $options = []);
Simperfit marked this conversation as resolved.
Show resolved Hide resolved

/**
* Fetches the entry manager instance.
Expand All @@ -44,11 +40,7 @@ public function getEntryManager();
/**
* Escape a string for use in an LDAP filter or DN.
*
* @param string $subject
* @param string $ignore
* @param int $flags
*
* @return string
*/
public function escape($subject, $ignore = '', $flags = 0);
public function escape(string $subject, string $ignore = '', int $flags = 0);
}
7 changes: 2 additions & 5 deletions 7 src/Symfony/Component/Ldap/Adapter/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ interface ConnectionInterface
public function isBound();

/**
* Binds the connection against a DN and password.
*
* @param string $dn The user's DN
* @param string $password The associated password
* Binds the connection against a user's DN and password.
*/
public function bind($dn = null, $password = null);
public function bind(string $dn = null, string $password = null);
}
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public function getEntryManager()
/**
* {@inheritdoc}
*/
public function createQuery($dn, $query, array $options = [])
public function createQuery(string $dn, string $query, array $options = [])
{
return new Query($this->getConnection(), $dn, $query, $options);
}

/**
* {@inheritdoc}
*/
public function escape($subject, $ignore = '', $flags = 0)
public function escape(string $subject, string $ignore = '', int $flags = 0)
{
$value = ldap_escape($subject, $ignore, $flags);

Expand Down
6 changes: 3 additions & 3 deletions 6 src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function isBound()
/**
* {@inheritdoc}
*/
public function bind($dn = null, $password = null)
public function bind(string $dn = null, string $password = null)
{
if (!$this->connection) {
$this->connect();
Expand Down Expand Up @@ -85,14 +85,14 @@ public function getResource()
return $this->connection;
}

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

public function getOption($name)
public function getOption(string $name)
{
if (!@ldap_get_option($this->connection, ConnectionOptions::getOption($name), $ret)) {
throw new LdapException(sprintf('Could not retrieve value for option "%s".', $name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class ConnectionOptions
const X_SASL_AUTHCID = 0x6102;
const X_SASL_AUTHZID = 0x6103;

public static function getOptionName($name): string
public static function getOptionName(string $name): string
{
return sprintf('%s::%s', self::class, strtoupper($name));
}
Expand All @@ -58,7 +58,7 @@ public static function getOptionName($name): string
*
* @throws LdapException
*/
public static function getOption($name): int
public static function getOption(string $name): int
{
// Convert
$constantName = self::getOptionName($name);
Expand All @@ -70,7 +70,7 @@ public static function getOption($name): int
return \constant($constantName);
}

public static function isOption($name): bool
public static function isOption(string $name): bool
{
return \defined(self::getOptionName($name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function removeAttributeValues(Entry $entry, string $attribute, array $va
/**
* {@inheritdoc}
*/
public function rename(Entry $entry, $newRdn, $removeOldRdn = true)
public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true)
{
$con = $this->getConnectionResource();

Expand Down
8 changes: 4 additions & 4 deletions 8 src/Symfony/Component/Ldap/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getDn()
*
* @return bool
*/
public function hasAttribute($name)
public function hasAttribute(string $name)
{
return isset($this->attributes[$name]);
}
Expand All @@ -57,7 +57,7 @@ public function hasAttribute($name)
*
* @return array|null
*/
public function getAttribute($name)
public function getAttribute(string $name)
{
return isset($this->attributes[$name]) ? $this->attributes[$name] : null;
}
Expand All @@ -78,7 +78,7 @@ public function getAttributes()
* @param string $name
* @param array $value
*/
public function setAttribute($name, array $value)
public function setAttribute(string $name, array $value)
{
$this->attributes[$name] = $value;
}
Expand All @@ -88,7 +88,7 @@ public function setAttribute($name, array $value)
*
* @param string $name
*/
public function removeAttribute($name)
public function removeAttribute(string $name)
{
unset($this->attributes[$name]);
}
Expand Down
8 changes: 4 additions & 4 deletions 8 src/Symfony/Component/Ldap/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public function __construct(AdapterInterface $adapter)
/**
* {@inheritdoc}
*/
public function bind($dn = null, $password = null)
public function bind(string $dn = null, string $password = null)
{
$this->adapter->getConnection()->bind($dn, $password);
}

/**
* {@inheritdoc}
*/
public function query($dn, $query, array $options = []): ?QueryInterface
public function query(string $dn, string $query, array $options = []): ?QueryInterface
{
return $this->adapter->createQuery($dn, $query, $options);
}
Expand All @@ -59,7 +59,7 @@ public function getEntryManager(): ?EntryManagerInterface
/**
* {@inheritdoc}
*/
public function escape($subject, $ignore = '', $flags = 0): ?string
public function escape(string $subject, string $ignore = '', int $flags = 0): ?string
{
return $this->adapter->escape($subject, $ignore, $flags);
}
Expand All @@ -72,7 +72,7 @@ public function escape($subject, $ignore = '', $flags = 0): ?string
*
* @return static
*/
public static function create($adapter, array $config = []): self
public static function create(string $adapter, array $config = []): self
{
if (!isset(self::$adapterMap[$adapter])) {
throw new DriverNotFoundException(sprintf(
Expand Down
17 changes: 3 additions & 14 deletions 17 src/Symfony/Component/Ldap/LdapInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,16 @@ interface LdapInterface
/**
* Return a connection bound to the ldap.
*
* @param string $dn A LDAP dn
* @param string $password A password
*
* @throws ConnectionException if dn / password could not be bound
*/
public function bind($dn = null, $password = null);
public function bind(string $dn = null, string $password = null);

/**
* Queries a ldap server for entries matching the given criteria.
*
* @param string $dn
* @param string $query
* @param array $options
*
* @return QueryInterface
*/
public function query($dn, $query, array $options = []);
public function query(string $dn, string $query, array $options = []);

/**
* @return EntryManagerInterface
Expand All @@ -54,11 +47,7 @@ public function getEntryManager();
/**
* Escape a string for use in an LDAP filter or DN.
*
* @param string $subject
* @param string $ignore
* @param int $flags
*
* @return string
*/
public function escape($subject, $ignore = '', $flags = 0);
public function escape(string $subject, string $ignore = '', int $flags = 0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testLdapEscape()
{
$ldap = new Adapter();

$this->assertEquals('\20foo\3dbar\0d(baz)*\20', $ldap->escape(" foo=bar\r(baz)* ", null, LdapInterface::ESCAPE_DN));
$this->assertEquals('\20foo\3dbar\0d(baz)*\20', $ldap->escape(" foo=bar\r(baz)* ", '', LdapInterface::ESCAPE_DN));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Ldap/Tests/LdapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function testLdapEscape()
$this->adapter
->expects($this->once())
->method('escape')
->with('foo', 'bar', 'baz')
->with('foo', 'bar', 0)
;
$this->ldap->escape('foo', 'bar', 'baz');
$this->ldap->escape('foo', 'bar', 0);
}

public function testLdapQuery()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.