From fbfca80deca0f06f78bb2bcc4488b39f7bcb59eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB?= Date: Tue, 29 Sep 2020 16:40:35 +0300 Subject: [PATCH] phpcs & code quality fixes --- .gitignore | 1 + composer.json | 2 +- phpcs.xml.dist | 13 +++++++++++++ src/Builder/ContainerBuilder.php | 20 ++++++++++---------- src/Component/Psr7/Stream.php | 9 ++++++--- src/Factory/SerializerFactory.php | 10 +++++----- src/Model/Request/BaseRequest.php | 4 +++- 7 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/.gitignore b/.gitignore index 1465077..3dd436d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ phpunit.xml .swp /nbproject .env +.php_cs.cache diff --git a/composer.json b/composer.json index 3121cbb..65d48d9 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "phpmd": "./vendor/bin/phpmd src text controversial,design,./phpmd.xml", "phpcs": "./vendor/bin/phpcs -p src --runtime-set testVersion 7.3", "phpcbf": "./vendor/bin/phpcbf -p src", - "test": "composer run-script phpmd && composer run-script phpunit" + "test": "composer run-script phpcs && composer run-script phpmd && composer run-script phpunit" }, "prefer-stable": true, "license": "MIT" diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..18bfbcf --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,13 @@ + + + + + + + + + + src/ + tests/ + diff --git a/src/Builder/ContainerBuilder.php b/src/Builder/ContainerBuilder.php index 9c728d3..5f5ff80 100644 --- a/src/Builder/ContainerBuilder.php +++ b/src/Builder/ContainerBuilder.php @@ -116,16 +116,16 @@ class ContainerBuilder implements BuilderInterface $container = new Container(); switch ($this->env) { - case Environment::PROD: - $this->setProdServices($container); - break; - case Environment::DEV: - case Environment::TEST: - $this->setProdServices($container); - $this->setDevServices($container); - break; - default: - throw new RuntimeException(sprintf('Invalid environment type: %s', $this->env)); + case Environment::PROD: + $this->setProdServices($container); + break; + case Environment::DEV: + case Environment::TEST: + $this->setProdServices($container); + $this->setDevServices($container); + break; + default: + throw new RuntimeException(sprintf('Invalid environment type: %s', $this->env)); } return $container; diff --git a/src/Component/Psr7/Stream.php b/src/Component/Psr7/Stream.php index e613267..e150758 100644 --- a/src/Component/Psr7/Stream.php +++ b/src/Component/Psr7/Stream.php @@ -119,9 +119,12 @@ class Stream implements StreamInterface throw $exception; } - trigger_error(sprintf( - '%s::__toString exception: %s', - self::class, (string) $exception), + trigger_error( + sprintf( + '%s::__toString exception: %s', + self::class, + (string) $exception + ), E_USER_ERROR ); } diff --git a/src/Factory/SerializerFactory.php b/src/Factory/SerializerFactory.php index a70dc7e..ba2bd7e 100644 --- a/src/Factory/SerializerFactory.php +++ b/src/Factory/SerializerFactory.php @@ -66,11 +66,11 @@ class SerializerFactory implements FactoryInterface $container = $this->container; return SerializerBuilder::create() - ->configureHandlers(function(HandlerRegistry $registry) use ($container) { - $returnNull = function($visitor, $obj, array $type) { + ->configureHandlers(function (HandlerRegistry $registry) use ($container) { + $returnNull = function ($visitor, $obj, array $type) { return null; }; - $returnSame = function($visitor, $obj, array $type) { + $returnSame = function ($visitor, $obj, array $type) { return $obj; }; @@ -78,7 +78,7 @@ class SerializerFactory implements FactoryInterface GraphNavigatorInterface::DIRECTION_SERIALIZATION, 'RequestDtoInterface', 'json', - function($visitor, $obj, array $type) use ($container) { + function ($visitor, $obj, array $type) use ($container) { /** @var SerializerInterface $serializer */ $serializer = $container->get(Constants::SERIALIZER); @@ -95,7 +95,7 @@ class SerializerFactory implements FactoryInterface GraphNavigatorInterface::DIRECTION_SERIALIZATION, 'RequestDtoInterface', 'xml', - function($visitor, $obj, array $type) use ($container) { + function ($visitor, $obj, array $type) use ($container) { /** @var SerializerInterface $serializer */ $serializer = $container->get(Constants::SERIALIZER); diff --git a/src/Model/Request/BaseRequest.php b/src/Model/Request/BaseRequest.php index 273e663..fe35d8c 100644 --- a/src/Model/Request/BaseRequest.php +++ b/src/Model/Request/BaseRequest.php @@ -136,7 +136,9 @@ abstract class BaseRequest * * @return void */ - final public function setMethod(string $method): void {} + final public function setMethod(string $method): void + { + } /** * Should return method name for this request.