diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1e56444..6d3c219 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,3 +25,5 @@ jobs: run: vendor/bin/phpunit - name: Check Code Styles run: vendor/bin/ecs + - name: Check PHPStan + run: vendor/bin/phpstan analyze src tests --level 5 diff --git a/Makefile b/Makefile index fd24f70..0c05564 100644 --- a/Makefile +++ b/Makefile @@ -29,4 +29,11 @@ install: ecs: vendor/bin/ecs --fix +## run tests +test: + vendor/bin/phpunit + +## run phpstan +phpstan: + vendor/bin/phpstan analyze src tests --level 5 diff --git a/composer.json b/composer.json index d6e448c..a2b2e03 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,11 @@ }, "require-dev": { "whatwedo/php-coding-standard": "^1.0", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^1.10", + "symfony/http-kernel": "^7.0", + "symfony/dependency-injection": "^7.0", + "symfony/config": "^7.0" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..31f6166 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 1 + paths: + - src + - tests diff --git a/src/DependencyInjection/whatwedoTwigBootstrapIconsExtension.php b/src/DependencyInjection/whatwedoTwigBootstrapIconsExtension.php index dbf34e2..116a10c 100644 --- a/src/DependencyInjection/whatwedoTwigBootstrapIconsExtension.php +++ b/src/DependencyInjection/whatwedoTwigBootstrapIconsExtension.php @@ -11,9 +11,9 @@ class whatwedoTwigBootstrapIconsExtension extends Extension { - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { - $loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__) . '/Resources/config')); + $loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config')); $loader->load('config.php'); } } diff --git a/src/Twig/BootstrapIconsExtensions.php b/src/Twig/BootstrapIconsExtensions.php index 8360022..7af93d2 100644 --- a/src/Twig/BootstrapIconsExtensions.php +++ b/src/Twig/BootstrapIconsExtensions.php @@ -15,7 +15,7 @@ class BootstrapIconsExtensions extends AbstractExtension /** * @return TwigFunction[] */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('bootstrap_icon', [$this, 'getIcon'], [ @@ -33,12 +33,12 @@ public function getIcon(string $icon, array $attributes = []) } array_walk($attributes, static function (&$val, $key) { - $val = $key . '="' . $val . '" '; + $val = $key.'="'.$val.'" '; }); return str_replace( ' $loader) { - $installed = require $vendorDir . '/composer/installed.php'; + $installed = require $vendorDir.'/composer/installed.php'; if (isset($installed['versions']['twbs/bootstrap-icons'])) { - return static::$iconsPath = $vendorDir . '/twbs/bootstrap-icons'; + return static::$iconsPath = $vendorDir.'/twbs/bootstrap-icons'; } }