Skip to content

Commit

Permalink
Updated coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
raoul authored and janlanger committed Feb 10, 2023
1 parent 7ef3f24 commit 920d249
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 41 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"phpstan/phpstan-phpunit": "^1.3.3",
"phpstan/phpstan-strict-rules": "^1.4.5",
"phpunit/phpunit": "^9.5.28",
"slevomat/coding-standard": "^7.2.0",
"slevomat/coding-standard": "^8.8",
"spell-checker/spell-checker": "^0.3.22",
"spell-checker/dictionary-en": "^0.1.1",
"squizlabs/php_codesniffer": "^3.7.1"
Expand Down
54 changes: 43 additions & 11 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,29 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing"/>
<rule ref="SlevomatCodingStandard.Attributes.AttributesOrder">
<properties>
<property name="order" type="array">
<element value="Get"/>
<element value="Set"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Attributes.DisallowAttributesJoining"/>
<rule ref="SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine"/>
<rule ref="SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment"/>
<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
<element value="uses"/>
<element value="constants"/>
<element value="enum cases"/>
<element value="public constants"/>
<element value="protected constants"/>
<element value="private constants"/>
<element value="properties"/>
<element value="constructor"/>
<element value="static constructors"/>
Expand All @@ -132,11 +148,13 @@
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing">
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration">
<properties>
<property name="minLinesCountBeforeWithComment" value="0"/>
<property name="checkPromoted" value="true"/>
<property name="enableMultipleSpacesBetweenModifiersCheck" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature">
<properties>
Expand All @@ -153,6 +171,7 @@
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming">
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>
</rule>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing"/>
Expand All @@ -172,8 +191,7 @@
@see,
"/>
<element value="
@get,
@set,
@var,
"/>
<element value="
@param,
Expand Down Expand Up @@ -201,8 +219,9 @@
<element value="@copyright"/>
<element value="@license"/>
<element value="@package"/>
<element value="@throws"/>
<element value="@version"/>
<element value="@get"/>
<element value="@set"/>
</property>
</properties>
</rule>
Expand Down Expand Up @@ -305,9 +324,24 @@
<property name="allowMultiLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowNamedArguments"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall">
<properties>
<property name="onlySingleLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse">
<properties>
<property name="onlySingleLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration">
<properties>
<property name="onlySingleLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
Expand All @@ -321,7 +355,6 @@
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="searchAnnotations" value="true"/>
<property name="fullyQualifiedKeywords" type="array" value=""/>
<property name="allowFallbackGlobalFunctions" value="false"/>
<property name="allowFallbackGlobalConstants" value="false"/>
<property name="allowFullyQualifiedExceptions" value="false"/>
Expand Down Expand Up @@ -362,6 +395,7 @@
<property name="declareOnFirstLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
Expand All @@ -381,7 +415,6 @@
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="traversableTypeHints" type="array">
Expand All @@ -401,7 +434,7 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!--<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>-->
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable" />
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
Expand Down Expand Up @@ -458,7 +491,6 @@
</rule>
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
<rule ref="Squiz.PHP.GlobalKeyword"/>
<rule ref="Squiz.PHP.Heredoc"/>
<rule ref="Squiz.PHP.InnerFunctions"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.PHP.NonExecutableCode"/>
Expand Down
6 changes: 3 additions & 3 deletions src/AsyncMessageQueueManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class AsyncMessageQueueManager

private PromiseTimer $promiseTimer;

/** @var mixed[] */
/** @var array<int, AsyncMessage> */
private array $messageQueue = [];

/** @var Deferred[] */
/** @var array<Deferred> */
private array $processingRequests = [];

private float $maxIntervalBetweenMessages;
Expand Down Expand Up @@ -161,7 +161,7 @@ public function getQueuedMessagesCount(): int
}

/**
* @return mixed[]
* @return array<mixed>
*/
public function getQueuedMessages(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Connector/ConnectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class ConnectorFactory

private bool $useSecureConnector;

/** @var mixed[][] */
/** @var array<array<mixed>> */
private array $context;

private int $timeoutInSeconds;

/**
* @param mixed[][] $context
* @param array<array<mixed>> $context
*/
public function __construct(
LoopInterface $loop,
Expand Down
4 changes: 2 additions & 2 deletions src/Connector/TcpConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class TcpConnector implements ConnectorInterface

private LoopInterface $loop;

/** @var mixed[] */
/** @var array<mixed> */
private array $context;

/**
* @param mixed[] $context
* @param array<mixed> $context
*/
public function __construct(LoopInterface $loop, array $context = [])
{
Expand Down
12 changes: 6 additions & 6 deletions src/Smtp/AsyncDoubleResponseMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class AsyncDoubleResponseMessage implements AsyncMessage

private string $text;

/** @var int[] */
/** @var array<int> */
private array $expectedFirstResponseCodes = [];

/** @var int[] */
/** @var array<int> */
private array $expectedSecondResponseCodes = [];

private ?string $textReplacement = null;

/**
* @param int[] $expectedFirstResponseCodes
* @param int[] $expectedSecondResponseCodes
* @param array<int> $expectedFirstResponseCodes
* @param array<int> $expectedSecondResponseCodes
*/
public function __construct(
string $text,
Expand All @@ -40,15 +40,15 @@ public function getText(): string
}

/**
* @return int[]
* @return array<int>
*/
public function getExpectedFirstResponseCodes(): array
{
return $this->expectedFirstResponseCodes;
}

/**
* @return int[]
* @return array<int>
*/
public function getExpectedSecondResponseCodes(): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/Smtp/AsyncSingleResponseMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ class AsyncSingleResponseMessage implements AsyncMessage

private string $text;

/** @var int[] */
/** @var array<int> */
private array $expectedResponseCodes = [];

private ?string $textReplacement = null;

/**
* @param int[] $expectedResponseCodes
* @param array<int> $expectedResponseCodes
*/
public function __construct(
string $text,
Expand All @@ -34,7 +34,7 @@ public function getText(): string
}

/**
* @return int[]
* @return array<int>
*/
public function getExpectedResponseCodes(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Smtp/AsyncSmtpConnectionWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class AsyncSmtpConnectionWriter implements AsyncConnectionWriter
{

/** @var mixed[][] */
/** @var array<array<mixed>> */
private array $expectedResponses = [];

private ConnectionInterface $connection;
Expand Down
2 changes: 1 addition & 1 deletion tests/AsyncMessageQueueManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AsyncMessageQueueManagerTest extends TestCase

private LoopInterface $loop;

/** @var mixed[] */
/** @var array<string, bool|string> */
private array $exceptions = [];

private int $disconnectsCount = 0;
Expand Down
8 changes: 1 addition & 7 deletions tests/Smtp/AsyncSmtpConnectionWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AsyncSmtpConnectionWriterTest extends TestCase

private ?Closure $doOnError = null;

/** @var string[] */
/** @var array<string> */
private array $serverResponses;

private LoggerInterface $logger;
Expand Down Expand Up @@ -124,9 +124,6 @@ function (Throwable $exception): void {
);
}

/**
* @return mixed[][]
*/
public function dataSuccessfulWrites(): array
{
return [
Expand Down Expand Up @@ -196,9 +193,6 @@ function (Throwable $exception): void {
);
}

/**
* @return mixed[][]
*/
public function dataFailedWrites(): array
{
return [
Expand Down
5 changes: 1 addition & 4 deletions tests/Smtp/AsyncSmtpMessageSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AsyncSmtpMessageSenderTest extends TestCase

private LoopInterface $loop;

/** @var string[] */
/** @var array<string> */
private array $recipients = [];

protected function setUp(): void
Expand All @@ -45,9 +45,6 @@ public function testSuccessfulSendingReturnsPromise(): void
$this->runSuccessfulSendingTest($this->createMessage());
}

/**
* @return mixed[][]
*/
public function dataFailedSendingThrowsException(): array
{
return [
Expand Down

0 comments on commit 920d249

Please sign in to comment.