Skip to content

Commit

Permalink
Remaining CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Apr 17, 2023
1 parent 4bf65c9 commit 29e1685
Show file tree
Hide file tree
Showing 40 changed files with 253 additions and 270 deletions.
4 changes: 2 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ protected function configure(): void
$this->configuration->get('options'),
[
LDAP_OPT_PROTOCOL_VERSION => $this->configuration->get('version'),
LDAP_OPT_NETWORK_TIMEOUT => $this->configuration->get('timeout'),
LDAP_OPT_REFERRALS => $this->configuration->get('follow_referrals'),
LDAP_OPT_NETWORK_TIMEOUT => $this->configuration->get('timeout'),
LDAP_OPT_REFERRALS => $this->configuration->get('follow_referrals'),
]
));
}
Expand Down
4 changes: 0 additions & 4 deletions src/Events/NullDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public function hasListeners(string $event): bool

/**
* Fire an event until the first non-null response is returned.
*
* @return null
*/
public function until(string|object $event, mixed $payload = []): ?array
{
Expand All @@ -45,8 +43,6 @@ public function until(string|object $event, mixed $payload = []): ?array

/**
* Fire an event and call the listeners.
*
* @return null
*/
public function fire(string|object $event, mixed $payload = [], bool $halt = false): void
{
Expand Down
4 changes: 2 additions & 2 deletions src/Models/ActiveDirectory/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class Entry extends BaseEntry implements ActiveDirectory
* The default attributes that should be mutated to dates.
*/
protected array $defaultDates = [
'whenchanged' => 'windows',
'whencreated' => 'windows',
'whenchanged' => 'windows',
'whencreated' => 'windows',
'dscorepropagationdata' => 'windows',
];

Expand Down
12 changes: 6 additions & 6 deletions src/Models/ActiveDirectory/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ class User extends Entry implements Authenticatable
* The attributes that should be mutated to dates.
*/
protected array $dates = [
'lastlogon' => 'windows-int',
'lastlogoff' => 'windows-int',
'pwdlastset' => 'windows-int',
'lockouttime' => 'windows-int',
'accountexpires' => 'windows-int',
'badpasswordtime' => 'windows-int',
'lastlogon' => 'windows-int',
'lastlogoff' => 'windows-int',
'pwdlastset' => 'windows-int',
'lockouttime' => 'windows-int',
'accountexpires' => 'windows-int',
'badpasswordtime' => 'windows-int',
'lastlogontimestamp' => 'windows-int',
];

Expand Down
30 changes: 15 additions & 15 deletions src/Models/Attributes/TSPropertyArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ class TSPropertyArray
* @var array
*/
public const DEFAULTS = [
'CtxCfgPresent' => 2953518677,
'CtxWFProfilePath' => '',
'CtxWFProfilePathW' => '',
'CtxWFHomeDir' => '',
'CtxWFHomeDirW' => '',
'CtxWFHomeDirDrive' => '',
'CtxWFHomeDirDriveW' => '',
'CtxShadow' => 1,
'CtxCfgPresent' => 2953518677,
'CtxWFProfilePath' => '',
'CtxWFProfilePathW' => '',
'CtxWFHomeDir' => '',
'CtxWFHomeDirW' => '',
'CtxWFHomeDirDrive' => '',
'CtxWFHomeDirDriveW' => '',
'CtxShadow' => 1,
'CtxMaxDisconnectionTime' => 0,
'CtxMaxConnectionTime' => 0,
'CtxMaxIdleTime' => 0,
'CtxWorkDirectory' => '',
'CtxWorkDirectoryW' => '',
'CtxCfgFlags1' => 2418077696,
'CtxInitialProgram' => '',
'CtxInitialProgramW' => '',
'CtxMaxConnectionTime' => 0,
'CtxMaxIdleTime' => 0,
'CtxWorkDirectory' => '',
'CtxWorkDirectoryW' => '',
'CtxCfgFlags1' => 2418077696,
'CtxInitialProgram' => '',
'CtxInitialProgramW' => '',
];

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Models/Attributes/Timestamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public function fromDateTime(mixed $value): float|int|string
}

return match ($this->type) {
'ldap' => $this->convertDateTimeToLdapTime($value),
'windows' => $this->convertDateTimeToWindows($value),
'ldap' => $this->convertDateTimeToLdapTime($value),
'windows' => $this->convertDateTimeToWindows($value),
'windows-int' => $this->convertDateTimeToWindowsInteger($value),
default => throw new LdapRecordException("Unrecognized date type [{$this->type}]"),
default => throw new LdapRecordException("Unrecognized date type [{$this->type}]"),
};
}

Expand All @@ -113,10 +113,10 @@ public function toDateTime(mixed $value): Carbon|int|false
}

$value = match ($this->type) {
'ldap' => $this->convertLdapTimeToDateTime($value),
'windows' => $this->convertWindowsTimeToDateTime($value),
'ldap' => $this->convertLdapTimeToDateTime($value),
'windows' => $this->convertWindowsTimeToDateTime($value),
'windows-int' => $this->convertWindowsIntegerTimeToDateTime($value),
default => throw new LdapRecordException("Unrecognized date type [{$this->type}]"),
default => throw new LdapRecordException("Unrecognized date type [{$this->type}]"),
};

return $value instanceof DateTime ? Carbon::instance($value) : $value;
Expand Down
6 changes: 3 additions & 3 deletions src/Models/BatchModification.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function get(): ?array
// A values key cannot be provided when
// a remove all type is selected.
return [
static::KEY_ATTRIB => $this->attribute,
static::KEY_ATTRIB => $this->attribute,
static::KEY_MODTYPE => $this->type,
];
case LDAP_MODIFY_BATCH_REMOVE:
Expand All @@ -228,9 +228,9 @@ public function get(): ?array
// Fallthrough.
case LDAP_MODIFY_BATCH_REPLACE:
return [
static::KEY_ATTRIB => $this->attribute,
static::KEY_ATTRIB => $this->attribute,
static::KEY_MODTYPE => $this->type,
static::KEY_VALUES => $this->values,
static::KEY_VALUES => $this->values,
];
default:
// If the modtype isn't recognized, we'll return null.
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@ public function fromJson(string $value, bool $asObject = false)
public function fromFloat(float $value): float
{
return match ((string) $value) {
'NaN' => NAN,
'Infinity' => INF,
'NaN' => NAN,
'Infinity' => INF,
'-Infinity' => -INF,
default => $value,
default => $value,
};
}

Expand Down
18 changes: 5 additions & 13 deletions src/Models/Concerns/SerializesProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ trait SerializesProperties

/**
* Prepare the attributes for serialization.
*
* @return array
*/
public function __sleep()
public function __sleep(): array
{
$properties = (new ReflectionClass($this))->getProperties();

Expand All @@ -32,10 +30,8 @@ public function __sleep()

/**
* Restore the attributes after serialization.
*
* @return void
*/
public function __wakeup()
public function __wakeup(): void
{
foreach ((new ReflectionClass($this))->getProperties() as $property) {
if ($property->isStatic()) {
Expand All @@ -51,10 +47,8 @@ public function __wakeup()

/**
* Prepare the model for serialization.
*
* @return array
*/
public function __serialize()
public function __serialize(): array
{
$values = [];

Expand Down Expand Up @@ -92,10 +86,8 @@ public function __serialize()

/**
* Restore the model after serialization.
*
* @return void
*/
public function __unserialize(array $values)
public function __unserialize(array $values): void
{
$properties = (new ReflectionClass($this))->getProperties();

Expand Down Expand Up @@ -130,7 +122,7 @@ public function __unserialize(array $values)
/**
* Get the property value for the given property.
*/
protected function getPropertyValue(ReflectionProperty $property)
protected function getPropertyValue(ReflectionProperty $property): mixed
{
$property->setAccessible(true);

Expand Down
2 changes: 1 addition & 1 deletion src/Models/FreeIPA/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Entry extends BaseEntry implements FreeIPA
* The default attributes that should be mutated to dates.
*/
protected array $defaultDates = [
'krblastpwdchange' => 'ldap',
'krblastpwdchange' => 'ldap',
'krbpasswordexpiration' => 'ldap',
];

Expand Down
2 changes: 0 additions & 2 deletions src/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ public function setDn(string $dn = null): static

/**
* A mutator for setting the models distinguished name.
*
* @return $this
*/
public function setDnAttribute(string $dn): static
{
Expand Down
2 changes: 0 additions & 2 deletions src/Models/ModelDoesNotExistException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class ModelDoesNotExistException extends LdapRecordException

/**
* Create a new exception for the given model.
*
* @return ModelDoesNotExistException
*/
public static function forModel(Model $model): static
{
Expand Down
7 changes: 4 additions & 3 deletions src/Query/ArrayCacheStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LdapRecord\Query;

use DateInterval;
use Psr\SimpleCache\CacheInterface;

class ArrayCacheStore implements CacheInterface
Expand Down Expand Up @@ -38,10 +39,10 @@ public function get(string $key, mixed $default = null): mixed
/**
* {@inheritdoc}
*/
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool
public function set(string $key, mixed $value, null|int|DateInterval $ttl = null): bool
{
$this->storage[$key] = [
'value' => $value,
'value' => $value,
'expiresAt' => $this->calculateExpiration($ttl),
];

Expand Down Expand Up @@ -101,7 +102,7 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable
/**
* {@inheritdoc}
*/
public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool
public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
{
foreach ($values as $key => $value) {
$this->set($key, $value, $ttl);
Expand Down
30 changes: 15 additions & 15 deletions src/Query/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ class Grammar
* The query operators and their method names.
*/
public array $operators = [
'*' => 'has',
'!*' => 'notHas',
'=' => 'equals',
'!' => 'doesNotEqual',
'!=' => 'doesNotEqual',
'>=' => 'greaterThanOrEquals',
'<=' => 'lessThanOrEquals',
'~=' => 'approximatelyEquals',
'starts_with' => 'startsWith',
'*' => 'has',
'!*' => 'notHas',
'=' => 'equals',
'!' => 'doesNotEqual',
'!=' => 'doesNotEqual',
'>=' => 'greaterThanOrEquals',
'<=' => 'lessThanOrEquals',
'~=' => 'approximatelyEquals',
'starts_with' => 'startsWith',
'not_starts_with' => 'notStartsWith',
'ends_with' => 'endsWith',
'not_ends_with' => 'notEndsWith',
'contains' => 'contains',
'not_contains' => 'notContains',
'ends_with' => 'endsWith',
'not_ends_with' => 'notEndsWith',
'contains' => 'contains',
'not_contains' => 'notContains',
];

/**
Expand Down Expand Up @@ -63,8 +63,8 @@ public function compile(Builder $query): string
.$this->compileOrWheres($query);

return match ($this->wrapper) {
'and' => $this->compileAnd($filter),
'or' => $this->compileOr($filter),
'and' => $this->compileAnd($filter),
'or' => $this->compileOr($filter),
default => $filter,
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function updateServerControls(LdapInterface $ldap, mixed $resource): v
$cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? '';

$this->query->controls[LDAP_CONTROL_PAGEDRESULTS]['value'] = [
'size' => $this->perPage,
'size' => $this->perPage,
'cookie' => $cookie,
];
}
Expand Down
8 changes: 4 additions & 4 deletions src/Query/Slice.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ public function toArray(): array
{
return [
'current_page' => $this->currentPage(),
'data' => $this->getArrayableItems(),
'last_page' => $this->lastPage(),
'per_page' => $this->perPage(),
'total' => $this->total(),
'data' => $this->getArrayableItems(),
'last_page' => $this->lastPage(),
'per_page' => $this->perPage(),
'total' => $this->total(),
];
}
}
2 changes: 0 additions & 2 deletions src/Testing/LdapExpectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ public function getExpectedArgs(): array

/**
* Get the expected exception.
*
* @return null|\Exception|LdapRecordException
*/
public function getExpectedException(): ?Exception
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function createGroup(array $attributes = []): Group
$group = (new Group())
->inside($this->ou)
->fill(array_merge([
'cn' => 'Foo',
'cn' => 'Foo',
'gidNumber' => 500,
], $attributes));

Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class TestCase extends BaseTestCase
protected function makeConnection(array $params = []): Connection
{
return new Connection(array_merge([
'hosts' => ['localhost'],
'base_dn' => 'dc=local,dc=com',
'hosts' => ['localhost'],
'base_dn' => 'dc=local,dc=com',
'username' => 'cn=admin,dc=local,dc=com',
'password' => 'secret',
'use_ssl' => true,
'use_ssl' => true,
], $params));
}
}
12 changes: 6 additions & 6 deletions tests/Integration/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ protected function createUser(array $attributes = []): User
$user = (new User())
->inside($this->ou)
->fill(array_merge([
'uid' => 'fbar',
'cn' => 'Foo',
'sn' => 'Bar',
'givenName' => 'Foo',
'uidNumber' => 1000,
'gidNumber' => 1000,
'uid' => 'fbar',
'cn' => 'Foo',
'sn' => 'Bar',
'givenName' => 'Foo',
'uidNumber' => 1000,
'gidNumber' => 1000,
'homeDirectory' => '/foo',
], $attributes));

Expand Down
Loading

0 comments on commit 29e1685

Please sign in to comment.