Skip to content

Commit

Permalink
Merge pull request #590 from DirectoryTree/analysis-lZE6WJ
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI

[ci skip] [skip ci]
  • Loading branch information
stevebauman committed Apr 17, 2023
2 parents 7e0d9dd + e0b8631 commit ca014b0
Show file tree
Hide file tree
Showing 71 changed files with 445 additions and 437 deletions.
4 changes: 2 additions & 2 deletions src/Auth/Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function attempt(string $username, string $password, bool $stayBound = fa
$authenticated = false;
}

if (! $stayBound) {
if (!$stayBound) {
$this->bindAsConfiguredUser();
}

Expand All @@ -80,7 +80,7 @@ public function bind(string $username = null, string $password = null): void
// Prior to binding, we will upgrade our connectivity to TLS on our current
// connection and ensure we are not already bound before upgrading.
// This is to prevent subsequent upgrading on several binds.
if ($this->connection->isUsingTLS() && ! $this->connection->isBound()) {
if ($this->connection->isUsingTLS() && !$this->connection->isBound()) {
$this->connection->startTLS();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/DomainConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function set(string $key, mixed $value): void
*/
public function get(string $key): mixed
{
if (! $this->has($key)) {
if (!$this->has($key)) {
throw new ConfigurationException("Option {$key} does not exist.");
}

Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/Validators/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract public function passes(): bool;
*/
public function validate(): bool
{
if (! $this->passes()) {
if (!$this->passes()) {
$this->fail();
}

Expand Down
12 changes: 6 additions & 6 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(DomainConfiguration|array $config = [], LdapInterfac
*/
public function setConfiguration(DomainConfiguration|array $config = []): static
{
if (! $config instanceof DomainConfiguration) {
if (!$config instanceof DomainConfiguration) {
$config = new DomainConfiguration($config);
}

Expand Down 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 Expand Up @@ -253,7 +253,7 @@ protected function reinitialize(): void
*/
public function replicate(): static
{
return new static($this->configuration, new $this->ldap);
return new static($this->configuration, new $this->ldap());
}

/**
Expand Down Expand Up @@ -291,7 +291,7 @@ public function run(Closure $operation): mixed
// Before running the operation, we will check if the current
// connection is bound and connect if necessary. Otherwise,
// some LDAP operations will not be executed properly.
if (! $this->isConnected()) {
if (!$this->isConnected()) {
$this->connect();
}

Expand Down Expand Up @@ -349,7 +349,7 @@ protected function runOperationCallback(Closure $operation): mixed
*/
public function auth(): Guard
{
if (! $this->ldap->isConnected()) {
if (!$this->ldap->isConnected()) {
$this->initialize();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function dispatch(string|object $event, mixed $payload = [], $halt = fals
// If a response is returned from the listener and event halting is enabled
// we will just return this response, and not call the rest of the event
// listeners. Otherwise we will add the response on the response list.
if ($halt && ! is_null($response)) {
if ($halt && !is_null($response)) {
return $response;
}

Expand Down
4 changes: 2 additions & 2 deletions src/HandlesConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function isBound(): bool
*/
public function isConnected(): bool
{
return ! is_null($this->connection);
return !is_null($this->connection);
}

/**
Expand Down Expand Up @@ -150,7 +150,7 @@ protected function executeFailableOperation(Closure $operation): mixed
// exceptions, which could be a significant detriment to our application.
// Here, we will enforce these operations to throw exceptions instead.
set_error_handler(function (int $severity, string $message, string $file, int $line): bool {
if (! $this->shouldBypassError($message)) {
if (!$this->shouldBypassError($message)) {
throw new ErrorException($message, $severity, $severity, $file, $line);
}

Expand Down
19 changes: 12 additions & 7 deletions src/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class Ldap implements LdapInterface
{
use HandlesConnection, DetectsErrors;
use HandlesConnection;
use DetectsErrors;

/**
* {@inheritdoc}
Expand All @@ -23,7 +24,7 @@ public function getEntries(mixed $result): array
*
* @see http://php.net/manual/en/function.ldap-first-entry.php
*
* @param \Ldap\Result $result
* @param \Ldap\Result $result
*/
public function getFirstEntry(mixed $result): mixed
{
Expand All @@ -37,7 +38,7 @@ public function getFirstEntry(mixed $result): mixed
*
* @see http://php.net/manual/en/function.ldap-next-entry.php
*
* @param \Ldap\ResultEntry $entry
* @param \Ldap\ResultEntry $entry
*/
public function getNextEntry(mixed $entry): mixed
{
Expand All @@ -51,7 +52,7 @@ public function getNextEntry(mixed $entry): mixed
*
* @see http://php.net/manual/en/function.ldap-get-attributes.php
*
* @param \Ldap\ResultEntry $entry
* @param \Ldap\ResultEntry $entry
*/
public function getAttributes(mixed $entry): array|false
{
Expand Down Expand Up @@ -85,7 +86,7 @@ public function compare(string $dn, string $attribute, string $value, array $con
*/
public function getLastError(): ?string
{
if (! $this->connection) {
if (!$this->connection) {
return null;
}

Expand All @@ -97,7 +98,7 @@ public function getLastError(): ?string
*/
public function getDetailedError(): ?DetailedError
{
if (! $number = $this->errNo()) {
if (!$number = $this->errNo()) {
return null;
}

Expand Down Expand Up @@ -252,7 +253,11 @@ public function parseResult(mixed $result, int &$errorCode = 0, string &$dn = nu
{
if (ldap_parse_result($this->connection, $result, $errorCode, $dn, $errorMessage, $referrals, $controls)) {
return new LdapResultResponse(
$errorCode, $dn, $errorMessage, $referrals, $controls
$errorCode,
$dn,
$errorMessage,
$referrals,
$controls
);
}

Expand Down
16 changes: 8 additions & 8 deletions src/LdapInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function getConnection(): ?Connection;
*
* @see http://php.net/manual/en/function.ldap-get-entries.php
*
* @param \LDAP\Result $result
* @param \LDAP\Result $result
*/
public function getEntries(mixed $result): array;

Expand All @@ -144,7 +144,7 @@ public function getEntries(mixed $result): array;
*
* @see https://www.php.net/manual/en/function.ldap-first-entry.php
*
* @param \LDAP\Result $result
* @param \LDAP\Result $result
*/
public function getFirstEntry(mixed $result): mixed;

Expand All @@ -153,7 +153,7 @@ public function getFirstEntry(mixed $result): mixed;
*
* @see https://www.php.net/manual/en/function.ldap-next-entry.php
*
* @param \LDAP\Result $entry
* @param \LDAP\Result $entry
*/
public function getNextEntry(mixed $entry): mixed;

Expand All @@ -162,14 +162,14 @@ public function getNextEntry(mixed $entry): mixed;
*
* @see https://www.php.net/manual/en/function.ldap-get-attributes.php
*
* @param \LDAP\Result $entry
* @param \LDAP\Result $entry
*/
public function getAttributes(mixed $entry): array|false;

/**
* Reads all the values of the attribute in the entry in the result.
*
* @param \LDAP\Result $entry
* @param \LDAP\Result $entry
*/
public function getValuesLen(mixed $entry, string $attribute): array|false;

Expand All @@ -194,7 +194,7 @@ public function getDetailedError(): ?DetailedError;
*
* @see https://www.php.net/manual/en/function.ldap-count-entries.php
*
* @param \LDAP\Result $result
* @param \LDAP\Result $result
*/
public function countEntries(mixed $result): int;

Expand Down Expand Up @@ -286,7 +286,7 @@ public function read(string $dn, string $filter, array $fields, bool $onlyAttrib
*
* @see https://www.php.net/manual/en/function.ldap-parse-result.php
*
* @param \LDAP\Result $result
* @param \LDAP\Result $result
*/
public function parseResult(mixed $result, int &$errorCode = 0, string &$dn = null, string &$errorMessage = null, array &$referrals = null, array &$controls = null): LdapResultResponse|false;

Expand Down Expand Up @@ -377,7 +377,7 @@ public function modDelete(string $dn, array $entry): bool;
*
* @see https://www.php.net/manual/en/function.ldap-free-result.php
*
* @param \LDAP\Result $result
* @param \LDAP\Result $result
*/
public function freeResult(mixed $result): bool;

Expand Down
2 changes: 1 addition & 1 deletion src/LdapResultResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public function successful(): bool
*/
public function failed(): bool
{
return ! $this->successful();
return !$this->successful();
}
}
6 changes: 3 additions & 3 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 Expand Up @@ -103,7 +103,7 @@ public function isDeleted(): bool
*/
public function restore(string $newParentDn = null): bool
{
if (! $this->isDeleted()) {
if (!$this->isDeleted()) {
return false;
}

Expand Down
18 changes: 9 additions & 9 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 All @@ -71,7 +71,7 @@ protected static function boot(): void
*/
public function isEnabled(): bool
{
return ! $this->isDisabled();
return !$this->isDisabled();
}

/**
Expand Down Expand Up @@ -148,14 +148,14 @@ public function isLockedOut(string|int $localTimezone, int $durationInMinutes =
{
$time = $this->getFirstAttribute('lockouttime');

if (! $time instanceof Carbon) {
if (!$time instanceof Carbon) {
return false;
}

is_int($localTimezone)
? $time->addMinutes($localTimezone)
: $time->setTimezone($localTimezone)->addMinutes($durationInMinutes ?: 0);

return ! $time->isPast();
return !$time->isPast();
}
}
6 changes: 3 additions & 3 deletions src/Models/Attributes/AccountControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AccountControl
*/
public function __construct(int $flag = null)
{
if (! is_null($flag)) {
if (!is_null($flag)) {
$this->apply($flag);
}
}
Expand Down Expand Up @@ -134,7 +134,7 @@ public function has(int $flag): bool
*/
public function doesntHave(int $flag): bool
{
return ! $this->has($flag);
return !$this->has($flag);
}

/**
Expand Down Expand Up @@ -367,7 +367,7 @@ public function getValues(): array
/**
* Set the account control values.
*
* @param array<int, int> $flags
* @param array<int, int> $flags
*/
public function setValues(array $flags): void
{
Expand Down
8 changes: 4 additions & 4 deletions src/Models/Attributes/DistinguishedName.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function make(string $value = null): static
*/
public static function isValid(string $value = null): bool
{
return ! static::make($value)->isEmpty();
return !static::make($value)->isEmpty();
}

/**
Expand All @@ -69,11 +69,11 @@ public static function explode(string $dn): array
{
$components = ldap_explode_dn($dn, (int) $withoutAttributes = false);

if (! is_array($components)) {
if (!is_array($components)) {
return [];
}

if (! array_key_exists('count', $components)) {
if (!array_key_exists('count', $components)) {
return [];
}

Expand Down Expand Up @@ -301,7 +301,7 @@ public function isDescendantOf(self $ancestor): bool
return false;
}

if (! $length = count($components) - count($ancestorComponents)) {
if (!$length = count($components) - count($ancestorComponents)) {
return false;
}

Expand Down
7 changes: 4 additions & 3 deletions src/Models/Attributes/Guid.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ protected function binaryGuidToString(string $binary = null): ?string
*
* @see https://github.com/ldaptools/ldaptools
*
* @param string $hex The full hex string.
* @param array $sections An array of start and length (unless octet is true, then length is always 2).
* @param bool $octet Whether this is for octet string form.
* @param string $hex The full hex string.
* @param array $sections An array of start and length (unless octet is true, then length is always 2).
* @param bool $octet Whether this is for octet string form.
*
* @return string The concatenated sections in upper-case.
*/
protected function parseSection(string $hex, array $sections, bool $octet = false): string
Expand Down
Loading

0 comments on commit ca014b0

Please sign in to comment.