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

Commit 5998122

Browse files
committed
Merge branch 'cs/various-things' of https://github.com/Maks3w/zf2
17 parents f342e7c + 73b49a3 + a7937fe + 18bc286 + 7c2f341 + 3fd24f6 + 46b66eb + 5dc451e + 6cc63be + 36c3273 + d866e82 + 91a7d10 + d7310a9 + 024435b + 9d596bf + 205ad91 + 34263bb commit 5998122

File tree

13 files changed

+60
-70
lines changed

13 files changed

+60
-70
lines changed

src/Attribute.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static function setAttribute(array &$data, $attribName, $value, $append =
4646
$valArray[] = $v;
4747
}
4848
}
49-
} else if ($value !== null) {
49+
} elseif ($value !== null) {
5050
$value = self::valueToLdap($value);
5151
if ($value !== null) {
5252
$valArray[] = $value;
@@ -83,10 +83,10 @@ public static function getAttribute(array $data, $attribName, $index = null)
8383
$retArray[] = self::valueFromLDAP($v);
8484
}
8585
return $retArray;
86-
} else if (is_int($index)) {
86+
} elseif (is_int($index)) {
8787
if (!isset($data[$attribName])) {
8888
return null;
89-
} else if ($index >= 0 && $index < count($data[$attribName])) {
89+
} elseif ($index >= 0 && $index < count($data[$attribName])) {
9090
return self::valueFromLDAP($data[$attribName][$index]);
9191
} else {
9292
return null;
@@ -248,7 +248,7 @@ public static function createPassword($password, $hashType = self::PASSWORD_HASH
248248
$password = '"' . $password . '"';
249249
if (function_exists('mb_convert_encoding')) {
250250
$password = mb_convert_encoding($password, 'UTF-16LE', 'UTF-8');
251-
} else if (function_exists('iconv')) {
251+
} elseif (function_exists('iconv')) {
252252
$password = iconv('UTF-8', 'UTF-16LE', $password);
253253
} else {
254254
$len = strlen($password);
@@ -363,7 +363,7 @@ private static function valueFromLdapDateTime($value)
363363
{
364364
if ($value instanceof DateTime) {
365365
return $value->format('U');
366-
} else if (is_string($value)) {
366+
} elseif (is_string($value)) {
367367
try {
368368
return Converter\Converter::fromLdapDateTime($value, false)->format('U');
369369
} catch (Converter\Exception\InvalidArgumentException $e) {

src/Collection/DefaultIterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function setAttributeNameTreatment($attributeNameTreatment)
128128
if (is_callable($attributeNameTreatment)) {
129129
if (is_string($attributeNameTreatment) && !function_exists($attributeNameTreatment)) {
130130
$this->attributeNameTreatment = self::ATTRIBUTE_TO_LOWER;
131-
} else if (is_array($attributeNameTreatment)
131+
} elseif (is_array($attributeNameTreatment)
132132
&& !method_exists($attributeNameTreatment[0], $attributeNameTreatment[1])
133133
) {
134134
$this->attributeNameTreatment = self::ATTRIBUTE_TO_LOWER;
@@ -265,7 +265,7 @@ public function next()
265265
if ($code === Exception\LdapException::LDAP_SIZELIMIT_EXCEEDED) {
266266
// we have reached the size limit enforced by the server
267267
return;
268-
} else if ($code > Exception\LdapException::LDAP_SUCCESS) {
268+
} elseif ($code > Exception\LdapException::LDAP_SUCCESS) {
269269
throw new Exception\LdapException($this->ldap, 'getting next entry (' . $msg . ')');
270270
}
271271
}

src/Converter/Converter.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,19 @@ public static function toLdap($value, $type = self::STANDARD)
9494
default:
9595
if (is_string($value)) {
9696
return $value;
97-
} else if (is_int($value) || is_float($value)) {
97+
} elseif (is_int($value) || is_float($value)) {
9898
return (string)$value;
99-
} else if (is_bool($value)) {
99+
} elseif (is_bool($value)) {
100100
return self::toldapBoolean($value);
101-
} else if (is_object($value)) {
101+
} elseif (is_object($value)) {
102102
if ($value instanceof DateTime) {
103103
return self::toLdapDatetime($value);
104104
} else {
105105
return self::toLdapSerialize($value);
106106
}
107-
} else if (is_array($value)) {
107+
} elseif (is_array($value)) {
108108
return self::toLdapSerialize($value);
109-
} else if (is_resource($value) && get_resource_type($value) === 'stream') {
109+
} elseif (is_resource($value) && get_resource_type($value) === 'stream') {
110110
return stream_get_contents($value);
111111
} else {
112112
return null;
@@ -135,7 +135,7 @@ public static function toLdapDateTime($date, $asUtc = true)
135135
if (is_int($date)) {
136136
$date = new DateTime('@' . $date);
137137
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
138-
} else if (is_string($date)) {
138+
} elseif (is_string($date)) {
139139
$date = new DateTime($date);
140140
} else {
141141
throw new Exception\InvalidArgumentException('Parameter $date is not of the expected type');
@@ -212,7 +212,7 @@ public static function fromLdap($value, $type = self::STANDARD, $dateTimeAsUtc =
212212
if (is_numeric($value)) {
213213
// prevent numeric values to be treated as date/time
214214
return $value;
215-
} else if ('TRUE' === $value || 'FALSE' === $value) {
215+
} elseif ('TRUE' === $value || 'FALSE' === $value) {
216216
return self::fromLdapBoolean($value);
217217
}
218218
if (preg_match('/^\d{4}[\d\+\-Z\.]*$/', $value)) {
@@ -366,7 +366,7 @@ public static function fromLdapBoolean($value)
366366
{
367367
if ('TRUE' === $value) {
368368
return true;
369-
} else if ('FALSE' === $value) {
369+
} elseif ('FALSE' === $value) {
370370
return false;
371371
} else {
372372
throw new Exception\InvalidArgumentException('The given value is not a boolean value');

src/Dn.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static function factory($dn, $caseFold = null)
5555
{
5656
if (is_array($dn)) {
5757
return self::fromArray($dn, $caseFold);
58-
} else if (is_string($dn)) {
58+
} elseif (is_string($dn)) {
5959
return self::fromString($dn, $caseFold);
6060
} else {
6161
throw new Exception\LdapException(null, 'Invalid argument type for $dn');
@@ -168,8 +168,7 @@ public function get($index, $length = 1, $caseFold = null)
168168
}
169169
if ($length === 1) {
170170
return self::caseFoldRdn($this->dn[$index], $caseFold);
171-
}
172-
else {
171+
} else {
173172
return self::caseFoldDn(array_slice($this->dn, $index, $length, false), $caseFold);
174173
}
175174
}
@@ -570,7 +569,7 @@ public static function explodeDn(
570569
$multi[$key] = $val;
571570
}
572571
$ret[] = $multi;
573-
} else if (is_string($k[$i]) && is_string($v[$i])) {
572+
} elseif (is_string($k[$i]) && is_string($v[$i])) {
574573
$ret[] = array($k[$i] => $v[$i]);
575574
}
576575
}
@@ -617,7 +616,7 @@ public static function checkDn(
617616
$key = trim(substr($dn, $ko, $di - $ko));
618617
if ($caseFold == self::ATTR_CASEFOLD_LOWER) {
619618
$key = strtolower($key);
620-
} else if ($caseFold == self::ATTR_CASEFOLD_UPPER) {
619+
} elseif ($caseFold == self::ATTR_CASEFOLD_UPPER) {
621620
$key = strtoupper($key);
622621
}
623622
if (is_array($multi)) {
@@ -632,14 +631,14 @@ public static function checkDn(
632631
}
633632
$state = 2;
634633
$vo = $di + 1;
635-
} else if ($ch === ',' || $ch === ';' || $ch === '+') {
634+
} elseif ($ch === ',' || $ch === ';' || $ch === '+') {
636635
return false;
637636
}
638637
break;
639638
case 2: // collect value
640639
if ($ch === '\\') {
641640
$state = 3;
642-
} else if ($ch === ',' || $ch === ';' || $ch === 0 || $ch === '+') {
641+
} elseif ($ch === ',' || $ch === ';' || $ch === 0 || $ch === '+') {
643642
$value = self::unescapeValue(trim(substr($dn, $vo, $di - $vo)));
644643
if (is_array($multi)) {
645644
$va[count($va) - 1][] = $value;
@@ -654,10 +653,10 @@ public static function checkDn(
654653
$ka[] = array($lastKey);
655654
$va[] = array($lastVal);
656655
$multi = array(strtolower($lastKey));
657-
} else if ($ch === ',' || $ch === ';' || $ch === 0) {
656+
} elseif ($ch === ',' || $ch === ';' || $ch === 0) {
658657
$multi = false;
659658
}
660-
} else if ($ch === '=') {
659+
} elseif ($ch === '=') {
661660
return false;
662661
}
663662
break;

src/Filter/AbstractLogicalFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function __construct(array $subfilters, $symbol)
5050
foreach ($subfilters as $key => $s) {
5151
if (is_string($s)) {
5252
$subfilters[$key] = new StringFilter($s);
53-
} else if (!($s instanceof AbstractFilter)) {
53+
} elseif (!($s instanceof AbstractFilter)) {
5454
throw new Exception\FilterException('Only strings or Zend\Ldap\Filter\AbstractFilter allowed.');
5555
}
5656
}

src/Ldap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ public function search($filter, $basedn = null, $scope = self::SEARCH_SCOPE_SUB,
879879

880880
if ($basedn === null) {
881881
$basedn = $this->getBaseDn();
882-
} else if ($basedn instanceof Dn) {
882+
} elseif ($basedn instanceof Dn) {
883883
$basedn = $basedn->toString();
884884
}
885885

@@ -1137,7 +1137,7 @@ public function add($dn, array $entry)
11371137
$value = Dn::unescapeValue($value);
11381138
if (!array_key_exists($key, $entry)) {
11391139
$entry[$key] = array($value);
1140-
} else if (!in_array($value, $entry[$key])) {
1140+
} elseif (!in_array($value, $entry[$key])) {
11411141
$entry[$key] = array_merge(array($value), $entry[$key]);
11421142
}
11431143
}
@@ -1348,7 +1348,7 @@ public function rename($from, $to, $recursively = false, $alwaysEmulate = false)
13481348
$emulate = (bool)$alwaysEmulate;
13491349
if (!function_exists('ldap_rename')) {
13501350
$emulate = true;
1351-
} else if ($recursively) {
1351+
} elseif ($recursively) {
13521352
$emulate = true;
13531353
}
13541354

@@ -1368,7 +1368,7 @@ public function rename($from, $to, $recursively = false, $alwaysEmulate = false)
13681368
$isOK = @ldap_rename($this->getResource(), $from, $newRdn, $newParent, true);
13691369
if ($isOK === false) {
13701370
throw new Exception\LdapException($this, 'renaming ' . $from . ' to ' . $to);
1371-
} else if (!$this->exists($to)) {
1371+
} elseif (!$this->exists($to)) {
13721372
$emulate = true;
13731373
}
13741374
}

src/Ldif/Encoder.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ protected function _decode($string)
7575
$matches = array();
7676
if (substr($line, 0, 1) === ' ' && $last !== null) {
7777
$last[2] .= substr($line, 1);
78-
} else if (substr($line, 0, 1) === '#') {
78+
} elseif (substr($line, 0, 1) === '#') {
7979
continue;
80-
} else if (preg_match('/^([a-z0-9;-]+)(:[:<]?\s*)([^:<]*)$/i', $line, $matches)) {
80+
} elseif (preg_match('/^([a-z0-9;-]+)(:[:<]?\s*)([^:<]*)$/i', $line, $matches)) {
8181
$name = strtolower($matches[1]);
8282
$type = trim($matches[2]);
8383
$value = $matches[3];
@@ -86,13 +86,13 @@ protected function _decode($string)
8686
}
8787
if ($name === 'version') {
8888
continue;
89-
} else if (count($item) > 0 && $name === 'dn') {
89+
} elseif (count($item) > 0 && $name === 'dn') {
9090
$items[] = $item;
9191
$item = array();
9292
$last = null;
9393
}
9494
$last = array($name, $type, $value);
95-
} else if (trim($line) === '') {
95+
} elseif (trim($line) === '') {
9696
continue;
9797
}
9898
}
@@ -120,7 +120,7 @@ protected function pushAttribute(array $attribute, array &$entry)
120120
}
121121
if ($name === 'dn') {
122122
$entry[$name] = $value;
123-
} else if (isset($entry[$name]) && $value !== '') {
123+
} elseif (isset($entry[$name]) && $value !== '') {
124124
$entry[$name][] = $value;
125125
} else {
126126
$entry[$name] = ($value !== '') ? array($value) : array();
@@ -152,9 +152,9 @@ protected function _encode($value)
152152
{
153153
if (is_scalar($value)) {
154154
return $this->encodeString($value);
155-
} else if (is_array($value)) {
155+
} elseif (is_array($value)) {
156156
return $this->encodeAttributes($value);
157-
} else if ($value instanceof Ldap\Node) {
157+
} elseif ($value instanceof Ldap\Node) {
158158
return $value->toLdif($this->options);
159159
}
160160

@@ -199,10 +199,10 @@ protected function encodeString($string, &$base64 = null)
199199
if ($char >= 127) {
200200
$base64 = true;
201201
break;
202-
} else if ($i === 0 && in_array($char, $unsafe_init_char)) {
202+
} elseif ($i === 0 && in_array($char, $unsafe_init_char)) {
203203
$base64 = true;
204204
break;
205-
} else if (in_array($char, $unsafe_char)) {
205+
} elseif (in_array($char, $unsafe_char)) {
206206
$base64 = true;
207207
break;
208208
}

src/Node.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public static function create($dn, array $objectClass = array())
240240
{
241241
if (is_string($dn) || is_array($dn)) {
242242
$dn = Dn::factory($dn);
243-
} else if ($dn instanceof Dn) {
243+
} elseif ($dn instanceof Dn) {
244244
$dn = clone $dn;
245245
} else {
246246
throw new Exception\LdapException(null, '$dn is of a wrong data type.');
@@ -264,7 +264,7 @@ public static function fromLdap($dn, Ldap $ldap)
264264
{
265265
if (is_string($dn) || is_array($dn)) {
266266
$dn = Dn::factory($dn);
267-
} else if ($dn instanceof Dn) {
267+
} elseif ($dn instanceof Dn) {
268268
$dn = clone $dn;
269269
} else {
270270
throw new Exception\LdapException(null, '$dn is of a wrong data type.');
@@ -293,7 +293,7 @@ public static function fromArray(array $data, $fromDataSource = false)
293293
}
294294
if (is_string($data['dn']) || is_array($data['dn'])) {
295295
$dn = Dn::factory($data['dn']);
296-
} else if ($data['dn'] instanceof Dn) {
296+
} elseif ($data['dn'] instanceof Dn) {
297297
$dn = clone $data['dn'];
298298
} else {
299299
throw new Exception\LdapException(null, '\'dn\' key is of a wrong data type.');
@@ -316,7 +316,7 @@ protected function ensureRdnAttributeValues($overwrite = false)
316316
foreach ($this->getRdnArray() as $key => $value) {
317317
if (!array_key_exists($key, $this->currentData) || $overwrite) {
318318
Attribute::setAttribute($this->currentData, $key, $value, false);
319-
} else if (!in_array($value, $this->currentData[$key])) {
319+
} elseif (!in_array($value, $this->currentData[$key])) {
320320
Attribute::setAttribute($this->currentData, $key, $value, true);
321321
}
322322
}
@@ -393,7 +393,7 @@ public function willBeMoved()
393393
{
394394
if ($this->isNew() || $this->willBeDeleted()) {
395395
return false;
396-
} else if ($this->newDn !== null) {
396+
} elseif ($this->newDn !== null) {
397397
return ($this->dn != $this->newDn);
398398
} else {
399399
return false;
@@ -605,7 +605,7 @@ public function getChangedData()
605605
foreach ($this->currentData as $key => $value) {
606606
if (!array_key_exists($key, $this->originalData) && !empty($value)) {
607607
$changed[$key] = $value;
608-
} else if ($this->originalData[$key] !== $this->currentData[$key]) {
608+
} elseif ($this->originalData[$key] !== $this->currentData[$key]) {
609609
$changed[$key] = $value;
610610
}
611611
}
@@ -629,9 +629,9 @@ public function getChanges()
629629
foreach ($this->currentData as $key => $value) {
630630
if (!array_key_exists($key, $this->originalData) && !empty($value)) {
631631
$changes['add'][$key] = $value;
632-
} else if (count($this->originalData[$key]) === 0 && !empty($value)) {
632+
} elseif (count($this->originalData[$key]) === 0 && !empty($value)) {
633633
$changes['add'][$key] = $value;
634-
} else if ($this->originalData[$key] !== $this->currentData[$key]) {
634+
} elseif ($this->originalData[$key] !== $this->currentData[$key]) {
635635
if (empty($value)) {
636636
$changes['delete'][$key] = $value;
637637
} else {
@@ -812,10 +812,9 @@ protected function assertChangeableAttribute($name)
812812
$rdn = $this->getRdnArray(Dn::ATTR_CASEFOLD_LOWER);
813813
if ($name == 'dn') {
814814
throw new Exception\LdapException(null, 'DN cannot be changed.');
815-
}
816-
else if (array_key_exists($name, $rdn)) {
815+
} elseif (array_key_exists($name, $rdn)) {
817816
throw new Exception\LdapException(null, 'Cannot change attribute because it\'s part of the RDN');
818-
} else if (in_array($name, self::$systemAttributes)) {
817+
} elseif (in_array($name, self::$systemAttributes)) {
819818
throw new Exception\LdapException(null, 'Cannot change attribute because it\'s read-only');
820819
} else {
821820
return true;

src/Node/AbstractNode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ public function existsAttribute($name, $emptyExists = false)
286286
}
287287

288288
return count($this->currentData[$name]) > 0;
289-
}
290-
else {
289+
} else {
291290
return false;
292291
}
293292
}

src/Node/RootDse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public static function create(Ldap\Ldap $ldap)
3838
$data = $ldap->getEntry($dn, array('*', '+'), true);
3939
if (isset($data['domainfunctionality'])) {
4040
return new RootDse\ActiveDirectory($dn, $data);
41-
} else if (isset($data['dsaname'])) {
41+
} elseif (isset($data['dsaname'])) {
4242
return new RootDse\eDirectory($dn, $data);
43-
} else if (isset($data['structuralobjectclass'])
43+
} elseif (isset($data['structuralobjectclass'])
4444
&& $data['structuralobjectclass'][0] === 'OpenLDAProotDSE'
4545
) {
4646
return new RootDse\OpenLdap($dn, $data);

0 commit comments

Comments
 (0)