Skip to content

Commit 1796030

Browse files
committed
Merge branch 'feature-php-cs' into 'master'
phpcs implementation See merge request head.trackingsoft/micro-plugin-redis!1
2 parents f8a0e97 + f54bd40 commit 1796030

11 files changed

+105
-46
lines changed

phpcs.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="pcsg-generated-ruleset">
3+
<file>src/</file>
4+
<arg name="basepath" value="."/>
5+
<arg name="colors"/>
6+
<arg name="no-cache"/>
7+
<description>
8+
Micro Framework - сode formatting rules.
9+
</description>
10+
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
11+
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
12+
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
13+
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
14+
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
15+
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
16+
<rule ref="Generic.Files.ByteOrderMark"/>
17+
<rule ref="Generic.Files.LineEndings"/>
18+
<rule ref="Generic.Files.LineLength">
19+
<properties>
20+
<property name="lineLimit" value="120"/>
21+
<property name="absoluteLineLimit" value="150"/>
22+
</properties>
23+
</rule>
24+
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
25+
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
26+
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
27+
<rule ref="Generic.Functions.CallTimePassByReference"/>
28+
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
29+
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
30+
<rule ref="Generic.Metrics.NestingLevel"/>
31+
<rule ref="Generic.NamingConventions.ConstructorName"/>
32+
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
33+
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
34+
<rule ref="Generic.PHP.DeprecatedFunctions"/>
35+
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
36+
<rule ref="Generic.PHP.ForbiddenFunctions"/>
37+
<rule ref="Generic.PHP.LowerCaseConstant"/>
38+
<rule ref="Generic.PHP.NoSilencedErrors"/>
39+
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
40+
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
41+
<rule ref="MySource.PHP.EvalObjectFactory"/>
42+
<rule ref="MySource.PHP.GetRequestData"/>
43+
<rule ref="PEAR.Classes.ClassDeclaration"/>
44+
<rule ref="PEAR.Commenting.InlineComment"/>
45+
<rule ref="PEAR.ControlStructures.MultiLineCondition"/>
46+
<rule ref="PEAR.Files.IncludingFile"/>
47+
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
48+
<rule ref="PEAR.Functions.ValidDefaultValue"/>
49+
<rule ref="PEAR.NamingConventions.ValidClassName"/>
50+
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
51+
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
52+
<rule ref="PEAR.WhiteSpace.ScopeIndent"/>
53+
<rule ref="PSR1.Classes.ClassDeclaration"/>
54+
<rule ref="PSR1.Files.SideEffects"/>
55+
<rule ref="PSR2.Classes.ClassDeclaration"/>
56+
<rule ref="PSR2.Classes.PropertyDeclaration"/>
57+
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
58+
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
59+
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
60+
<rule ref="PSR2.Files.EndFileNewline"/>
61+
<rule ref="PSR2.Methods.MethodDeclaration"/>
62+
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
63+
<rule ref="PSR2.Namespaces.UseDeclaration"/>
64+
</ruleset>

src/Business/Redis/RedisBuilder.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ class RedisBuilder implements RedisBuilderInterface
1414
* @param RedisFactoryInterface $redisFactory
1515
*/
1616
public function __construct(
17-
private RedisPluginConfiguration $pluginConfiguration,
18-
private RedisFactoryInterface $redisFactory
19-
) {}
17+
private RedisPluginConfiguration $pluginConfiguration,
18+
private RedisFactoryInterface $redisFactory
19+
)
20+
{
21+
}
2022

2123
/**
2224
* @param string $redisAlias
@@ -26,7 +28,7 @@ public function __construct(
2628
public function create(string $redisAlias): Redis
2729
{
2830
$clientConfiguration = $this->pluginConfiguration->getClientConfiguration($redisAlias);
29-
$redis = $this->redisFactory->create();
31+
$redis = $this->redisFactory->create();
3032

3133
$this->initialize($redis, $clientConfiguration);
3234

src/Business/Redis/RedisBuilderFactory.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ class RedisBuilderFactory implements RedisBuilderFactoryInterface
1111
* @param RedisFactoryInterface $redisFactory
1212
*/
1313
public function __construct(
14-
private RedisPluginConfiguration $configuration,
15-
private RedisFactoryInterface $redisFactory
16-
) {}
14+
private RedisPluginConfiguration $configuration,
15+
private RedisFactoryInterface $redisFactory
16+
)
17+
{
18+
}
1719

1820
/**
1921
* {@inheritDoc}

src/Configuration/AuthorizationConfigurationInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ public function username(): ?string;
1414
*/
1515
public function password(): ?string;
1616
}
17-

src/Configuration/ClientOptionsConfiguration.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ class ClientOptionsConfiguration extends PluginRoutingKeyConfiguration implement
88
{
99

1010
protected const CFG_SERIALIZER = 'REDIS_%s_OPT_SERIALIZER';
11-
protected const CFG_PREFIX = 'REDIS_%s_OPT_PREFIX';
12-
protected const CFG_SCAN = 'REDIS_%s_OPT_SCAN';
11+
protected const CFG_PREFIX = 'REDIS_%s_OPT_PREFIX';
12+
protected const CFG_SCAN = 'REDIS_%s_OPT_SCAN';
1313

14-
public const PREFIX_DEFAULT = '';
14+
public const PREFIX_DEFAULT = '';
1515
public const SERIALIZER_DEFAULT = ClientOptionsConfigurationInterface::SERIALIZER_NONE;
16-
public const SCAN_DEFAULT = '';
16+
public const SCAN_DEFAULT = '';
1717

1818
/**
1919
* {@inheritDoc}

src/Configuration/ClientOptionsConfigurationInterface.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
interface ClientOptionsConfigurationInterface
66
{
7-
const SERIALIZER_NONE = 'SERIALIZER_NONE';
8-
const SERIALIZER_PHP = 'SERIALIZER_PHP';
7+
const SERIALIZER_NONE = 'SERIALIZER_NONE';
8+
const SERIALIZER_PHP = 'SERIALIZER_PHP';
99
const SERIALIZER_IGBINARY = 'SERIALIZER_IGBINARY';
10-
const SERIALIZER_MSGPACK = 'SERIALIZER_MSGPACK';
11-
const SERIALIZER_JSON = 'SERIALIZER_JSON';
10+
const SERIALIZER_MSGPACK = 'SERIALIZER_MSGPACK';
11+
const SERIALIZER_JSON = 'SERIALIZER_JSON';
1212

13-
const SCAN_NORETRY = 'SCAN_NORETRY';
14-
const SCAN_RETRY = 'SCAN_RETRY';
15-
const SCAN_PREFIX = 'SCAN_PREFIX';
13+
const SCAN_NORETRY = 'SCAN_NORETRY';
14+
const SCAN_RETRY = 'SCAN_RETRY';
15+
const SCAN_PREFIX = 'SCAN_PREFIX';
1616
const SCAN_NOPREFIX = 'SCAN_NOPREFIX';
1717

1818
/**

src/Configuration/RedisClientConfiguration.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,25 @@
22

33
namespace Micro\Plugin\Redis\Configuration;
44

5-
65
use Micro\Framework\Kernel\Configuration\PluginRoutingKeyConfiguration;
76

8-
97
class RedisClientConfiguration extends PluginRoutingKeyConfiguration implements RedisClientConfigurationInterface
108
{
11-
public const CONNECTION_TYPE_DEFAULT = RedisClientConfigurationInterface::CONNECTION_TYPE_NET;
12-
public const HOST_DEFAULT = 'localhost';
13-
public const PORT_DEFAULT = 6379;
14-
public const CONNECTION_TIMEOUT_DEFAULT = 0.0;
15-
public const READ_TIMEOUT_DEFAULT = 0.0;
9+
public const CONNECTION_TYPE_DEFAULT = RedisClientConfigurationInterface::CONNECTION_TYPE_NET;
10+
public const HOST_DEFAULT = 'localhost';
11+
public const PORT_DEFAULT = 6379;
12+
public const CONNECTION_TIMEOUT_DEFAULT = 0.0;
13+
public const READ_TIMEOUT_DEFAULT = 0.0;
1614
public const CONNECTION_RETRY_INTERNAL_DEFAULT = 0;
17-
public const CONNECTION_REUSE_DEFAULT = false;
15+
public const CONNECTION_REUSE_DEFAULT = false;
1816

19-
protected const CFG_CONNECTION_TYPE = 'REDIS_%s_CONNECTION_TYPE';
20-
protected const CFG_CONNECTION_REUSE = 'REDIS_%s_CONNECTION_REUSE';
21-
protected const CFG_CONNECTION_HOST = 'REDIS_%s_HOST';
22-
protected const CFG_CONNECTION_PORT = 'REDIS_%s_PORT';
23-
protected const CFG_CONNECTION_TIMEOUT = 'REDIS_%s_TIMEOUT';
17+
protected const CFG_CONNECTION_TYPE = 'REDIS_%s_CONNECTION_TYPE';
18+
protected const CFG_CONNECTION_REUSE = 'REDIS_%s_CONNECTION_REUSE';
19+
protected const CFG_CONNECTION_HOST = 'REDIS_%s_HOST';
20+
protected const CFG_CONNECTION_PORT = 'REDIS_%s_PORT';
21+
protected const CFG_CONNECTION_TIMEOUT = 'REDIS_%s_TIMEOUT';
2422
protected const CFG_CONNECTION_RETRY_INTERVAL = 'REDIS_%s_RETRY_INTERVAL';
25-
protected const CFG_READ_TIMEOUT = 'REDIS_%s_READ_TIMEOUT';
23+
protected const CFG_READ_TIMEOUT = 'REDIS_%s_READ_TIMEOUT';
2624

2725
/**
2826
* {@inheritDoc}

src/Configuration/SslConfiguration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ class SslConfiguration extends PluginRoutingKeyConfiguration implements SslConfi
88
{
99

1010
protected const CFG_SSL_ENABLED = 'REDIS_%s_SSL_ENABLED';
11-
protected const CFG_SSL_VERIFY = 'REDIS_%s_SSL_VERIFY';
11+
protected const CFG_SSL_VERIFY = 'REDIS_%s_SSL_VERIFY';
1212

1313
public const SSL_ENABLED_DEFAULT = false;
14-
public const SSL_VERIFY_DEFAULT = false;
14+
public const SSL_VERIFY_DEFAULT = false;
1515

1616
/**
1717
* @return bool

src/RedisPlugin.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function createRedisManager(): RedisManagerInterface
4646
protected function createRedisBuilderFactory(): RedisBuilderFactoryInterface
4747
{
4848
return new RedisBuilderFactory(
49-
$this->configuration(),
49+
$this->configuration,
5050
$this->createRedisFactory()
5151
);
5252
}
@@ -58,12 +58,4 @@ protected function createRedisFactory(): RedisFactoryInterface
5858
{
5959
return new RedisFactory();
6060
}
61-
62-
/**
63-
* @return RedisPluginConfiguration
64-
*/
65-
protected function configuration(): RedisPluginConfigurationInterface
66-
{
67-
return parent::configuration();
68-
}
6961
}

src/RedisPluginConfiguration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public function getClientList(): array
3030
public function getClientConfiguration(string $clientName): RedisClientConfigurationInterface
3131
{
3232
if(!in_array($clientName, $this->getClientList(), true)) {
33-
throw new \InvalidArgumentException('Redis client is not defined in the environment file. Please, append connection id to "%s"', self::CFG_CLIENT_LIST);
33+
throw new \InvalidArgumentException(
34+
'Redis client is not defined in the environment file. Please, append connection id to "%s"',
35+
self::CFG_CLIENT_LIST
36+
);
3437
}
3538

3639
return new RedisClientConfiguration($this->configuration, $clientName);

0 commit comments

Comments
 (0)