Skip to content

Commit

Permalink
Apply CS fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadSikorra committed Aug 7, 2023
1 parent 2be8bd1 commit fa0900d
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/Control/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Control implements ProtocolElementInterface, Stringable
public function __construct(
protected string $controlType,
protected bool $criticality = false,
protected AbstractType|ProtocolElementInterface|string|null $controlValue = null
protected AbstractType | ProtocolElementInterface | string | null $controlValue = null
) {
}

Expand Down
5 changes: 3 additions & 2 deletions src/FreeDSx/Ldap/LdapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use FreeDSx\Ldap\Search\Vlv;
use FreeDSx\Ldap\Sync\SyncRepl;
use FreeDSx\Sasl\Exception\SaslException;
use SensitiveParameter;
use Stringable;

/**
Expand Down Expand Up @@ -74,7 +75,7 @@ public function __construct(
*/
public function bind(
string $username,
#[\SensitiveParameter]
#[SensitiveParameter]
string $password,
): LdapMessageResponse {
return $this->sendAndReceive(
Expand All @@ -93,7 +94,7 @@ public function bind(
* @throws SaslException
*/
public function bindSasl(
#[\SensitiveParameter]
#[SensitiveParameter]
array $options = [],
string $mechanism = ''
): LdapMessageResponse {
Expand Down
5 changes: 3 additions & 2 deletions src/FreeDSx/Ldap/Operation/Request/SearchRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public function useReferralHandler(?Closure $referralHandler): self
*/
public function useCancelStrategy(string $strategy): self
{
if ($strategy !== self::CANCEL_STOP && $strategy!== self::CANCEL_CONTINUE) {
if ($strategy !== self::CANCEL_STOP && $strategy !== self::CANCEL_CONTINUE) {
throw new UnexpectedValueException(sprintf(
'The cancel strategy must be one of: %s',
implode(
Expand Down Expand Up @@ -387,7 +387,8 @@ public static function fromAsn1(AbstractType $type): self
}
$filter = FilterFactory::get($filter);

if (!($baseDn instanceof OctetStringType
if (
!($baseDn instanceof OctetStringType
&& $scope instanceof EnumeratedType
&& $deref instanceof EnumeratedType
&& $sizeLimit instanceof IntegerType
Expand Down
3 changes: 2 additions & 1 deletion src/FreeDSx/Ldap/Operation/Request/SimpleBindRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use FreeDSx\Asn1\Asn1;
use FreeDSx\Asn1\Type\AbstractType;
use FreeDSx\Ldap\Exception\BindException;
use SensitiveParameter;

/**
* Represents a simple bind request consisting of a username (dn, etc) and a password.
Expand All @@ -34,7 +35,7 @@ class SimpleBindRequest extends BindRequest

public function __construct(
string $username,
#[\SensitiveParameter]
#[SensitiveParameter]
string $password,
int $version = 3
) {
Expand Down
3 changes: 2 additions & 1 deletion src/FreeDSx/Ldap/Operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use FreeDSx\Ldap\Protocol\ProtocolElementInterface;
use FreeDSx\Ldap\Search\Filter\FilterInterface;
use FreeDSx\Ldap\Search\Filters;
use SensitiveParameter;
use Stringable;

/**
Expand Down Expand Up @@ -68,7 +69,7 @@ public static function add(Entry $entry): AddRequest
*/
public static function bind(
string $username,
#[\SensitiveParameter]
#[SensitiveParameter]
string $password,
): SimpleBindRequest {
return new SimpleBindRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use FreeDSx\Ldap\Operation\ResultCode;
use FreeDSx\Ldap\Protocol\LdapMessageRequest;
use FreeDSx\Ldap\Protocol\LdapMessageResponse;
use FreeDSx\Ldap\Protocol\Queue\ClientQueue;
use FreeDSx\Ldap\Protocol\ReferralContext;
use FreeDSx\Ldap\ReferralChaserInterface;
use FreeDSx\Ldap\Search\Filters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
private readonly string $strategy = SearchRequest::CANCEL_STOP,
?Closure $messageProcessor = null,
) {
$this->messageProcessor = $messageProcessor ?? fn() => null;
$this->messageProcessor = $messageProcessor ?? fn () => null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function forResponse(
return new ClientProtocolHandler\ClientBasicHandler($this->queue());
}
}

private function queue(): ClientQueue
{
return $this->queueInstantiator->make();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use FreeDSx\Ldap\Operation\Request\BindRequest;
use FreeDSx\Ldap\Operation\Request\SimpleBindRequest;
use FreeDSx\Ldap\Operation\ResultCode;
use FreeDSx\Ldap\Protocol\Factory\ResponseFactory;
use FreeDSx\Ldap\Protocol\LdapMessageRequest;
use FreeDSx\Ldap\Protocol\Queue\ServerQueue;
use FreeDSx\Ldap\Server\RequestHandler\RequestHandlerInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use FreeDSx\Ldap\Operation\Request\ModifyRequest;
use FreeDSx\Ldap\Operation\Request\SearchRequest;
use FreeDSx\Ldap\Server\RequestContext;
use SensitiveParameter;

/**
* This allows the LDAP server to run, but rejects everything. You can extend and selectively override specific request
Expand All @@ -44,7 +45,7 @@ public function add(

public function bind(
string $username,
#[\SensitiveParameter]
#[SensitiveParameter]
string $password,
): bool {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use FreeDSx\Ldap\Operation\Request\SearchRequest;
use FreeDSx\Ldap\Operation\ResultCode;
use FreeDSx\Ldap\Server\RequestContext;
use SensitiveParameter;

/**
* Proxies requests to an LDAP server and returns the response. You should extend this to add your own constructor and
Expand All @@ -51,7 +52,7 @@ public function __construct(ClientOptions $options = new ClientOptions())
*/
public function bind(
string $username,
#[\SensitiveParameter]
#[SensitiveParameter]
string $password,
): bool {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use FreeDSx\Ldap\Operation\Request\ModifyRequest;
use FreeDSx\Ldap\Operation\Request\SearchRequest;
use FreeDSx\Ldap\Server\RequestContext;
use SensitiveParameter;

/**
* Handler methods for LDAP server requests.
Expand Down Expand Up @@ -110,7 +111,7 @@ public function search(
*/
public function bind(
string $username,
#[\SensitiveParameter]
#[SensitiveParameter]
string $password,
): bool;
}
4 changes: 3 additions & 1 deletion src/FreeDSx/Ldap/Server/Token/BindToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace FreeDSx\Ldap\Server\Token;

use SensitiveParameter;

/**
* Represents a username/password token that is bound and authorized.
*
Expand All @@ -28,7 +30,7 @@ class BindToken implements TokenInterface

public function __construct(
string $username,
#[\SensitiveParameter]
#[SensitiveParameter]
string $password,
int $version = 3
) {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/FreeDSx/Ldap/Search/PagingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testPagingAllWhenEntryHandlerIsUsed(): void
),
'cn'
);
$operation->useEntryHandler(fn(EntryResult $result)=> $entries->add($result->getEntry()));
$operation->useEntryHandler(fn (EntryResult $result) => $entries->add($result->getEntry()));

$this->paging = $this->client->paging($operation);

Expand Down
1 change: 0 additions & 1 deletion tests/spec/FreeDSx/Ldap/ContainerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use FreeDSx\Ldap\LdapClient;
use FreeDSx\Ldap\Protocol\ClientProtocolHandler;
use FreeDSx\Ldap\Protocol\Factory\ClientProtocolHandlerFactory;
use FreeDSx\Ldap\Protocol\Factory\ServerProtocolHandlerFactory;
use FreeDSx\Ldap\Protocol\Queue\ClientQueueInstantiator;
use FreeDSx\Ldap\Protocol\RootDseLoader;
use FreeDSx\Ldap\Protocol\ServerAuthorization;
Expand Down
1 change: 0 additions & 1 deletion tests/spec/FreeDSx/Ldap/LdapClientSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use FreeDSx\Ldap\Entry\Entries;
use FreeDSx\Ldap\Entry\Entry;
use FreeDSx\Ldap\Exception\OperationException;
use FreeDSx\Ldap\LdapClient;
use FreeDSx\Ldap\Operation\LdapResult;
use FreeDSx\Ldap\Operation\Request\ExtendedRequest;
use FreeDSx\Ldap\Operation\Request\SimpleBindRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace spec\FreeDSx\Ldap\Protocol\ClientProtocolHandler;

use FreeDSx\Ldap\ClientOptions;
use FreeDSx\Ldap\Exception\BindException;
use FreeDSx\Ldap\Operation\LdapResult;
use FreeDSx\Ldap\Operation\Request\CompareRequest;
Expand Down Expand Up @@ -55,7 +54,7 @@ public function it_should_implement_RequestHandlerInterface(): void
$this->shouldBeAnInstanceOf(RequestHandlerInterface::class);
}

public function it_should_handle_a_request_and_return_a_response(ClientQueue $queue,): void
public function it_should_handle_a_request_and_return_a_response(ClientQueue $queue, ): void
{
$queue->sendMessage(Argument::type(LdapMessageRequest::class))->shouldBeCalledOnce();
$queue->getMessage(1)->willReturn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function let(
->willReturn(
Entry::fromArray(
'',
['supportedSaslMechanisms' => ['DIGEST-MD5', 'CRAM-MD5'],]
['supportedSaslMechanisms' => ['DIGEST-MD5', 'CRAM-MD5'], ]
)
);
$queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class MockCancelResponseProcessor
{
public function __invoke(LdapMessageResponse $messageResponse,): void
public function __invoke(LdapMessageResponse $messageResponse): void
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@
use FreeDSx\Ldap\Operation\Request\CancelRequest;
use FreeDSx\Ldap\Operation\Request\SearchRequest;
use FreeDSx\Ldap\Operation\Response\ExtendedResponse;
use FreeDSx\Ldap\Operation\Response\SearchResultDone;
use FreeDSx\Ldap\Operation\Response\SearchResultEntry;
use FreeDSx\Ldap\Operation\Response\SearchResultReference;
use FreeDSx\Ldap\Operation\ResultCode;
use FreeDSx\Ldap\Protocol\LdapMessageRequest;
use FreeDSx\Ldap\Protocol\LdapMessageResponse;
use FreeDSx\Ldap\Protocol\Queue\ClientQueue;
use PhpParser\Node\Arg;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use spec\FreeDSx\Ldap\TestFactoryTrait;

class RequestCancelerSpec extends ObjectBehavior
{
Expand All @@ -54,7 +51,7 @@ public function it_should_return_the_cancel_response(ClientQueue $queue): void

$queue
->sendMessage(Argument::that(
fn(LdapMessageRequest $request) =>
fn (LdapMessageRequest $request) =>
$request->getRequest() instanceof CancelRequest
))
->shouldBeCalledOnce();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use FreeDSx\Ldap\Entry\Entry;
use FreeDSx\Ldap\Operation\Request\ExtendedRequest;
use FreeDSx\Ldap\Operations;
use FreeDSx\Ldap\Protocol\ClientProtocolHandler\RequestHandlerInterface;
use FreeDSx\Ldap\Protocol\Factory\ServerProtocolHandlerFactory;
use FreeDSx\Ldap\Protocol\Queue\ServerQueue;
use FreeDSx\Ldap\Protocol\ServerProtocolHandler\ServerDispatchHandler;
Expand Down Expand Up @@ -116,7 +115,7 @@ public function it_should_get_an_unbind_handler(ServerQueue $queue): void
->shouldBeAnInstanceOf(ServerUnbindHandler::class);
}

public function it_should_get_the_dispatch_handler_for_common_requests(HandlerFactoryInterface $handlerFactory,): void
public function it_should_get_the_dispatch_handler_for_common_requests(HandlerFactoryInterface $handlerFactory, ): void
{
$handlerFactory->makeRequestHandler()
->willReturn(new GenericRequestHandler());
Expand Down
4 changes: 2 additions & 2 deletions tests/spec/FreeDSx/Ldap/Protocol/ServerAuthorizationSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function it_should_require_authentication_for_all_other_operations(): voi
public function it_should_not_require_authentication_if_it_has_been_explicitly_disabled(): void
{
$this->beConstructedWith(
(new ServerOptions)
(new ServerOptions())
->setAllowAnonymous(false)
->setRequireAuthentication(false),
new AnonToken()
Expand All @@ -116,7 +116,7 @@ public function it_should_not_allow_anonymous_authentication_by_default(): void
public function it_should_respect_the_option_for_whether_anon_binds_are_allowed(): void
{
$this->beConstructedWith(
(new ServerOptions)
(new ServerOptions())
->setAllowAnonymous(true),
new AnonToken()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use FreeDSx\Ldap\Protocol\LdapMessageResponse;
use FreeDSx\Ldap\Protocol\Queue\ServerQueue;
use FreeDSx\Ldap\Protocol\ServerProtocolHandler\ServerStartTlsHandler;
use FreeDSx\Ldap\Server\RequestHandler\RequestHandlerInterface;
use FreeDSx\Ldap\Server\Token\TokenInterface;
use FreeDSx\Ldap\ServerOptions;
use PhpSpec\ObjectBehavior;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use FreeDSx\Ldap\Protocol\LdapMessageResponse;
use FreeDSx\Ldap\Protocol\Queue\ServerQueue;
use FreeDSx\Ldap\Protocol\ServerProtocolHandler\ServerWhoAmIHandler;
use FreeDSx\Ldap\Server\RequestHandler\RequestHandlerInterface;
use FreeDSx\Ldap\Server\Token\AnonToken;
use FreeDSx\Ldap\Server\Token\BindToken;
use PhpSpec\ObjectBehavior;
Expand Down

0 comments on commit fa0900d

Please sign in to comment.