Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman authored and github-actions[bot] committed Oct 18, 2024
1 parent e5b9699 commit 48f64f4
Show file tree
Hide file tree
Showing 32 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/Auth/BindFailureListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function usingLaravelUi(string $controller = 'App\Http\Controllers
/**
* Register the bind failure listener upon resolving the given class.
*/
protected static function whenResolving(string $class, Closure $callback = null): void
protected static function whenResolving(string $class, ?Closure $callback = null): void
{
if (! class_exists($class)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Auth/ListensForLdapBindFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function listenForLdapBindFailure(): void
*
* @throws ValidationException
*/
protected function ldapBindFailed(string $errorMessage, string $diagnosticMessage = null): void
protected function ldapBindFailed(string $errorMessage, ?string $diagnosticMessage = null): void
{
switch (true) {
case $this->causedByLostConnection($errorMessage):
Expand Down Expand Up @@ -98,7 +98,7 @@ protected function ldapBindFailed(string $errorMessage, string $diagnosticMessag
*
* @throws ValidationException
*/
protected function handleLdapBindError(string $message, string $code = null): void
protected function handleLdapBindError(string $message, ?string $code = null): void
{
logger()->error($message, compact('code'));

Expand Down
2 changes: 1 addition & 1 deletion src/Auth/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ interface Rule
/**
* Determine if the rule passes validation.
*/
public function passes(LdapRecord $user, Eloquent $model = null): bool;
public function passes(LdapRecord $user, ?Eloquent $model = null): bool;
}
2 changes: 1 addition & 1 deletion src/Auth/Rules/OnlyImported.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class OnlyImported implements Rule
/**
* {@inheritdoc}
*/
public function passes(LdapRecord $user, Eloquent $model = null): bool
public function passes(LdapRecord $user, ?Eloquent $model = null): bool
{
return $model?->exists;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(iterable $rules = [])
/**
* Determine if all rules pass validation.
*/
public function passes(LdapRecord $user, Eloquent $model = null): bool
public function passes(LdapRecord $user, ?Eloquent $model = null): bool
{
foreach ($this->rules as $rule) {
if (! $rule->passes($user, $model)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Events/Auth/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class Event
/**
* Constructor.
*/
public function __construct(LdapModel $object, EloquentModel $eloquent = null)
public function __construct(LdapModel $object, ?EloquentModel $eloquent = null)
{
$this->object = $object;
$this->eloquent = $eloquent;
Expand Down
2 changes: 1 addition & 1 deletion src/Events/Auth/RuleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class RuleEvent extends Event
/**
* Constructor.
*/
public function __construct(Rule $rule, LdapModel $object, EloquentModel $eloquent = null)
public function __construct(Rule $rule, LdapModel $object, ?EloquentModel $eloquent = null)
{
parent::__construct($object, $eloquent);

Expand Down
2 changes: 1 addition & 1 deletion src/Import/LdapUserImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function trashDisabledUsers(): static
/**
* Load the import's objects from the LDAP repository.
*/
public function loadObjectsFromRepository(string $username = null): Collection
public function loadObjectsFromRepository(?string $username = null): Collection
{
$query = $this->applyLdapQueryConstraints(
$this->repository->query()
Expand Down
2 changes: 1 addition & 1 deletion src/Import/Synchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected function getSyncScopeOperatorAndValue(LdapModel $ldap, array|string $c
/**
* Get the sync scope option from the config array.
*/
protected function getSyncScopeOption(array|string $config, string $option, array|string $default = null): array|string
protected function getSyncScopeOption(array|string $config, string $option, array|string|null $default = null): array|string
{
return is_array($config) ? $config[$option] : $default;
}
Expand Down
6 changes: 3 additions & 3 deletions src/LdapUserAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(array $rules = [])
/**
* Set the authenticating eloquent model.
*/
public function setEloquentModel(Eloquent $model = null): static
public function setEloquentModel(?Eloquent $model = null): static
{
$this->eloquentModel = $model;

Expand All @@ -59,7 +59,7 @@ public function setEloquentModel(Eloquent $model = null): static
/**
* Attempt authenticating against the LDAP domain.
*/
public function attempt(Model $user, string $password = null): bool
public function attempt(Model $user, ?string $password = null): bool
{
$this->attempting($user);

Expand Down Expand Up @@ -95,7 +95,7 @@ public function attempt(Model $user, string $password = null): bool
/**
* Attempt authentication using the given callback once.
*/
public function attemptOnceUsing(Closure $callback, Model $user, string $password = null): bool
public function attemptOnceUsing(Closure $callback, Model $user, ?string $password = null): bool
{
$authenticator = $this->authenticator;

Expand Down
2 changes: 1 addition & 1 deletion src/LdapUserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function getModel(): string
/**
* Get a new query builder for the model instance.
*/
protected function newModelQuery(Model $model = null): Builder
protected function newModelQuery(?Model $model = null): Builder
{
$model = is_null($model) ? $this->createModel() : $model;

Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/UserDomainValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class UserDomainValidator
/**
* Determine if the user passes domain validation.
*/
public function __invoke(Model $user, string $username, string $domain = null): bool
public function __invoke(Model $user, string $username, ?string $domain = null): bool
{
if (empty($domain)) {
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/Middleware/WindowsAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static function validateDomainUsing(Closure|string $callback): void
/**
* Set the callback to resolve users by when retrieving the authenticated user fails.
*/
public static function fallback(Closure|string $callback = null): void
public static function fallback(Closure|string|null $callback = null): void
{
static::$userResolverFallback = $callback;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ protected function authenticate(Request $request, array $guards): void
/**
* Attempt retrieving and logging in the authenticated user.
*/
protected function attempt(array $guards, string $username, string $domain = null): void
protected function attempt(array $guards, string $username, ?string $domain = null): void
{
foreach ($guards as $guard) {
$provider = $this->auth->guard($guard)->getProvider();
Expand Down Expand Up @@ -258,7 +258,7 @@ protected function authenticated(array $guards): bool
/**
* Returns the authenticatable user instance if found.
*/
protected function retrieveAuthenticatedUser(UserProvider $provider, string $username, string $domain = null): ?Authenticatable
protected function retrieveAuthenticatedUser(UserProvider $provider, string $username, ?string $domain = null): ?Authenticatable
{
// First, we will attempt to retrieve the user from the LDAP server
// by their username. If we don't get any result, we can bail
Expand Down Expand Up @@ -346,7 +346,7 @@ protected function getUserFromRepository(LdapUserRepository $repository, string
/**
* Determine if the located user is apart of the domain.
*/
protected function userIsApartOfDomain(Model $user, string $username, string $domain = null): bool
protected function userIsApartOfDomain(Model $user, string $username, ?string $domain = null): bool
{
if (! static::$domainVerification) {
return true;
Expand All @@ -360,7 +360,7 @@ protected function userIsApartOfDomain(Model $user, string $username, string $do
/**
* Handle failure of retrieving the authenticated user.
*/
protected function failedRetrievingUser(UserProvider $provider, string $username, string $domain = null): ?Authenticatable
protected function failedRetrievingUser(UserProvider $provider, string $username, ?string $domain = null): ?Authenticatable
{
if (! static::$userResolverFallback) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/DirectoryEmulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DirectoryEmulator extends DirectoryFake
*
* @throws \LdapRecord\ContainerException
*/
public static function setup(string $name = null, array $config = []): ConnectionFake
public static function setup(?string $name = null, array $config = []): ConnectionFake
{
return tap(parent::setup($name), function (EmulatedConnectionFake $fake) use ($name, $config) {
$fake->name($name);
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/Emulated/EmulatesModelQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait EmulatesModelQueries
/**
* {@inheritdoc}
*/
public function newInstance(string $baseDn = null): static
public function newInstance(?string $baseDn = null): static
{
return (new self($this->connection))
->setModel($this->model)
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/EmulatedConnectionFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class EmulatedConnectionFake extends ConnectionFake
/**
* Get or set the name of the connection fake.
*/
public function name(string $name = null): string|static|null
public function name(?string $name = null): string|static|null
{
if (is_null($name)) {
return $this->name;
Expand Down
4 changes: 2 additions & 2 deletions src/Testing/LdapDatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(DatabaseManager $db)
/**
* Create the eloquent database model.
*/
public function createModel(string $connection = null): Model
public function createModel(?string $connection = null): Model
{
$class = '\\'.ltrim(static::$model, '\\');

Expand All @@ -67,7 +67,7 @@ public function createModel(string $connection = null): Model
/**
* Get the LDAP database connection.
*/
public function connection(string $name = null, array $config = []): Connection
public function connection(?string $name = null, array $config = []): Connection
{
$name = $name ?? Config::get('ldap.default', 'default');

Expand Down
4 changes: 2 additions & 2 deletions src/Testing/LdapObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public static function booted(): void
/**
* Find an object by its distinguished name.
*/
public static function findByDn(string $dn, string $connection = null): ?static
public static function findByDn(string $dn, ?string $connection = null): ?static
{
return static::on($connection)->firstWhere('dn', 'like', $dn);
}

/**
* Find an object by its object guid.
*/
public static function findByGuid(string $guid, string $connection = null): ?static
public static function findByGuid(string $guid, ?string $connection = null): ?static
{
return static::on($connection)->firstWhere('guid', '=', $guid);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Commands/GetRootDseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function test_command_displays_no_attributes_error_when_rootdse_is_empty_

class RootDse extends Entry
{
public function getCreatableDn(string $name = null, string $attribute = null): string
public function getCreatableDn(?string $name = null, ?string $attribute = null): string
{
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Commands/ImportLdapUsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function test_message_is_shown_when_no_users_are_found_for_importing()

$repo = m::mock(LdapUserRepository::class, function ($repo) {
$query = m::mock(Builder::class);
$query->shouldReceive('paginate')->once()->andReturn(new Collection());
$query->shouldReceive('paginate')->once()->andReturn(new Collection);

$repo->shouldReceive('query')->once()->andReturn($query);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/CreatesTestUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait CreatesTestUsers
/**
* Create a new test user.
*/
protected function createTestUser(array $attributes = [], string $model = null): Model
protected function createTestUser(array $attributes = [], ?string $model = null): Model
{
$model = $model ?? TestUserModelStub::class;

Expand Down
10 changes: 5 additions & 5 deletions tests/Feature/DatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ protected function getMockLdapModel(array $attributes = [])
}

protected function createDatabaseUserProvider(
LdapUserRepository $repo = null,
LdapUserAuthenticator $auth = null,
UserSynchronizer $synchronizer = null,
EloquentUserProvider $eloquent = null
?LdapUserRepository $repo = null,
?LdapUserAuthenticator $auth = null,
?UserSynchronizer $synchronizer = null,
?EloquentUserProvider $eloquent = null
) {
return new DatabaseUserProvider(
$repo ?? $this->createLdapUserRepository(),
Expand All @@ -77,7 +77,7 @@ protected function createLdapUserRepository($model = null)

protected function createLdapUserAuthenticator()
{
return new LdapUserAuthenticator();
return new LdapUserAuthenticator;
}

protected function createLdapUserSynchronizer($eloquentModel = null, array $config = [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function test_database_authentication_fallback_is_not_performed_when_fall

class TestEmulatorUserModelStub extends User implements LdapAuthenticatable
{
use SoftDeletes, AuthenticatesWithLdap, HasLdapUser;
use AuthenticatesWithLdap, HasLdapUser, SoftDeletes;

protected $guarded = [];

Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/ListenForLdapBindFailureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ public function test_validation_exception_is_not_thrown_until_all_connection_hos
LdapFake::operation('bind')
->with('user', 'secret')
->once()
->andReturn(new LdapResultResponse()),
->andReturn(new LdapResultResponse),

// Bind is attempted with the authenticating user and passes.
LdapFake::operation('bind')
->with('cn=jdoe,dc=local,dc=com', 'secret')
->once()
->andReturn(new LdapResultResponse()),
->andReturn(new LdapResultResponse),

// Rebind is attempted with configured user account.
LdapFake::operation('bind')
Expand All @@ -85,7 +85,7 @@ public function test_validation_exception_is_not_thrown_until_all_connection_hos

LdapFake::operation('parseResult')
->once()
->andReturn(new LdapResultResponse()),
->andReturn(new LdapResultResponse),
])->shouldReturnError("Can't contact LDAP server");

$result = Auth::attempt([
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/NoDatabaseUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function test_retrieve_by_id_returns_model_instance()

$repo->shouldReceive('findByGuid')->once()->withArgs(['id'])->andReturn($model);

$provider = new NoDatabaseUserProvider($repo, new LdapUserAuthenticator());
$provider = new NoDatabaseUserProvider($repo, new LdapUserAuthenticator);

$this->assertSame($model, $provider->retrieveById('id'));
}
Expand All @@ -61,7 +61,7 @@ public function test_retrieve_by_credentials_returns_model_instance()

$repo->shouldReceive('findByCredentials')->once()->withArgs([['username' => 'foo']])->andReturn($model);

$provider = new NoDatabaseUserProvider($repo, new LdapUserAuthenticator());
$provider = new NoDatabaseUserProvider($repo, new LdapUserAuthenticator);

$this->assertSame($model, $provider->retrieveByCredentials(['username' => 'foo']));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/TestUserModelStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class TestUserModelStub extends User implements LdapAuthenticatable
{
use SoftDeletes, AuthenticatesWithLdap, HasLdapUser;
use AuthenticatesWithLdap, HasLdapUser, SoftDeletes;

protected $guarded = [];

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/WindowsAuthMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public function test_fallback_is_used_when_failing_to_retrieve_user()

class WindowsAuthRuleStub implements Rule
{
public function passes(Model $user, Eloquent $model = null): bool
public function passes(Model $user, ?Eloquent $model = null): bool
{
$_SERVER[self::class] = true;

Expand Down
Loading

0 comments on commit 48f64f4

Please sign in to comment.