Skip to content

Commit

Permalink
feat: add code style PSR-12
Browse files Browse the repository at this point in the history
  • Loading branch information
Yozhef committed Apr 30, 2021
1 parent b417880 commit 00a08f5
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
build
vendor
/composer.lock
/.phpcs-cache
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "3.5.*"
},
"autoload": {
"psr-4": {
Expand All @@ -43,5 +44,11 @@
}
},
"scripts": {
"cs": [
"vendor/bin/phpcs"
],
"cs-fix": [
"vendor/bin/phpcbf"
]
}
}
41 changes: 41 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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=".phpcs-cache"/>
<arg name="colors"/>
<arg value="p"/>
<arg name="extensions" value="php"/>
<arg name="tab-width" value="4"/>
<arg name="report-width" value="120"/>

<rule ref="PSR12" />

<file>src/</file>
<file>tests/</file>

<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Generic.PHP.RequireStrictTypes"/>
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"></rule>
<rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamType"></rule>

<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array" value="eval=>NULL,dd=>NULL,die=>NULL,var_dump=>NULL,dump=>NULL,sizeof=>count,delete=>unset,print=>echo,echo=>NULL,print_r=>NULL,create_function=>NULL"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0" />
<property name="spacingAfterLast" value="0" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false" />
</properties>
</rule>
</ruleset>
4 changes: 2 additions & 2 deletions src/Check/DoctrineCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(ContainerInterface $container)
public function check(): array
{
$entityManager = $this->container->get('doctrine.orm.entity_manager');

if ($entityManager === false) {
throw new ServiceNotFoundException('Entity Manager Not Found.');
}
Expand All @@ -35,7 +35,7 @@ public function check(): array
} catch (Throwable $e) {
return [self::CHECK_RESULT_KEY => false];
}

return [self::CHECK_RESULT_KEY => true];
}
}
4 changes: 2 additions & 2 deletions src/Controller/HealthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ final class HealthController extends AbstractController
* @var array<CheckInterface>
*/
private array $healthChecks = [];

public function addHealthCheck(CheckInterface $healthCheck): void
{
$this->healthChecks[] = $healthCheck;
}

/**
* @Route(
* path="/health",
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/SymfonyHealthCheckExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public function load(array $configs, ContainerBuilder $container): void

$this->loadHealthChecks($config, $loader, $container);
}

private function loadHealthChecks(
array $config,
XmlFileLoader $loader,
ContainerBuilder $container
): void {
$loader->load('health_checks.xml');

$healthCheckCollection = $container->findDefinition(HealthController::class);
foreach ($config['health_checks'] as $healthCheckConfig) {
$healthCheckDefinition = $container->findDefinition($healthCheckConfig['id']);
Expand Down
9 changes: 4 additions & 5 deletions src/Exception/AbstractException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
abstract class AbstractException extends Exception implements ParameterExceptionInterface
{
private array $parameters;

public function __construct(
string $message,
array $parameters = [],
int $code = 0,
Throwable $previous = null
)
{
) {
$this->parameters = $parameters;

parent::__construct($message, $code, $previous);
}

public function getParameters(): array
{
return $this->parameters;
Expand Down

0 comments on commit 00a08f5

Please sign in to comment.