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

Commit

Permalink
Merge branch 'hotfix/2878'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 59 deletions.
24 changes: 12 additions & 12 deletions src/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public static function setAttribute(array &$data, $attribName, $value, $append =
$valArray = array();
if (is_array($value) || ($value instanceof \Traversable)) {
foreach ($value as $v) {
$v = self::valueToLdap($v);
$v = static::valueToLdap($v);
if ($v !== null) {
$valArray[] = $v;
}
}
} elseif ($value !== null) {
$value = self::valueToLdap($value);
$value = static::valueToLdap($value);
if ($value !== null) {
$valArray[] = $value;
}
Expand Down Expand Up @@ -80,14 +80,14 @@ public static function getAttribute(array $data, $attribName, $index = null)
}
$retArray = array();
foreach ($data[$attribName] as $v) {
$retArray[] = self::valueFromLdap($v);
$retArray[] = static::valueFromLdap($v);
}
return $retArray;
} elseif (is_int($index)) {
if (!isset($data[$attribName])) {
return null;
} elseif ($index >= 0 && $index < count($data[$attribName])) {
return self::valueFromLdap($data[$attribName][$index]);
return static::valueFromLdap($data[$attribName][$index]);
} else {
return null;
}
Expand Down Expand Up @@ -227,8 +227,8 @@ public static function setPassword(
}
}

$hash = self::createPassword($password, $hashType);
self::setAttribute($data, $attribName, $hash, false);
$hash = static::createPassword($password, $hashType);
static::setAttribute($data, $attribName, $hash, false);
}

/**
Expand Down Expand Up @@ -299,18 +299,18 @@ public static function setDateTimeAttribute(
$convertedValues = array();
if (is_array($value) || ($value instanceof \Traversable)) {
foreach ($value as $v) {
$v = self::valueToLdapDateTime($v, $utc);
$v = static::valueToLdapDateTime($v, $utc);
if ($v !== null) {
$convertedValues[] = $v;
}
}
} elseif ($value !== null) {
$value = self::valueToLdapDateTime($value, $utc);
$value = static::valueToLdapDateTime($value, $utc);
if ($value !== null) {
$convertedValues[] = $value;
}
}
self::setAttribute($data, $attribName, $convertedValues, $append);
static::setAttribute($data, $attribName, $convertedValues, $append);
}

/**
Expand All @@ -337,16 +337,16 @@ private static function valueToLdapDateTime($value, $utc)
*/
public static function getDateTimeAttribute(array $data, $attribName, $index = null)
{
$values = self::getAttribute($data, $attribName, $index);
$values = static::getAttribute($data, $attribName, $index);
if (is_array($values)) {
for ($i = 0; $i < count($values); $i++) {
$newVal = self::valueFromLdapDateTime($values[$i]);
$newVal = static::valueFromLdapDateTime($values[$i]);
if ($newVal !== null) {
$values[$i] = $newVal;
}
}
} else {
$newVal = self::valueFromLdapDateTime($values);
$newVal = static::valueFromLdapDateTime($values);
if ($newVal !== null) {
$values = $newVal;
}
Expand Down
22 changes: 11 additions & 11 deletions src/Converter/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,26 @@ public static function toLdap($value, $type = self::STANDARD)
try {
switch ($type) {
case self::BOOLEAN:
return self::toldapBoolean($value);
return static::toldapBoolean($value);
break;
case self::GENERALIZED_TIME:
return self::toLdapDatetime($value);
return static::toLdapDatetime($value);
break;
default:
if (is_string($value)) {
return $value;
} elseif (is_int($value) || is_float($value)) {
return (string)$value;
} elseif (is_bool($value)) {
return self::toldapBoolean($value);
return static::toldapBoolean($value);
} elseif (is_object($value)) {
if ($value instanceof DateTime) {
return self::toLdapDatetime($value);
return static::toLdapDatetime($value);
} else {
return self::toLdapSerialize($value);
return static::toLdapSerialize($value);
}
} elseif (is_array($value)) {
return self::toLdapSerialize($value);
return static::toLdapSerialize($value);
} elseif (is_resource($value) && get_resource_type($value) === 'stream') {
return stream_get_contents($value);
} else {
Expand Down Expand Up @@ -204,23 +204,23 @@ public static function fromLdap($value, $type = self::STANDARD, $dateTimeAsUtc =
{
switch ($type) {
case self::BOOLEAN:
return self::fromldapBoolean($value);
return static::fromldapBoolean($value);
break;
case self::GENERALIZED_TIME:
return self::fromLdapDateTime($value);
return static::fromLdapDateTime($value);
break;
default:
if (is_numeric($value)) {
// prevent numeric values to be treated as date/time
return $value;
} elseif ('TRUE' === $value || 'FALSE' === $value) {
return self::fromLdapBoolean($value);
return static::fromLdapBoolean($value);
}
if (preg_match('/^\d{4}[\d\+\-Z\.]*$/', $value)) {
return self::fromLdapDateTime($value, $dateTimeAsUtc);
return static::fromLdapDateTime($value, $dateTimeAsUtc);
}
try {
return self::fromLdapUnserialize($value);
return static::fromLdapUnserialize($value);
} catch (Exception\UnexpectedValueException $e) {
// Do nothing
}
Expand Down
56 changes: 28 additions & 28 deletions src/Dn.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class Dn implements \ArrayAccess
public static function factory($dn, $caseFold = null)
{
if (is_array($dn)) {
return self::fromArray($dn, $caseFold);
return static::fromArray($dn, $caseFold);
} elseif (is_string($dn)) {
return self::fromString($dn, $caseFold);
return static::fromString($dn, $caseFold);
}
throw new Exception\LdapException(null, 'Invalid argument type for $dn');
}
Expand All @@ -75,7 +75,7 @@ public static function fromString($dn, $caseFold = null)
if (empty($dn)) {
$dnArray = array();
} else {
$dnArray = self::explodeDn((string)$dn);
$dnArray = static::explodeDn((string)$dn);
}
return new self($dnArray, $caseFold);
}
Expand Down Expand Up @@ -114,8 +114,8 @@ protected function __construct(array $dn, $caseFold)
*/
public function getRdn($caseFold = null)
{
$caseFold = self::sanitizeCaseFold($caseFold, $this->caseFold);
return self::caseFoldRdn($this->get(0, 1, $caseFold), null);
$caseFold = static::sanitizeCaseFold($caseFold, $this->caseFold);
return static::caseFoldRdn($this->get(0, 1, $caseFold), null);
}

/**
Expand All @@ -127,8 +127,8 @@ public function getRdn($caseFold = null)
*/
public function getRdnString($caseFold = null)
{
$caseFold = self::sanitizeCaseFold($caseFold, $this->caseFold);
return self::implodeRdn($this->getRdn(), $caseFold);
$caseFold = static::sanitizeCaseFold($caseFold, $this->caseFold);
return static::implodeRdn($this->getRdn(), $caseFold);
}

/**
Expand Down Expand Up @@ -159,16 +159,16 @@ public function getParentDn($levelUp = 1)
*/
public function get($index, $length = 1, $caseFold = null)
{
$caseFold = self::sanitizeCaseFold($caseFold, $this->caseFold);
$caseFold = static::sanitizeCaseFold($caseFold, $this->caseFold);
$this->assertIndex($index);
$length = (int) $length;
if ($length <= 0) {
$length = 1;
}
if ($length === 1) {
return self::caseFoldRdn($this->dn[$index], $caseFold);
return static::caseFoldRdn($this->dn[$index], $caseFold);
}
return self::caseFoldDn(array_slice($this->dn, $index, $length, false), $caseFold);
return static::caseFoldDn(array_slice($this->dn, $index, $length, false), $caseFold);
}

/**
Expand All @@ -182,7 +182,7 @@ public function get($index, $length = 1, $caseFold = null)
public function set($index, array $value)
{
$this->assertIndex($index);
self::assertRdn($value);
static::assertRdn($value);
$this->dn[$index] = $value;
return $this;
}
Expand Down Expand Up @@ -214,7 +214,7 @@ public function remove($index, $length = 1)
*/
public function append(array $value)
{
self::assertRdn($value);
static::assertRdn($value);
$this->dn[] = $value;
return $this;
}
Expand All @@ -227,7 +227,7 @@ public function append(array $value)
*/
public function prepend(array $value)
{
self::assertRdn($value);
static::assertRdn($value);
array_unshift($this->dn, $value);
return $this;
}
Expand All @@ -243,7 +243,7 @@ public function prepend(array $value)
public function insert($index, array $value)
{
$this->assertIndex($index);
self::assertRdn($value);
static::assertRdn($value);
$first = array_slice($this->dn, 0, $index + 1);
$second = array_slice($this->dn, $index + 1);
$this->dn = array_merge($first, array($value), $second);
Expand Down Expand Up @@ -295,7 +295,7 @@ protected static function assertRdn(array $value)
*/
public function setCaseFold($caseFold)
{
$this->caseFold = self::sanitizeCaseFold($caseFold, self::$defaultCaseFold);
$this->caseFold = static::sanitizeCaseFold($caseFold, static::$defaultCaseFold);
}

/**
Expand All @@ -307,8 +307,8 @@ public function setCaseFold($caseFold)
*/
public function toString($caseFold = null)
{
$caseFold = self::sanitizeCaseFold($caseFold, $this->caseFold);
return self::implodeDn($this->dn, $caseFold);
$caseFold = static::sanitizeCaseFold($caseFold, $this->caseFold);
return static::implodeDn($this->dn, $caseFold);
}

/**
Expand All @@ -319,12 +319,12 @@ public function toString($caseFold = null)
*/
public function toArray($caseFold = null)
{
$caseFold = self::sanitizeCaseFold($caseFold, $this->caseFold);
$caseFold = static::sanitizeCaseFold($caseFold, $this->caseFold);

if ($caseFold === self::ATTR_CASEFOLD_NONE) {
return $this->dn;
}
return self::caseFoldDn($this->dn, $caseFold);
return static::caseFoldDn($this->dn, $caseFold);
}

/**
Expand Down Expand Up @@ -358,7 +358,7 @@ protected static function caseFoldDn(array $dn, $caseFold)
{
$return = array();
foreach ($dn as $part) {
$return[] = self::caseFoldRdn($part, $caseFold);
$return[] = static::caseFoldRdn($part, $caseFold);
}
return $return;
}
Expand Down Expand Up @@ -430,7 +430,7 @@ public function offsetUnset($offset)
*/
public static function setDefaultCaseFold($caseFold)
{
self::$defaultCaseFold = self::sanitizeCaseFold($caseFold, self::ATTR_CASEFOLD_NONE);
static::$defaultCaseFold = static::sanitizeCaseFold($caseFold, self::ATTR_CASEFOLD_NONE);
}

/**
Expand Down Expand Up @@ -635,7 +635,7 @@ public static function checkDn(
if ($ch === '\\') {
$state = 3;
} elseif ($ch === ',' || $ch === ';' || $ch === 0 || $ch === '+') {
$value = self::unescapeValue(trim(substr($dn, $vo, $di - $vo)));
$value = static::unescapeValue(trim(substr($dn, $vo, $di - $vo)));
if (is_array($multi)) {
$va[count($va) - 1][] = $value;
} else {
Expand Down Expand Up @@ -685,11 +685,11 @@ public static function checkDn(
*/
public static function implodeRdn(array $part, $caseFold = null)
{
self::assertRdn($part);
$part = self::caseFoldRdn($part, $caseFold);
static::assertRdn($part);
$part = static::caseFoldRdn($part, $caseFold);
$rdnParts = array();
foreach ($part as $key => $value) {
$value = self::escapeValue($value);
$value = static::escapeValue($value);
$keyId = strtolower($key);
$rdnParts[$keyId] = implode('=', array($key, $value));
}
Expand Down Expand Up @@ -720,7 +720,7 @@ public static function implodeDn(array $dnArray, $caseFold = null, $separator =
{
$parts = array();
foreach ($dnArray as $p) {
$parts[] = self::implodeRdn($p, $caseFold);
$parts[] = static::implodeRdn($p, $caseFold);
}

return implode($separator, $parts);
Expand All @@ -741,12 +741,12 @@ public static function isChildOf($childDn, $parentDn)
if ($childDn instanceof Dn) {
$cdn = $childDn->toArray(DN::ATTR_CASEFOLD_LOWER);
} else {
$cdn = self::explodeDn($childDn, $keys, $vals, DN::ATTR_CASEFOLD_LOWER);
$cdn = static::explodeDn($childDn, $keys, $vals, DN::ATTR_CASEFOLD_LOWER);
}
if ($parentDn instanceof Dn) {
$pdn = $parentDn->toArray(DN::ATTR_CASEFOLD_LOWER);
} else {
$pdn = self::explodeDn($parentDn, $keys, $vals, DN::ATTR_CASEFOLD_LOWER);
$pdn = static::explodeDn($parentDn, $keys, $vals, DN::ATTR_CASEFOLD_LOWER);
}
} catch (Exception\LdapException $e) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private static function createFilterString($attr, $value, $filtertype, $prepend
if ($prepend !== null) {
$str .= $prepend;
}
$str .= self::escapeValue($value);
$str .= static::escapeValue($value);
if ($append !== null) {
$str .= $append;
}
Expand All @@ -234,7 +234,7 @@ private static function createFilterString($attr, $value, $filtertype, $prepend
*/
public function __construct($attr, $value, $filtertype, $prepend = null, $append = null)
{
$filter = self::createFilterString($attr, $value, $filtertype, $prepend, $append);
$filter = static::createFilterString($attr, $value, $filtertype, $prepend, $append);
parent::__construct($filter);
}
}
2 changes: 1 addition & 1 deletion src/Filter/MaskFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct($mask, $value)
$args = func_get_args();
array_shift($args);
for ($i = 0; $i < count($args); $i++) {
$args[$i] = self::escapeValue($args[$i]);
$args[$i] = static::escapeValue($args[$i]);
}
$filter = vsprintf($mask, $args);
parent::__construct($filter);
Expand Down
4 changes: 2 additions & 2 deletions src/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ public function add($dn, array $entry)
if (!($dn instanceof Dn)) {
$dn = Dn::factory($dn, null);
}
self::prepareLdapEntryArray($entry);
static::prepareLdapEntryArray($entry);
foreach ($entry as $key => $value) {
if (is_array($value) && count($value) === 0) {
unset($entry[$key]);
Expand Down Expand Up @@ -1196,7 +1196,7 @@ public function update($dn, array $entry)
if (!($dn instanceof Dn)) {
$dn = Dn::factory($dn, null);
}
self::prepareLdapEntryArray($entry);
static::prepareLdapEntryArray($entry);

$rdnParts = $dn->getRdn(Dn::ATTR_CASEFOLD_LOWER);
foreach ($rdnParts as $key => $value) {
Expand Down
Loading

0 comments on commit 6004e35

Please sign in to comment.