Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ These code standards are extendable, all you need to do is create your own `ecs.
```php
<?php

declare(strict_types=1);

use JumpTwentyFour\PhpCodingStandards\Support\ConfigHelper;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

Expand All @@ -49,5 +52,20 @@ return static function (ContainerConfigurator $containerConfigurator): void {
__DIR__ . '/app',
__DIR__ . '/tests',
]);

$jumpSkips = ConfigHelper::make()->getParameter(Option::SKIP);

$ecsConfig->skip(array_merge($jumpSkips, [
UnusedParameterSniff::class => [
__DIR__ . '/app/Console/Kernel.php',
__DIR__ . '/app/Exceptions/Handler.php',
],
'Unused parameter $attributes.' => [
__DIR__ . '/database/*.php',
],
CamelCapsFunctionNameSniff::class => [
'/tests/**',
],
]));
};
```
31 changes: 31 additions & 0 deletions src/Support/ConfigHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace JumpTwentyFour\PhpCodingStandards\Support;

use ReflectionObject;
use Symplify\EasyCodingStandard\Config\ECSConfig;

class ConfigHelper
{
public function __construct(private ECSConfig $config)
{
}

public static function make(ECSConfig $config): self
{
return new self($config);
}

public function getParameter(string $name): mixed
{
$reflectedConfig = new ReflectionObject($this->config);

$containerProperty = $reflectedConfig->getParentClass()->getProperty('container');

$containerProperty->setAccessible(true);

return $containerProperty->getValue($this->config)->getParameter($name);
}
}