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

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 73 changed files with 308 additions and 476 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -28,8 +28,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.4-dev",
"dev-develop": "2.5-dev"
"dev-master": "2.2-dev",
"dev-develop": "2.3-dev"
}
},
"autoload-dev": {
Expand Down
28 changes: 12 additions & 16 deletions src/Attribute.php
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Ldap
*/

namespace Zend\Ldap;
Expand All @@ -14,9 +13,6 @@

/**
* Zend\Ldap\Attribute is a collection of LDAP attribute related functions.
*
* @category Zend
* @package Zend_Ldap
*/
class Attribute
{
Expand All @@ -32,7 +28,7 @@ class Attribute
* @param array $data
* @param string $attribName
* @param string|array|\Traversable $value
* @param boolean $append
* @param bool $append
* @return void
*/
public static function setAttribute(array &$data, $attribName, $value, $append = false)
Expand Down Expand Up @@ -68,7 +64,7 @@ public static function setAttribute(array &$data, $attribName, $value, $append =
*
* @param array $data
* @param string $attribName
* @param integer $index
* @param int $index
* @return array|mixed
*/
public static function getAttribute(array $data, $attribName, $index = null)
Expand Down Expand Up @@ -102,7 +98,7 @@ public static function getAttribute(array $data, $attribName, $index = null)
* @param array $data
* @param string $attribName
* @param mixed|array $value
* @return boolean
* @return bool
*/
public static function attributeHasValue(array &$data, $attribName, $value)
{
Expand Down Expand Up @@ -287,9 +283,9 @@ public static function createPassword($password, $hashType = self::PASSWORD_HASH
*
* @param array $data
* @param string $attribName
* @param integer|array|\Traversable $value
* @param boolean $utc
* @param boolean $append
* @param int|array|\Traversable $value
* @param bool $utc
* @param bool $append
*/
public static function setDateTimeAttribute(
array &$data, $attribName, $value, $utc = false,
Expand All @@ -314,8 +310,8 @@ public static function setDateTimeAttribute(
}

/**
* @param integer $value
* @param boolean $utc
* @param int $value
* @param bool $utc
* @return string|null
*/
private static function valueToLdapDateTime($value, $utc)
Expand All @@ -332,8 +328,8 @@ private static function valueToLdapDateTime($value, $utc)
*
* @param array $data
* @param string $attribName
* @param integer $index
* @return array|integer
* @param int $index
* @return array|int
*/
public static function getDateTimeAttribute(array $data, $attribName, $index = null)
{
Expand All @@ -357,7 +353,7 @@ public static function getDateTimeAttribute(array $data, $attribName, $index = n

/**
* @param string|DateTime $value
* @return integer|null
* @return int|null
*/
private static function valueFromLdapDateTime($value)
{
Expand Down
12 changes: 4 additions & 8 deletions src/Collection.php
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Ldap
*/

namespace Zend\Ldap;

/**
* Zend\Ldap\Collection wraps a list of LDAP entries.
*
* @category Zend
* @package Zend_Ldap
*/
class Collection implements \Iterator, \Countable
{
Expand All @@ -28,7 +24,7 @@ class Collection implements \Iterator, \Countable
/**
* Current item number
*
* @var integer
* @var int
*/
protected $current = -1;

Expand Down Expand Up @@ -57,7 +53,7 @@ public function __destruct()
/**
* Closes the current result set
*
* @return boolean
* @return bool
*/
public function close()
{
Expand Down Expand Up @@ -211,7 +207,7 @@ public function rewind()
* after calls to rewind() or next()
* Implements Iterator
*
* @return boolean
* @return bool
*/
public function valid()
{
Expand Down
22 changes: 9 additions & 13 deletions src/Collection/DefaultIterator.php
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Ldap
*/

namespace Zend\Ldap\Collection;
Expand All @@ -17,9 +16,6 @@
/**
* Zend\Ldap\Collection\DefaultIterator is the default collection iterator implementation
* using ext/ldap
*
* @category Zend
* @package Zend_Ldap
*/
class DefaultIterator implements \Iterator, \Countable
{
Expand Down Expand Up @@ -51,7 +47,7 @@ class DefaultIterator implements \Iterator, \Countable
/**
* Number of items in query result
*
* @var integer
* @var int
*/
protected $itemCount = -1;

Expand Down Expand Up @@ -128,7 +124,7 @@ public function getLDAP()
* or a valid callback accepting the attribute's name as it's only
* argument and returning the new attribute's name.
*
* @param integer|callable $attributeNameTreatment
* @param int|callable $attributeNameTreatment
* @return DefaultIterator Provides a fluent interface
*/
public function setAttributeNameTreatment($attributeNameTreatment)
Expand Down Expand Up @@ -163,7 +159,7 @@ public function setAttributeNameTreatment($attributeNameTreatment)
/**
* Returns the currently set attribute name treatment
*
* @return integer|callable
* @return int|callable
*/
public function getAttributeNameTreatment()
{
Expand Down Expand Up @@ -197,14 +193,14 @@ public function current()
return null;
}

$entry = array('dn' => $this->key());
$ber_identifier = null;
$entry = array('dn' => $this->key());
$berIdentifier = null;

$resource = $this->ldap->getResource();
ErrorHandler::start();
$name = ldap_first_attribute(
$resource, $this->current,
$ber_identifier
$berIdentifier
);
ErrorHandler::stop();

Expand Down Expand Up @@ -240,7 +236,7 @@ public function current()
ErrorHandler::start();
$name = ldap_next_attribute(
$resource, $this->current,
$ber_identifier
$berIdentifier
);
ErrorHandler::stop();
}
Expand Down Expand Up @@ -332,7 +328,7 @@ public function rewind()
* after calls to rewind() or next()
* Implements Iterator
*
* @return boolean
* @return bool
*/
public function valid()
{
Expand Down
24 changes: 11 additions & 13 deletions src/Converter/Converter.php
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Ldap
*/

namespace Zend\Ldap\Converter;
Expand All @@ -16,9 +15,6 @@

/**
* Zend\Ldap\Converter is a collection of useful LDAP related conversion functions.
*
* @category Zend
* @package Zend_Ldap
*/
class Converter
{
Expand All @@ -38,7 +34,7 @@ class Converter
*/
public static function ascToHex32($string)
{
for ($i = 0; $i < strlen($string); $i++) {
for ($i = 0, $len = strlen($string); $i < $len; $i++) {
$char = substr($string, $i, 1);
if (ord($char) < 32) {
$hex = dechex(ord($char));
Expand All @@ -64,7 +60,9 @@ public static function ascToHex32($string)
*/
public static function hex32ToAsc($string)
{
$string = preg_replace('/\\\([0-9A-Fa-f]{2})/e', "''.chr(hexdec('\\1')).''", $string);
$string = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function ($matches) {
return chr(hexdec($matches[1]));
}, $string);
return $string;
}

Expand Down Expand Up @@ -125,8 +123,8 @@ public static function toLdap($value, $type = self::STANDARD)
* The date-entity <var>$date</var> can be either a timestamp, a
* DateTime Object, a string that is parseable by strtotime().
*
* @param integer|string|DateTime $date The date-entity
* @param boolean $asUtc Whether to return the LDAP-compatible date-string as UTC or as local value
* @param int|string|DateTime $date The date-entity
* @param bool $asUtc Whether to return the LDAP-compatible date-string as UTC or as local value
* @return string
* @throws Exception\InvalidArgumentException
*/
Expand Down Expand Up @@ -160,7 +158,7 @@ public static function toLdapDateTime($date, $asUtc = true)
* case-insensitive string 'true' to an LDAP-compatible 'TRUE'. All other
* other values are converted to an LDAP-compatible 'FALSE'.
*
* @param boolean|integer|string $value The boolean value to encode
* @param bool|int|string $value The boolean value to encode
* @return string
*/
public static function toLdapBoolean($value)
Expand Down Expand Up @@ -197,7 +195,7 @@ public static function toLdapSerialize($value)
* @see Converter::GENERALIZED_TIME
* @param string $value The value to convert
* @param int $type The conversion type to use
* @param boolean $dateTimeAsUtc Return DateTime values in UTC timezone
* @param bool $dateTimeAsUtc Return DateTime values in UTC timezone
* @return mixed
*/
public static function fromLdap($value, $type = self::STANDARD, $dateTimeAsUtc = true)
Expand Down Expand Up @@ -236,7 +234,7 @@ public static function fromLdap($value, $type = self::STANDARD, $dateTimeAsUtc =
* CAVEAT: The DateTime-Object returned will always be set to UTC-Timezone.
*
* @param string $date The generalized-Time
* @param boolean $asUtc Return the DateTime with UTC timezone
* @param bool $asUtc Return the DateTime with UTC timezone
* @return DateTime
* @throws Exception\InvalidArgumentException if a non-parseable-format is given
*/
Expand Down Expand Up @@ -360,7 +358,7 @@ public static function fromLdapDateTime($date, $asUtc = true)
* Convert an LDAP-compatible boolean value into a PHP-compatible one
*
* @param string $value The value to convert
* @return boolean
* @return bool
* @throws Exception\InvalidArgumentException
*/
public static function fromLdapBoolean($value)
Expand Down
7 changes: 1 addition & 6 deletions src/Converter/Exception/ConverterException.php
Expand Up @@ -3,17 +3,12 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Ldap
*/

namespace Zend\Ldap\Converter\Exception;

/**
* @category Zend
* @package Zend_Ldap
*/
class ConverterException extends \Exception implements ExceptionInterface
{
}
7 changes: 1 addition & 6 deletions src/Converter/Exception/ExceptionInterface.php
Expand Up @@ -3,17 +3,12 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Ldap
*/

namespace Zend\Ldap\Converter\Exception;

/**
* @category Zend
* @package Zend_Ldap
*/
interface ExceptionInterface
{
}
7 changes: 1 addition & 6 deletions src/Converter/Exception/InvalidArgumentException.php
Expand Up @@ -3,17 +3,12 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Ldap
*/

namespace Zend\Ldap\Converter\Exception;

/**
* @category Zend
* @package Zend_Ldap
*/
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
7 changes: 1 addition & 6 deletions src/Converter/Exception/UnexpectedValueException.php
Expand Up @@ -3,17 +3,12 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Ldap
*/

namespace Zend\Ldap\Converter\Exception;

/**
* @category Zend
* @package Zend_Ldap
*/
class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface
{
}

0 comments on commit 1ae1507

Please sign in to comment.