From ce0ae3d069d3859d271509c7381909e4428fbc55 Mon Sep 17 00:00:00 2001 From: Chad Sikorra Date: Sat, 6 Jun 2026 10:29:26 -0400 Subject: [PATCH] Adjust code style so we sort class properties / constants / methods by visibility. One new line between each. --- ecs.php | 37 +- src/FreeDSx/Ldap/ClientOptions.php | 1 - src/FreeDSx/Ldap/Container.php | 10 +- src/FreeDSx/Ldap/Control/Control.php | 10 +- src/FreeDSx/Ldap/Controls.php | 1 - src/FreeDSx/Ldap/Entry/Attribute.php | 10 +- src/FreeDSx/Ldap/Entry/Dn.php | 10 +- src/FreeDSx/Ldap/Entry/Entry.php | 66 ++-- src/FreeDSx/Ldap/Entry/Option.php | 10 +- src/FreeDSx/Ldap/Entry/Options.php | 10 +- src/FreeDSx/Ldap/Entry/Rdn.php | 10 +- src/FreeDSx/Ldap/LdapClient.php | 22 +- src/FreeDSx/Ldap/LdapServer.php | 126 +++---- src/FreeDSx/Ldap/LdapUrl.php | 10 +- src/FreeDSx/Ldap/LdapUrlExtension.php | 10 +- .../Ldap/Ldif/Output/StringLdifOutput.php | 10 +- .../Ldap/Ldif/Parser/LdifLineCursor.php | 64 ++-- .../Operation/Request/ExtendedRequest.php | 6 +- .../Operation/Response/ExtendedResponse.php | 46 +-- .../Response/IntermediateResponse.php | 52 +-- .../SyncInfo/SyncRefreshDoneTrait.php | 4 +- .../OptionsBuilder/RequireIdentityTrait.php | 10 +- src/FreeDSx/Ldap/Protocol/Bind/SimpleBind.php | 16 +- .../ClientBasicHandler.php | 4 +- src/FreeDSx/Ldap/Protocol/LdapQueue.php | 10 +- .../Ldap/Protocol/Queue/ServerQueue.php | 76 ++--- .../Schema/Definition/AttributeTypeOid.php | 104 ++++++ .../Schema/Definition/MatchingRuleOid.php | 20 ++ .../Ldap/Schema/Definition/ObjectClassOid.php | 24 ++ .../Schema/Definition/PasswordPolicyOid.php | 62 ++++ .../Ldap/Schema/Definition/SyntaxOid.php | 14 + .../Ldap/Schema/StandardSchemaProvider.php | 4 +- .../Search/Filter/FilterAttributeTrait.php | 10 +- .../Search/Filter/FilterContainerTrait.php | 10 +- .../Ldap/Search/Filter/MatchingRuleFilter.php | 10 +- src/FreeDSx/Ldap/Search/Filter/NotFilter.php | 10 +- .../Ldap/Search/Result/EntryResult.php | 20 +- .../Ldap/Search/Result/ReferralResult.php | 22 +- .../Adapter/Dialect/PdoDialectInterface.php | 1 - .../Adapter/Pdo/PdoStorageFactoryTrait.php | 12 +- .../Storage/Adapter/Pdo/PooledStatement.php | 10 +- .../Backend/Storage/Adapter/PdoStorage.php | 196 +++++------ .../SqlFilter/SqlFilterTranslatorTrait.php | 30 +- .../Adapter/Support/JsonEntryBuffer.php | 48 +-- .../Adapter/Writer/SwooleWriterQueue.php | 88 ++--- .../Storage/WritableStorageBackend.php | 116 +++---- .../Ldap/Server/Logging/EventContext.php | 25 ++ .../Recorder/InMemoryMetricsRecorder.php | 62 ++-- .../PasswordPolicy/PasswordPolicyEngine.php | 322 +++++++++--------- .../Server/Proxy/ProxyProtocolFactory.php | 10 +- .../Ldap/Server/ServerProtocolFactory.php | 10 +- .../Ldap/Sync/Result/SyncIdSetResult.php | 38 +-- .../PasswordPolicyBindEnforcementTest.php | 5 + .../PasswordPolicyChangeEnforcementTest.php | 5 + ...sswordPolicyPlainModifyEnforcementTest.php | 4 + tests/integration/ServerTestCase.php | 46 +-- .../Storage/LdapBackendStorageTest.php | 30 +- tests/integration/Sync/SyncReplTest.php | 4 +- .../Compare/BenchCompareCommand.php | 8 +- tests/performance/Server/ServerManager.php | 14 +- tests/performance/Workload/Worker.php | 18 +- tests/support/LdapBackendStorageCommand.php | 1 - tests/unit/Control/Ad/SdFlagsControlTest.php | 1 + .../Protocol/Bind/Sasl/SaslExchangeTest.php | 42 +-- .../ClientSyncHandlerTest.php | 1 - .../ClientUnbindHandlerTest.php | 1 + tests/unit/Protocol/Queue/ServerQueueTest.php | 1 - .../ServerPagingHandlerTest.php | 114 +++---- .../ServerRootDseHandlerTest.php | 42 +-- .../ServerSearchHandlerTest.php | 32 +- .../ServerSubschemaHandlerTest.php | 16 +- .../Schema/Validation/SchemaValidatorTest.php | 152 ++++----- tests/unit/Search/PagingTest.php | 1 - .../PasswordAuthenticatorTest.php | 32 +- .../PasswordPolicyAwareAuthenticatorTest.php | 3 + .../Auth/SaslBindPolicyEnforcerTest.php | 3 + .../Storage/Adapter/JsonFileStorageTest.php | 32 +- .../Adapter/Pdo/PdoListQueryBuilderTest.php | 38 +-- .../Storage/Adapter/SqliteStorageTest.php | 100 +++--- .../Adapter/Support/SortKeyComparatorTest.php | 44 +-- .../Adapter/WritableStorageBackendTest.php | 50 +-- .../OperationalAttributeGeneratorTest.php | 38 +-- .../Write/PasswordPolicyWriteHandlerTest.php | 3 + .../Backend/Write/SystemChangeWriterTest.php | 1 + .../Write/WriteOperationDispatcherTest.php | 16 +- .../Constraint/MinAgeConstraintTest.php | 1 + .../Guard/PasswordPolicyBindGuardTest.php | 5 + .../Guard/PasswordPolicyChangeGuardTest.php | 3 + .../PasswordPolicyEngineTest.php | 1 + .../PasswordPolicyResolverTest.php | 2 + .../unit/Server/ServerProtocolFactoryTest.php | 16 +- .../unit/Sync/Result/SyncEntryResultTest.php | 1 - 92 files changed, 1580 insertions(+), 1266 deletions(-) diff --git a/ecs.php b/ecs.php index e8514ef0..94c025c6 100644 --- a/ecs.php +++ b/ecs.php @@ -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; @@ -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', + ], + ], + ); diff --git a/src/FreeDSx/Ldap/ClientOptions.php b/src/FreeDSx/Ldap/ClientOptions.php index ab3d1b0d..53f4f995 100644 --- a/src/FreeDSx/Ldap/ClientOptions.php +++ b/src/FreeDSx/Ldap/ClientOptions.php @@ -202,7 +202,6 @@ public function getSslCaCert(): ?string return $this->sslCaCert; } - public function setSslCaCert(?string $sslCaCert): self { $this->sslCaCert = $sslCaCert; diff --git a/src/FreeDSx/Ldap/Container.php b/src/FreeDSx/Ldap/Container.php index c796e0ee..00829c7a 100644 --- a/src/FreeDSx/Ldap/Container.php +++ b/src/FreeDSx/Ldap/Container.php @@ -59,11 +59,6 @@ class Container { - /** - * @var array - */ - private array $instanceFactory = []; - /** * These are classes that should never cache an instance when retrieved from the container. */ @@ -72,6 +67,11 @@ class Container ServerAuthorization::class, ]; + /** + * @var array + */ + private array $instanceFactory = []; + /** * @var array */ diff --git a/src/FreeDSx/Ldap/Control/Control.php b/src/FreeDSx/Ldap/Control/Control.php index 6a840832..b2de37df 100644 --- a/src/FreeDSx/Ldap/Control/Control.php +++ b/src/FreeDSx/Ldap/Control/Control.php @@ -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; @@ -164,11 +169,6 @@ public function toAsn1(): SequenceType return $asn1; } - public function __toString(): string - { - return $this->controlType; - } - /** * {@inheritDoc} * diff --git a/src/FreeDSx/Ldap/Controls.php b/src/FreeDSx/Ldap/Controls.php index a509374d..f4c13fd5 100644 --- a/src/FreeDSx/Ldap/Controls.php +++ b/src/FreeDSx/Ldap/Controls.php @@ -124,7 +124,6 @@ public static function manageDsaIt(): Control ); } - /** * Create a paging control with a specific size. */ diff --git a/src/FreeDSx/Ldap/Entry/Attribute.php b/src/FreeDSx/Ldap/Entry/Attribute.php index e68c0857..8ab89e83 100644 --- a/src/FreeDSx/Ldap/Entry/Attribute.php +++ b/src/FreeDSx/Ldap/Entry/Attribute.php @@ -76,6 +76,11 @@ public function __clone() } } + public function __toString(): string + { + return implode(', ', $this->values); + } + /** * @param string[] $values */ @@ -299,11 +304,6 @@ public function equals( return $nameMatches; } - public function __toString(): string - { - return implode(', ', $this->values); - } - /** * Escape an attribute value for a filter. */ diff --git a/src/FreeDSx/Ldap/Entry/Dn.php b/src/FreeDSx/Ldap/Entry/Dn.php index 473dcb6f..1521c5f4 100644 --- a/src/FreeDSx/Ldap/Entry/Dn.php +++ b/src/FreeDSx/Ldap/Entry/Dn.php @@ -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 */ @@ -102,11 +107,6 @@ public function count(): int return count((array) $this->pieces); } - public function __toString(): string - { - return $this->dn; - } - /** * @return Rdn[] * @throws UnexpectedValueException diff --git a/src/FreeDSx/Ldap/Entry/Entry.php b/src/FreeDSx/Ldap/Entry/Entry.php index 9f115938..1325aaa0 100644 --- a/src/FreeDSx/Ldap/Entry/Entry.php +++ b/src/FreeDSx/Ldap/Entry/Entry.php @@ -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 $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 @@ -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 $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(). * diff --git a/src/FreeDSx/Ldap/Entry/Option.php b/src/FreeDSx/Ldap/Entry/Option.php index f6394c73..90c42791 100644 --- a/src/FreeDSx/Ldap/Entry/Option.php +++ b/src/FreeDSx/Ldap/Entry/Option.php @@ -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-'); @@ -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. * diff --git a/src/FreeDSx/Ldap/Entry/Options.php b/src/FreeDSx/Ldap/Entry/Options.php index 8f432c84..c124a819 100644 --- a/src/FreeDSx/Ldap/Entry/Options.php +++ b/src/FreeDSx/Ldap/Entry/Options.php @@ -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) { @@ -139,11 +144,6 @@ public function toArray(): array return $this->options; } - public function __toString(): string - { - return $this->toString(); - } - /** * @inheritDoc * @return Traversable