Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
use Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer;
Expand All @@ -17,4 +19,37 @@
BlankLineAfterStrictTypesFixer::class,
BlankLineAfterOpeningTagFixer::class,
NoUnusedImportsFixer::class,
]);
])
->withConfiguredRule(
OrderedClassElementsFixer::class,
[
'order' => [
'use_trait',
'case',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
],
'sort_algorithm' => 'none',
],
)
->withConfiguredRule(
ClassAttributesSeparationFixer::class,
[
'elements' => [
'const' => 'one',
'property' => 'one',
'method' => 'one',
],
],
);
1 change: 0 additions & 1 deletion src/FreeDSx/Ldap/ClientOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ public function getSslCaCert(): ?string
return $this->sslCaCert;
}


public function setSslCaCert(?string $sslCaCert): self
{
$this->sslCaCert = $sslCaCert;
Expand Down
10 changes: 5 additions & 5 deletions src/FreeDSx/Ldap/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@

class Container
{
/**
* @var array<class-string, callable>
*/
private array $instanceFactory = [];

/**
* These are classes that should never cache an instance when retrieved from the container.
*/
Expand All @@ -72,6 +67,11 @@ class Container
ServerAuthorization::class,
];

/**
* @var array<class-string, callable>
*/
private array $instanceFactory = [];

/**
* @var array<class-string, object>
*/
Expand Down
10 changes: 5 additions & 5 deletions src/FreeDSx/Ldap/Control/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public function __construct(
protected AbstractType|ProtocolElementInterface|string|null $controlValue = null,
) {}

public function __toString(): string
{
return $this->controlType;
}

public function setTypeOid(string $oid): static
{
$this->controlType = $oid;
Expand Down Expand Up @@ -164,11 +169,6 @@ public function toAsn1(): SequenceType
return $asn1;
}

public function __toString(): string
{
return $this->controlType;
}

/**
* {@inheritDoc}
*
Expand Down
1 change: 0 additions & 1 deletion src/FreeDSx/Ldap/Controls.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public static function manageDsaIt(): Control
);
}


/**
* Create a paging control with a specific size.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/FreeDSx/Ldap/Entry/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public function __clone()
}
}

public function __toString(): string
{
return implode(', ', $this->values);
}

/**
* @param string[] $values
*/
Expand Down Expand Up @@ -299,11 +304,6 @@ public function equals(
return $nameMatches;
}

public function __toString(): string
{
return implode(', ', $this->values);
}

/**
* Escape an attribute value for a filter.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/FreeDSx/Ldap/Entry/Dn.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class Dn implements IteratorAggregate, Countable, Stringable

public function __construct(private readonly string $dn) {}

public function __toString(): string
{
return $this->dn;
}

/**
* @throws UnexpectedValueException
*/
Expand Down Expand Up @@ -102,11 +107,6 @@ public function count(): int
return count((array) $this->pieces);
}

public function __toString(): string
{
return $this->dn;
}

/**
* @return Rdn[]
* @throws UnexpectedValueException
Expand Down
66 changes: 33 additions & 33 deletions src/FreeDSx/Ldap/Entry/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,39 @@ public function __construct(
$this->changes = new Changes();
}

public function __toString(): string
{
return $this->dn->toString();
}

public function __get(string $name): ?Attribute
{
return $this->get($name);
}

/**
* @param Stringable|string|array<string|Stringable> $value
*/
public function __set(
string $name,
Stringable|string|array $value,
): void {
$this->set(
$name,
...(is_array($value) ? $value : [(string) $value]),
);
}

public function __isset(string $name): bool
{
return $this->has($name);
}

public function __unset(string $name): void
{
$this->reset($name);
}

/**
* @internal
* @param Attribute[] $attributes
Expand Down Expand Up @@ -281,39 +314,6 @@ public function count(): int
return count($this->attributes);
}

public function __toString(): string
{
return $this->dn->toString();
}

public function __get(string $name): ?Attribute
{
return $this->get($name);
}

/**
* @param Stringable|string|array<string|Stringable> $value
*/
public function __set(
string $name,
Stringable|string|array $value,
): void {
$this->set(
$name,
...(is_array($value) ? $value : [(string) $value]),
);
}

public function __isset(string $name): bool
{
return $this->has($name);
}

public function __unset(string $name): void
{
$this->reset($name);
}

/**
* An alias of fromArray().
*
Expand Down
10 changes: 5 additions & 5 deletions src/FreeDSx/Ldap/Entry/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class Option implements Stringable

public function __construct(private readonly string $option) {}

public function __toString(): string
{
return $this->option;
}

public function isLanguageTag(): bool
{
return $this->startsWith('lang-');
Expand Down Expand Up @@ -115,11 +120,6 @@ public function toString(bool $lowercase = false): string
return $this->option;
}

public function __toString(): string
{
return $this->option;
}

/**
* Convenience factory method for creating a range option.
*
Expand Down
10 changes: 5 additions & 5 deletions src/FreeDSx/Ldap/Entry/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public function __construct(string|Option ...$options)
$this->set(...$options);
}

public function __toString(): string
{
return $this->toString();
}

public function add(string|Option ...$options): self
{
foreach ($options as $option) {
Expand Down Expand Up @@ -139,11 +144,6 @@ public function toArray(): array
return $this->options;
}

public function __toString(): string
{
return $this->toString();
}

/**
* @inheritDoc
* @return Traversable<Option>
Expand Down
10 changes: 5 additions & 5 deletions src/FreeDSx/Ldap/Entry/Rdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public function __construct(
private readonly string $value,
) {}

public function __toString(): string
{
return $this->toString();
}

public function getName(): string
{
return $this->name;
Expand Down Expand Up @@ -117,11 +122,6 @@ public function toString(): string
return $rdn;
}

public function __toString(): string
{
return $this->toString();
}

/**
* @throws InvalidArgumentException
*/
Expand Down
22 changes: 11 additions & 11 deletions src/FreeDSx/Ldap/LdapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ public function __construct(
]);
}

/**
* Try to clean-up if needed.
*
* @throws Exception\ConnectionException
* @throws OperationException
*/
public function __destruct()
{
$this->unbindIfConnected();
}

/**
* A Simple Bind to LDAP with a username and password.
*
Expand Down Expand Up @@ -488,17 +499,6 @@ public function isConnected(): bool
->isInstantiatedAndConnected();
}

/**
* Try to clean-up if needed.
*
* @throws Exception\ConnectionException
* @throws OperationException
*/
public function __destruct()
{
$this->unbindIfConnected();
}

private function handler(): ClientProtocolHandler
{
if ($this->handler === null) {
Expand Down
Loading
Loading