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

Commit

Permalink
[PSR-2] fixers=braces,elseif,short_tag,php_closing_tag,trailing_space…
Browse files Browse the repository at this point in the history
…s,linefeed

Applied php-cs-fixer --fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed
  • Loading branch information
Maks3w committed Jul 12, 2012
1 parent aa754c0 commit 34263bb
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 70 deletions.
10 changes: 5 additions & 5 deletions src/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function setAttribute(array &$data, $attribName, $value, $append =
$valArray[] = $v;
}
}
} else if ($value !== null) {
} elseif ($value !== null) {
$value = self::valueToLdap($value);
if ($value !== null) {
$valArray[] = $value;
Expand Down Expand Up @@ -83,10 +83,10 @@ public static function getAttribute(array $data, $attribName, $index = null)
$retArray[] = self::valueFromLDAP($v);
}
return $retArray;
} else if (is_int($index)) {
} elseif (is_int($index)) {
if (!isset($data[$attribName])) {
return null;
} else if ($index >= 0 && $index < count($data[$attribName])) {
} elseif ($index >= 0 && $index < count($data[$attribName])) {
return self::valueFromLDAP($data[$attribName][$index]);
} else {
return null;
Expand Down Expand Up @@ -248,7 +248,7 @@ public static function createPassword($password, $hashType = self::PASSWORD_HASH
$password = '"' . $password . '"';
if (function_exists('mb_convert_encoding')) {
$password = mb_convert_encoding($password, 'UTF-16LE', 'UTF-8');
} else if (function_exists('iconv')) {
} elseif (function_exists('iconv')) {
$password = iconv('UTF-8', 'UTF-16LE', $password);
} else {
$len = strlen($password);
Expand Down Expand Up @@ -363,7 +363,7 @@ private static function valueFromLdapDateTime($value)
{
if ($value instanceof DateTime) {
return $value->format('U');
} else if (is_string($value)) {
} elseif (is_string($value)) {
try {
return Converter\Converter::fromLdapDateTime($value, false)->format('U');
} catch (Converter\Exception\InvalidArgumentException $e) {
Expand Down
4 changes: 2 additions & 2 deletions src/Collection/DefaultIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function setAttributeNameTreatment($attributeNameTreatment)
if (is_callable($attributeNameTreatment)) {
if (is_string($attributeNameTreatment) && !function_exists($attributeNameTreatment)) {
$this->attributeNameTreatment = self::ATTRIBUTE_TO_LOWER;
} else if (is_array($attributeNameTreatment)
} elseif (is_array($attributeNameTreatment)
&& !method_exists($attributeNameTreatment[0], $attributeNameTreatment[1])
) {
$this->attributeNameTreatment = self::ATTRIBUTE_TO_LOWER;
Expand Down Expand Up @@ -265,7 +265,7 @@ public function next()
if ($code === Exception\LdapException::LDAP_SIZELIMIT_EXCEEDED) {
// we have reached the size limit enforced by the server
return;
} else if ($code > Exception\LdapException::LDAP_SUCCESS) {
} elseif ($code > Exception\LdapException::LDAP_SUCCESS) {
throw new Exception\LdapException($this->ldap, 'getting next entry (' . $msg . ')');
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/Converter/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ public static function toLdap($value, $type = self::STANDARD)
default:
if (is_string($value)) {
return $value;
} else if (is_int($value) || is_float($value)) {
} elseif (is_int($value) || is_float($value)) {
return (string)$value;
} else if (is_bool($value)) {
} elseif (is_bool($value)) {
return self::toldapBoolean($value);
} else if (is_object($value)) {
} elseif (is_object($value)) {
if ($value instanceof DateTime) {
return self::toLdapDatetime($value);
} else {
return self::toLdapSerialize($value);
}
} else if (is_array($value)) {
} elseif (is_array($value)) {
return self::toLdapSerialize($value);
} else if (is_resource($value) && get_resource_type($value) === 'stream') {
} elseif (is_resource($value) && get_resource_type($value) === 'stream') {
return stream_get_contents($value);
} else {
return null;
Expand Down Expand Up @@ -135,7 +135,7 @@ public static function toLdapDateTime($date, $asUtc = true)
if (is_int($date)) {
$date = new DateTime('@' . $date);
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
} else if (is_string($date)) {
} elseif (is_string($date)) {
$date = new DateTime($date);
} else {
throw new Exception\InvalidArgumentException('Parameter $date is not of the expected type');
Expand Down Expand Up @@ -212,7 +212,7 @@ public static function fromLdap($value, $type = self::STANDARD, $dateTimeAsUtc =
if (is_numeric($value)) {
// prevent numeric values to be treated as date/time
return $value;
} else if ('TRUE' === $value || 'FALSE' === $value) {
} elseif ('TRUE' === $value || 'FALSE' === $value) {
return self::fromLdapBoolean($value);
}
if (preg_match('/^\d{4}[\d\+\-Z\.]*$/', $value)) {
Expand Down Expand Up @@ -366,7 +366,7 @@ public static function fromLdapBoolean($value)
{
if ('TRUE' === $value) {
return true;
} else if ('FALSE' === $value) {
} elseif ('FALSE' === $value) {
return false;
} else {
throw new Exception\InvalidArgumentException('The given value is not a boolean value');
Expand Down
17 changes: 8 additions & 9 deletions src/Dn.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function factory($dn, $caseFold = null)
{
if (is_array($dn)) {
return self::fromArray($dn, $caseFold);
} else if (is_string($dn)) {
} elseif (is_string($dn)) {
return self::fromString($dn, $caseFold);
} else {
throw new Exception\LdapException(null, 'Invalid argument type for $dn');
Expand Down Expand Up @@ -168,8 +168,7 @@ public function get($index, $length = 1, $caseFold = null)
}
if ($length === 1) {
return self::caseFoldRdn($this->dn[$index], $caseFold);
}
else {
} else {
return self::caseFoldDn(array_slice($this->dn, $index, $length, false), $caseFold);
}
}
Expand Down Expand Up @@ -570,7 +569,7 @@ public static function explodeDn(
$multi[$key] = $val;
}
$ret[] = $multi;
} else if (is_string($k[$i]) && is_string($v[$i])) {
} elseif (is_string($k[$i]) && is_string($v[$i])) {
$ret[] = array($k[$i] => $v[$i]);
}
}
Expand Down Expand Up @@ -617,7 +616,7 @@ public static function checkDn(
$key = trim(substr($dn, $ko, $di - $ko));
if ($caseFold == self::ATTR_CASEFOLD_LOWER) {
$key = strtolower($key);
} else if ($caseFold == self::ATTR_CASEFOLD_UPPER) {
} elseif ($caseFold == self::ATTR_CASEFOLD_UPPER) {
$key = strtoupper($key);
}
if (is_array($multi)) {
Expand All @@ -632,14 +631,14 @@ public static function checkDn(
}
$state = 2;
$vo = $di + 1;
} else if ($ch === ',' || $ch === ';' || $ch === '+') {
} elseif ($ch === ',' || $ch === ';' || $ch === '+') {
return false;
}
break;
case 2: // collect value
if ($ch === '\\') {
$state = 3;
} else if ($ch === ',' || $ch === ';' || $ch === 0 || $ch === '+') {
} elseif ($ch === ',' || $ch === ';' || $ch === 0 || $ch === '+') {
$value = self::unescapeValue(trim(substr($dn, $vo, $di - $vo)));
if (is_array($multi)) {
$va[count($va) - 1][] = $value;
Expand All @@ -654,10 +653,10 @@ public static function checkDn(
$ka[] = array($lastKey);
$va[] = array($lastVal);
$multi = array(strtolower($lastKey));
} else if ($ch === ',' || $ch === ';' || $ch === 0) {
} elseif ($ch === ',' || $ch === ';' || $ch === 0) {
$multi = false;
}
} else if ($ch === '=') {
} elseif ($ch === '=') {
return false;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/AbstractLogicalFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function __construct(array $subfilters, $symbol)
foreach ($subfilters as $key => $s) {
if (is_string($s)) {
$subfilters[$key] = new StringFilter($s);
} else if (!($s instanceof AbstractFilter)) {
} elseif (!($s instanceof AbstractFilter)) {
throw new Exception\FilterException('Only strings or Zend\Ldap\Filter\AbstractFilter allowed.');
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ public function search($filter, $basedn = null, $scope = self::SEARCH_SCOPE_SUB,

if ($basedn === null) {
$basedn = $this->getBaseDn();
} else if ($basedn instanceof Dn) {
} elseif ($basedn instanceof Dn) {
$basedn = $basedn->toString();
}

Expand Down Expand Up @@ -1137,7 +1137,7 @@ public function add($dn, array $entry)
$value = Dn::unescapeValue($value);
if (!array_key_exists($key, $entry)) {
$entry[$key] = array($value);
} else if (!in_array($value, $entry[$key])) {
} elseif (!in_array($value, $entry[$key])) {
$entry[$key] = array_merge(array($value), $entry[$key]);
}
}
Expand Down Expand Up @@ -1348,7 +1348,7 @@ public function rename($from, $to, $recursively = false, $alwaysEmulate = false)
$emulate = (bool)$alwaysEmulate;
if (!function_exists('ldap_rename')) {
$emulate = true;
} else if ($recursively) {
} elseif ($recursively) {
$emulate = true;
}

Expand All @@ -1368,7 +1368,7 @@ public function rename($from, $to, $recursively = false, $alwaysEmulate = false)
$isOK = @ldap_rename($this->getResource(), $from, $newRdn, $newParent, true);
if ($isOK === false) {
throw new Exception\LdapException($this, 'renaming ' . $from . ' to ' . $to);
} else if (!$this->exists($to)) {
} elseif (!$this->exists($to)) {
$emulate = true;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/Ldif/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ protected function _decode($string)
$matches = array();
if (substr($line, 0, 1) === ' ' && $last !== null) {
$last[2] .= substr($line, 1);
} else if (substr($line, 0, 1) === '#') {
} elseif (substr($line, 0, 1) === '#') {
continue;
} else if (preg_match('/^([a-z0-9;-]+)(:[:<]?\s*)([^:<]*)$/i', $line, $matches)) {
} elseif (preg_match('/^([a-z0-9;-]+)(:[:<]?\s*)([^:<]*)$/i', $line, $matches)) {
$name = strtolower($matches[1]);
$type = trim($matches[2]);
$value = $matches[3];
Expand All @@ -86,13 +86,13 @@ protected function _decode($string)
}
if ($name === 'version') {
continue;
} else if (count($item) > 0 && $name === 'dn') {
} elseif (count($item) > 0 && $name === 'dn') {
$items[] = $item;
$item = array();
$last = null;
}
$last = array($name, $type, $value);
} else if (trim($line) === '') {
} elseif (trim($line) === '') {
continue;
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ protected function pushAttribute(array $attribute, array &$entry)
}
if ($name === 'dn') {
$entry[$name] = $value;
} else if (isset($entry[$name]) && $value !== '') {
} elseif (isset($entry[$name]) && $value !== '') {
$entry[$name][] = $value;
} else {
$entry[$name] = ($value !== '') ? array($value) : array();
Expand Down Expand Up @@ -152,9 +152,9 @@ protected function _encode($value)
{
if (is_scalar($value)) {
return $this->encodeString($value);
} else if (is_array($value)) {
} elseif (is_array($value)) {
return $this->encodeAttributes($value);
} else if ($value instanceof Ldap\Node) {
} elseif ($value instanceof Ldap\Node) {
return $value->toLdif($this->options);
}

Expand Down Expand Up @@ -199,10 +199,10 @@ protected function encodeString($string, &$base64 = null)
if ($char >= 127) {
$base64 = true;
break;
} else if ($i === 0 && in_array($char, $unsafe_init_char)) {
} elseif ($i === 0 && in_array($char, $unsafe_init_char)) {
$base64 = true;
break;
} else if (in_array($char, $unsafe_char)) {
} elseif (in_array($char, $unsafe_char)) {
$base64 = true;
break;
}
Expand Down
21 changes: 10 additions & 11 deletions src/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public static function create($dn, array $objectClass = array())
{
if (is_string($dn) || is_array($dn)) {
$dn = Dn::factory($dn);
} else if ($dn instanceof Dn) {
} elseif ($dn instanceof Dn) {
$dn = clone $dn;
} else {
throw new Exception\LdapException(null, '$dn is of a wrong data type.');
Expand All @@ -264,7 +264,7 @@ public static function fromLdap($dn, Ldap $ldap)
{
if (is_string($dn) || is_array($dn)) {
$dn = Dn::factory($dn);
} else if ($dn instanceof Dn) {
} elseif ($dn instanceof Dn) {
$dn = clone $dn;
} else {
throw new Exception\LdapException(null, '$dn is of a wrong data type.');
Expand Down Expand Up @@ -293,7 +293,7 @@ public static function fromArray(array $data, $fromDataSource = false)
}
if (is_string($data['dn']) || is_array($data['dn'])) {
$dn = Dn::factory($data['dn']);
} else if ($data['dn'] instanceof Dn) {
} elseif ($data['dn'] instanceof Dn) {
$dn = clone $data['dn'];
} else {
throw new Exception\LdapException(null, '\'dn\' key is of a wrong data type.');
Expand All @@ -316,7 +316,7 @@ protected function ensureRdnAttributeValues($overwrite = false)
foreach ($this->getRdnArray() as $key => $value) {
if (!array_key_exists($key, $this->currentData) || $overwrite) {
Attribute::setAttribute($this->currentData, $key, $value, false);
} else if (!in_array($value, $this->currentData[$key])) {
} elseif (!in_array($value, $this->currentData[$key])) {
Attribute::setAttribute($this->currentData, $key, $value, true);
}
}
Expand Down Expand Up @@ -393,7 +393,7 @@ public function willBeMoved()
{
if ($this->isNew() || $this->willBeDeleted()) {
return false;
} else if ($this->newDn !== null) {
} elseif ($this->newDn !== null) {
return ($this->dn != $this->newDn);
} else {
return false;
Expand Down Expand Up @@ -605,7 +605,7 @@ public function getChangedData()
foreach ($this->currentData as $key => $value) {
if (!array_key_exists($key, $this->originalData) && !empty($value)) {
$changed[$key] = $value;
} else if ($this->originalData[$key] !== $this->currentData[$key]) {
} elseif ($this->originalData[$key] !== $this->currentData[$key]) {
$changed[$key] = $value;
}
}
Expand All @@ -629,9 +629,9 @@ public function getChanges()
foreach ($this->currentData as $key => $value) {
if (!array_key_exists($key, $this->originalData) && !empty($value)) {
$changes['add'][$key] = $value;
} else if (count($this->originalData[$key]) === 0 && !empty($value)) {
} elseif (count($this->originalData[$key]) === 0 && !empty($value)) {
$changes['add'][$key] = $value;
} else if ($this->originalData[$key] !== $this->currentData[$key]) {
} elseif ($this->originalData[$key] !== $this->currentData[$key]) {
if (empty($value)) {
$changes['delete'][$key] = $value;
} else {
Expand Down Expand Up @@ -812,10 +812,9 @@ protected function assertChangeableAttribute($name)
$rdn = $this->getRdnArray(Dn::ATTR_CASEFOLD_LOWER);
if ($name == 'dn') {
throw new Exception\LdapException(null, 'DN cannot be changed.');
}
else if (array_key_exists($name, $rdn)) {
} elseif (array_key_exists($name, $rdn)) {
throw new Exception\LdapException(null, 'Cannot change attribute because it\'s part of the RDN');
} else if (in_array($name, self::$systemAttributes)) {
} elseif (in_array($name, self::$systemAttributes)) {
throw new Exception\LdapException(null, 'Cannot change attribute because it\'s read-only');
} else {
return true;
Expand Down
3 changes: 1 addition & 2 deletions src/Node/AbstractNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ public function existsAttribute($name, $emptyExists = false)
}

return count($this->currentData[$name]) > 0;
}
else {
} else {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Node/RootDse.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public static function create(Ldap\Ldap $ldap)
$data = $ldap->getEntry($dn, array('*', '+'), true);
if (isset($data['domainfunctionality'])) {
return new RootDse\ActiveDirectory($dn, $data);
} else if (isset($data['dsaname'])) {
} elseif (isset($data['dsaname'])) {
return new RootDse\eDirectory($dn, $data);
} else if (isset($data['structuralobjectclass'])
} elseif (isset($data['structuralobjectclass'])
&& $data['structuralobjectclass'][0] === 'OpenLDAProotDSE'
) {
return new RootDse\OpenLdap($dn, $data);
Expand Down
4 changes: 2 additions & 2 deletions src/Node/Schema/ObjectClass/OpenLdap.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ public function getType()
{
if ($this->structural) {
return Schema::OBJECTCLASS_TYPE_STRUCTURAL;
} else if ($this->abstract) {
} elseif ($this->abstract) {
return Schema::OBJECTCLASS_TYPE_ABSTRACT;
} else if ($this->auxiliary) {
} elseif ($this->auxiliary) {
return Schema::OBJECTCLASS_TYPE_AUXILIARY;
} else {
return Schema::OBJECTCLASS_TYPE_UNKNOWN;
Expand Down
Loading

0 comments on commit 34263bb

Please sign in to comment.