Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into hotf…
Browse files Browse the repository at this point in the history
…ix/ZF2-270
  • Loading branch information
Show file tree
Hide file tree
Showing 35 changed files with 180 additions and 196 deletions.
42 changes: 19 additions & 23 deletions src/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,24 @@ class Attribute
/**
* Sets a LDAP attribute.
*
* @param array $data
* @param string $attribName
* @param scalar|array|Traversable $value
* @param boolean $append
* @param array $data
* @param string $attribName
* @param string|array|\Traversable $value
* @param boolean $append
* @return void
*/
public static function setAttribute(array &$data, $attribName, $value, $append = false)
{
$attribName = strtolower($attribName);
$valArray = array();
if (is_array($value) || ($value instanceof \Traversable)) {
foreach ($value as $v)
{
foreach ($value as $v) {
$v = self::valueToLdap($v);
if ($v !== null) {
$valArray[] = $v;
}
}
} elseif ($value !== null) {
} else if ($value !== null) {
$value = self::valueToLdap($value);
if ($value !== null) {
$valArray[] = $value;
Expand Down Expand Up @@ -90,8 +89,7 @@ public static function getAttribute(array $data, $attribName, $index = null)
return array();
}
$retArray = array();
foreach ($data[$attribName] as $v)
{
foreach ($data[$attribName] as $v) {
$retArray[] = self::valueFromLDAP($v);
}
return $retArray;
Expand Down Expand Up @@ -173,8 +171,7 @@ public static function removeFromAttribute(array &$data, $attribName, $value)
}

$valArray = array();
foreach ($value as $v)
{
foreach ($value as $v) {
$v = self::valueToLDAP($v);
if ($v !== null) {
$valArray[] = $v;
Expand Down Expand Up @@ -284,16 +281,16 @@ public static function convertFromLdapDateTimeValue($value)
/**
* Sets a LDAP password.
*
* @param array $data
* @param string $password
* @param string $hashType
* @param string|null $attribName
* @return null
* @param array $data
* @param string $password
* @param string $hashType Optional by default MD5
* @param string $attribName Optional
*/
public static function setPassword(
array &$data, $password, $hashType = self::PASSWORD_HASH_MD5,
$attribName = null
) {
)
{
if ($attribName === null) {
if ($hashType === self::PASSWORD_UNICODEPWD) {
$attribName = 'unicodePwd';
Expand Down Expand Up @@ -360,12 +357,11 @@ public static function createPassword($password, $hashType = self::PASSWORD_HASH
/**
* Sets a LDAP date/time attribute.
*
* @param array $data
* @param string $attribName
* @param integer|array|Traversable $value
* @param boolean $utc
* @param boolean $append
* @return null
* @param array $data
* @param string $attribName
* @param integer|array|\Traversable $value
* @param boolean $utc
* @param boolean $append
*/
public static function setDateTimeAttribute(
array &$data, $attribName, $value, $utc = false,
Expand Down
26 changes: 14 additions & 12 deletions src/Collection/DefaultIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

namespace Zend\Ldap\Collection;

use Zend\Ldap,
Zend\Ldap\Exception;
use Zend\Ldap;
use Zend\Ldap\Exception;

/**
* Zend\Ldap\Collection\DefaultIterator is the default collection iterator implementation
Expand All @@ -41,7 +41,7 @@ class DefaultIterator implements \Iterator, \Countable
/**
* LDAP Connection
*
* @var Ldap\Ldap
* @var \Zend\Ldap\Ldap
*/
protected $ldap = null;

Expand Down Expand Up @@ -76,10 +76,10 @@ class DefaultIterator implements \Iterator, \Countable
/**
* Constructor.
*
* @param Ldap\Ldap $ldap
* @param resource $resultId
* @return void
* @throws Exception\LdapException if no entries was found.
* @param \Zend\Ldap\Ldap $ldap
* @param resource $resultId
* @throws \Zend\Ldap\Exception\LdapException if no entries was found.
* @return DefaultIterator
*/
public function __construct(Ldap\Ldap $ldap, $resultId)
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public function close()
/**
* Gets the current LDAP connection.
*
* @return Ldap\Ldap
* @return \Zend\Ldap\Ldap
*/
public function getLDAP()
{
Expand Down Expand Up @@ -190,7 +190,7 @@ public function count()
* Implements Iterator
*
* @return array|null
* @throws Exception\LdapException
* @throws \Zend\Ldap\Exception\LdapException
*/
public function current()
{
Expand Down Expand Up @@ -239,8 +239,8 @@ public function current()
* Return the result item key
* Implements Iterator
*
* @throws \Zend\Ldap\Exception\LdapException
* @return string|null
* @throws Exception\LdapException if can't get Dn.
*/
public function key()
{
Expand All @@ -263,7 +263,8 @@ public function key()
* Move forward to next result item
* Implements Iterator
*
* @throws Exception\LdapException
* @throws \Zend\Ldap\Exception\LdapException
* @return
*/
public function next()
{
Expand All @@ -289,7 +290,8 @@ public function next()
* Rewind the Iterator to the first result item
* Implements Iterator
*
* @throws Exception\LdapException
*
* @throws \Zend\Ldap\Exception\LdapException
*/
public function rewind()
{
Expand Down
12 changes: 7 additions & 5 deletions src/Dn.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public function getRdnString($caseFold = null)
* Get the parent DN $levelUp levels up the tree
*
* @param int $levelUp
* @throws Exception\LdapException
* @return Dn
*/
public function getParentDn($levelUp = 1)
Expand Down Expand Up @@ -453,6 +454,7 @@ public static function setDefaultCaseFold($caseFold)
* Sanitizes the case fold
*
* @param string $caseFold
* @param string $default
* @return string
*/
protected static function sanitizeCaseFold($caseFold, $default)
Expand Down Expand Up @@ -693,7 +695,7 @@ public static function checkDn(
* This method supports the creation of multi-valued RDNs
* $part must contain an even number of elemets.
*
* @param array $attribute
* @param array $part
* @param string $caseFold
* @return string
* @throws Exception\LdapException
Expand All @@ -709,6 +711,7 @@ public static function implodeRdn(array $part, $caseFold = null)
$rdnParts[$keyId] = implode('=', array($key, $value));
}
ksort($rdnParts, SORT_STRING);

return implode('+', $rdnParts);
}

Expand Down Expand Up @@ -752,18 +755,17 @@ public static function isChildOf($childDn, $parentDn)
try {
$keys = array();
$vals = array();
if ($childDn instanceof DN) {
if ($childDn instanceof Dn) {
$cdn = $childDn->toArray(DN::ATTR_CASEFOLD_LOWER);
} else {
$cdn = self::explodeDn($childDn, $keys, $vals, DN::ATTR_CASEFOLD_LOWER);
}
if ($parentDn instanceof DN) {
if ($parentDn instanceof Dn) {
$pdn = $parentDn->toArray(DN::ATTR_CASEFOLD_LOWER);
} else {
$pdn = self::explodeDn($parentDn, $keys, $vals, DN::ATTR_CASEFOLD_LOWER);
}
}
catch (Exception\LdapException $e) {
} catch (Exception\LdapException $e) {
return false;
}

Expand Down
4 changes: 1 addition & 3 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@

namespace Zend\Ldap\Exception;

use Zend\Ldap\Exception;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class BadMethodCallException extends \BadMethodCallException implements Exception
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
}
4 changes: 2 additions & 2 deletions src/Exception.php → src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Ldap;
namespace Zend\Ldap\Exception;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception
interface ExceptionInterface
{
}
4 changes: 1 addition & 3 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@

namespace Zend\Ldap\Exception;

use Zend\Ldap\Exception;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidArgumentException extends \InvalidArgumentException implements Exception
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
11 changes: 5 additions & 6 deletions src/Exception/LdapException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@

namespace Zend\Ldap\Exception;

use Zend\Ldap\Ldap,
Zend\Ldap\Exception;
use Zend\Ldap\Ldap;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class LdapException extends \Exception implements Exception
class LdapException extends \Exception implements ExceptionInterface
{
const LDAP_SUCCESS = 0x00;
const LDAP_OPERATIONS_ERROR = 0x01;
Expand Down Expand Up @@ -114,9 +113,9 @@ class LdapException extends \Exception implements Exception
const LDAP_X_EXTENSION_NOT_LOADED = 0x7002;

/**
* @param Ldap $ldap A Zend\Ldap\Ldap object
* @param string $str An informtive exception message
* @param int $code An LDAP error code
* @param Ldap $ldap Zend\Ldap\Ldap object
* @param string $str Informative exception message
* @param int $code LDAP error code
*/
public function __construct(Ldap $ldap = null, $str = null, $code = 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Ldap\Filter;
namespace Zend\Ldap\Filter\Exception;

use Zend\Ldap;
use Zend\Ldap\Exception\ExceptionInterface as MainLdapException;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception extends Ldap\Exception
interface ExceptionInterface extends MainLdapException
{
}
4 changes: 1 addition & 3 deletions src/Filter/Exception/FilterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@

namespace Zend\Ldap\Filter\Exception;

use Zend\Ldap\Filter\Exception;

/**
* @category Zend
* @package Zend_Ldap
* @subpackage Filter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class FilterException extends \Exception implements Exception
class FilterException extends \Exception implements ExceptionInterface
{
}
1 change: 1 addition & 0 deletions src/Filter/LogicalFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ abstract class LogicalFilter extends AbstractFilter
*
* @param array $subfilters
* @param string $symbol
* @throws Exception\FilterException
*/
protected function __construct(array $subfilters, $symbol)
{
Expand Down
Loading

0 comments on commit 4e84fef

Please sign in to comment.