From 99c0da7f6d4f060df2461045ff2189666be4f8b6 Mon Sep 17 00:00:00 2001 From: Spomky Date: Fri, 8 Feb 2019 22:51:55 +0100 Subject: [PATCH 1/3] PHPStan error fixed --- composer.json | 9 ++++++++- phpstan.neon | 11 +++++++++++ src/DependencyInjection/Configuration.php | 3 +++ .../SpomkyLabsCborExtension.php | 7 ++++--- tests/AppKernel.php | 10 +++++++--- tests/Functional/DecodingTest.php | 14 ++++++++++---- 6 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 phpstan.neon diff --git a/composer.json b/composer.json index 2817155..629f7de 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,14 @@ "require-dev": { "symfony/framework-bundle": "^3.4|^4.0", "phpunit/phpunit": "^7.0", - "symfony/phpunit-bridge": "^4.1" + "symfony/phpunit-bridge": "^4.1", + "php-coveralls/php-coveralls": "^2.0", + "phpstan/phpstan": "^0.11", + "phpstan/phpstan-beberlei-assert": "^0.11.0", + "phpstan/phpstan-deprecation-rules": "^0.11", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-strict-rules": "^0.11", + "thecodingmachine/phpstan-safe-rule": "^0.1.2" }, "extra": { "branch-alias": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..c6986f7 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,11 @@ +parameters: + level: 7 + paths: + - src + - tests +includes: + - vendor/phpstan/phpstan-strict-rules/rules.neon + - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-deprecation-rules/rules.neon + - vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon + - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 8634af8..8ab7c42 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -18,6 +18,9 @@ class Configuration implements ConfigurationInterface { + /** + * @var string + */ private $alias; public function __construct(string $alias) diff --git a/src/DependencyInjection/SpomkyLabsCborExtension.php b/src/DependencyInjection/SpomkyLabsCborExtension.php index 1705ccd..2f4c633 100644 --- a/src/DependencyInjection/SpomkyLabsCborExtension.php +++ b/src/DependencyInjection/SpomkyLabsCborExtension.php @@ -20,6 +20,9 @@ class SpomkyLabsCborExtension extends Extension { + /** + * @var string + */ private $alias; public function __construct(string $alias) @@ -32,10 +35,8 @@ public function getAlias(): string return $this->alias; } - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { - $container->registerForAutoconfiguration(JWKSetSourceInterface::class)->addTag('jose.jwkset_source'); - $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.php'); } diff --git a/tests/AppKernel.php b/tests/AppKernel.php index 32f794b..58d7972 100644 --- a/tests/AppKernel.php +++ b/tests/AppKernel.php @@ -16,6 +16,7 @@ use SpomkyLabs\CborBundle\SpomkyLabsCborBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel; /** @@ -23,12 +24,15 @@ */ class AppKernel extends Kernel { - public function __construct(string $environment, bool $debug) + public function __construct(string $environment) { parent::__construct($environment, false); } - public function registerBundles() + /** + * @return BundleInterface[] + */ + public function registerBundles(): array { $bundles = [ new FrameworkBundle(), @@ -38,7 +42,7 @@ public function registerBundles() return $bundles; } - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); } diff --git a/tests/Functional/DecodingTest.php b/tests/Functional/DecodingTest.php index 8a7a0d3..f0d7c8f 100644 --- a/tests/Functional/DecodingTest.php +++ b/tests/Functional/DecodingTest.php @@ -11,11 +11,12 @@ * of the MIT license. See the LICENSE file for details. */ -namespace SpomkyLabs\CborBundle\Tests; +namespace SpomkyLabs\CborBundle\Tests\Functional; use CBOR\Decoder; use CBOR\StringStream; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\DependencyInjection\ContainerInterface; final class DecodingTest extends KernelTestCase { @@ -25,21 +26,26 @@ final class DecodingTest extends KernelTestCase public function theDecoderServiceIsAvailable(): void { static::bootKernel(); - static::assertTrue(static::$kernel->getContainer()->has(Decoder::class)); + $container = static::$kernel->getContainer(); + static::assertInstanceOf(ContainerInterface::class, $container); + static::assertTrue($container->has(Decoder::class)); } /** * @test * @depends theDecoderServiceIsAvailable * @dataProvider getInputs + * @param mixed $expectedNormalizedValue */ public function theDecoderCanDecodeInputs(string $data, $expectedNormalizedValue): void { static::bootKernel(); + $container = static::$kernel->getContainer(); + static::assertInstanceOf(ContainerInterface::class, $container); /** @var Decoder $decoder */ - $decoder = static::$kernel->getContainer()->get(Decoder::class); - $stream = new StringStream(hex2bin($data)); + $decoder = $container->get(Decoder::class); + $stream = new StringStream(\Safe\hex2bin($data)); $result = $decoder->decode($stream); static::assertEquals($expectedNormalizedValue, $result->getNormalizedData()); From 243b53a5f581bcbe0d719bcd59b0d69344db9c28 Mon Sep 17 00:00:00 2001 From: Spomky Date: Fri, 8 Feb 2019 22:52:30 +0100 Subject: [PATCH 2/3] Travis config updated --- .travis.yml | 62 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7cbec7..657eff9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,52 @@ +sudo: false language: php +php: + - 7.1 + - 7.2 + - 7.3 + - nightly + cache: directories: - - "$HOME/.composer/cache" - - "vendor" - -matrix: - allow_failures: - - php: nightly - fast_finish: true - include: - - php: 7.1 - env: deps=low - - php: 7.1 - - php: 7.2 - - php: nightly + - $HOME/.composer/cache + - vendor before_script: - mkdir -p build/logs - - composer self-update - - composer require --dev --no-update php-coveralls/php-coveralls "^2.0" - - if [[ $deps = low ]]; then composer update --no-interaction --prefer-lowest ; fi - - if [[ !$deps ]]; then composer install --no-interaction ; fi + +before_install: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" + +install: travis_retry composer install script: - - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml + - ./vendor/bin/phpunit + +jobs: + allow_failures: + - php: nightly + + include: + - stage: Metrics and quality + env: COVERAGE + before_script: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} + - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi + script: + - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml + after_script: + - ./vendor/bin/php-coveralls --no-interaction + + - stage: Metrics and quality + env: STATIC_ANALYSIS + script: + - ./vendor/bin/phpstan analyse -after_success: - - ./vendor/bin/php-coveralls --no-interaction + - stage: Security Check + env: SECURITY_CHECK + before_script: + - wget -c https://get.sensiolabs.org/security-checker.phar + - chmod +x security-checker.phar + script: + - ./security-checker.phar security:check From da5bf5b47f2fa7b09d6bdb5785861759994851cf Mon Sep 17 00:00:00 2001 From: Spomky Date: Fri, 8 Feb 2019 22:54:23 +0100 Subject: [PATCH 3/3] PHP 8 allowed --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 629f7de..f3f6a35 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ } }, "require": { - "php": "^7.1", + "php": "^7.1|^8.0", "spomky-labs/cbor-php": "^1.0", "symfony/config": "^3.4|^4.0", "symfony/dependency-injection": "^3.4|^4.0",