1
0
mirror of synced 2024-11-24 05:26:03 +03:00

phpcs & code quality fixes

This commit is contained in:
Pavel 2020-09-29 16:40:35 +03:00
parent 08d118a842
commit fbfca80dec
7 changed files with 39 additions and 20 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ phpunit.xml
.swp .swp
/nbproject /nbproject
.env .env
.php_cs.cache

View File

@ -42,7 +42,7 @@
"phpmd": "./vendor/bin/phpmd src text controversial,design,./phpmd.xml", "phpmd": "./vendor/bin/phpmd src text controversial,design,./phpmd.xml",
"phpcs": "./vendor/bin/phpcs -p src --runtime-set testVersion 7.3", "phpcs": "./vendor/bin/phpcs -p src --runtime-set testVersion 7.3",
"phpcbf": "./vendor/bin/phpcbf -p src", "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, "prefer-stable": true,
"license": "MIT" "license": "MIT"

13
phpcs.xml.dist Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="basepath" value="."/>
<arg name="cache" value=".php_cs.cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<rule ref="PSR2"/>
<file>src/</file>
<file>tests/</file>
</ruleset>

View File

@ -116,16 +116,16 @@ class ContainerBuilder implements BuilderInterface
$container = new Container(); $container = new Container();
switch ($this->env) { switch ($this->env) {
case Environment::PROD: case Environment::PROD:
$this->setProdServices($container); $this->setProdServices($container);
break; break;
case Environment::DEV: case Environment::DEV:
case Environment::TEST: case Environment::TEST:
$this->setProdServices($container); $this->setProdServices($container);
$this->setDevServices($container); $this->setDevServices($container);
break; break;
default: default:
throw new RuntimeException(sprintf('Invalid environment type: %s', $this->env)); throw new RuntimeException(sprintf('Invalid environment type: %s', $this->env));
} }
return $container; return $container;

View File

@ -119,9 +119,12 @@ class Stream implements StreamInterface
throw $exception; throw $exception;
} }
trigger_error(sprintf( trigger_error(
'%s::__toString exception: %s', sprintf(
self::class, (string) $exception), '%s::__toString exception: %s',
self::class,
(string) $exception
),
E_USER_ERROR E_USER_ERROR
); );
} }

View File

@ -66,11 +66,11 @@ class SerializerFactory implements FactoryInterface
$container = $this->container; $container = $this->container;
return SerializerBuilder::create() return SerializerBuilder::create()
->configureHandlers(function(HandlerRegistry $registry) use ($container) { ->configureHandlers(function (HandlerRegistry $registry) use ($container) {
$returnNull = function($visitor, $obj, array $type) { $returnNull = function ($visitor, $obj, array $type) {
return null; return null;
}; };
$returnSame = function($visitor, $obj, array $type) { $returnSame = function ($visitor, $obj, array $type) {
return $obj; return $obj;
}; };
@ -78,7 +78,7 @@ class SerializerFactory implements FactoryInterface
GraphNavigatorInterface::DIRECTION_SERIALIZATION, GraphNavigatorInterface::DIRECTION_SERIALIZATION,
'RequestDtoInterface', 'RequestDtoInterface',
'json', 'json',
function($visitor, $obj, array $type) use ($container) { function ($visitor, $obj, array $type) use ($container) {
/** @var SerializerInterface $serializer */ /** @var SerializerInterface $serializer */
$serializer = $container->get(Constants::SERIALIZER); $serializer = $container->get(Constants::SERIALIZER);
@ -95,7 +95,7 @@ class SerializerFactory implements FactoryInterface
GraphNavigatorInterface::DIRECTION_SERIALIZATION, GraphNavigatorInterface::DIRECTION_SERIALIZATION,
'RequestDtoInterface', 'RequestDtoInterface',
'xml', 'xml',
function($visitor, $obj, array $type) use ($container) { function ($visitor, $obj, array $type) use ($container) {
/** @var SerializerInterface $serializer */ /** @var SerializerInterface $serializer */
$serializer = $container->get(Constants::SERIALIZER); $serializer = $container->get(Constants::SERIALIZER);

View File

@ -136,7 +136,9 @@ abstract class BaseRequest
* *
* @return void * @return void
*/ */
final public function setMethod(string $method): void {} final public function setMethod(string $method): void
{
}
/** /**
* Should return method name for this request. * Should return method name for this request.