diff --git a/.travis.yml b/.travis.yml index 8f31f83..5d2e736 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ install: script: - vendor/bin/simple-phpunit --coverage-clover coverage.xml - composer cs:dry + - composer phpstan after_script: - wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar diff --git a/CHANGELOG-3.x.md b/CHANGELOG-3.x.md index 25332bd..e8fa684 100644 --- a/CHANGELOG-3.x.md +++ b/CHANGELOG-3.x.md @@ -4,3 +4,4 @@ * Fixed compatibility with Symfony 5 * Dropped compatibility with Symfony < 4.4 * Dropped support for PHP < 7.2 +* Added php-cs-fixer & phpstan diff --git a/README.md b/README.md index b345dff..f79224b 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Note there are a few helpers to maintain code quality, that you can run using th ```bash composer cs:dry # Code style check +composer phpstan # Static analysis vendor/bin/simple-phpunit # Run tests ``` diff --git a/composer.json b/composer.json index f39cda9..aa45112 100644 --- a/composer.json +++ b/composer.json @@ -33,19 +33,21 @@ "symfony/http-kernel": "^4.4|^5.0", "symfony/routing": "^4.4|^5.0", "symfony/translation": "^4.4|^5.0", - "symfony/validator": "^4.4|^5.0", "symfony/twig-bundle": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", "twig/twig": "^2.9|^3.0" }, "require-dev": { + "doctrine/data-fixtures": "^1.0", "friendsofphp/php-cs-fixer": "^2.16.1", "fzaninotto/faker": "^1.1", - "doctrine/data-fixtures": "^1.0", + "phpstan/phpstan": "^0.12.4", "symfony/phpunit-bridge": "^4.4|^5.0" }, "scripts": { "cs:dry": "php-cs-fixer fix --diff --diff-format=udiff --dry-run --no-interaction --ansi", - "cs:fix": "php-cs-fixer fix --ansi" + "cs:fix": "php-cs-fixer fix --ansi", + "phpstan": "vendor/bin/phpstan analyse --ansi" }, "autoload": { "psr-4": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..274991f --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,9 @@ +parameters: + autoload_directories: + - vendor/bin/.phpunit/phpunit-8.3-0/src + paths: + - src + - tests + level: 0 + ignoreErrors: + - '#^Class Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType not found.$#' diff --git a/src/Datalist/Filter/Type/EntityFilterType.php b/src/Datalist/Filter/Type/EntityFilterType.php index d1692f3..0a98562 100644 --- a/src/Datalist/Filter/Type/EntityFilterType.php +++ b/src/Datalist/Filter/Type/EntityFilterType.php @@ -40,6 +40,10 @@ public function buildForm(FormBuilderInterface $builder, DatalistFilterInterface } } + if (!class_exists(EntityType::class)) { + throw new \LogicException('You can not use the EntityFilterType as Doctrine bridge is not installed.'); + } + $builder->add($filter->getName(), EntityType::class, $formOptions); } diff --git a/src/Form/Type/RecaptchaType.php b/src/Form/Type/RecaptchaType.php index ee36f31..073c481 100644 --- a/src/Form/Type/RecaptchaType.php +++ b/src/Form/Type/RecaptchaType.php @@ -46,6 +46,8 @@ class RecaptchaType extends AbstractType */ protected $localeResolver; + protected $scripts = []; + /** * @param string $publicKey Recaptcha public key * @param bool $enabled Recaptache status diff --git a/src/Listener/RequestListener.php b/src/Listener/RequestListener.php index 641a4bd..9e8e38f 100644 --- a/src/Listener/RequestListener.php +++ b/src/Listener/RequestListener.php @@ -2,16 +2,8 @@ namespace Leapt\CoreBundle\Listener; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; -if (!class_exists(RequestEvent::class)) { - class_alias(GetResponseEvent::class, RequestEvent::class); -} - -/** - * Class RequestListener. - */ class RequestListener { public function onKernelRequest(RequestEvent $event)