diff --git a/.gitignore b/.gitignore index e1d3f3c..db0383e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -phpunit/ -vendor/ -composer.lock -.php_cs.cache - +.DS_Store .idea/ +.phpunit.result.cache +.vscode/ +build/ +composer.lock +vendor/ diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..bd0754e --- /dev/null +++ b/.php_cs @@ -0,0 +1,38 @@ +files() + ->name('*.php') + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/tests') +; + +return PhpCsFixer\Config::create() + ->setIndent(" ") + ->setLineEnding("\n") + ->setRules([ + '@DoctrineAnnotation' => true, + '@PhpCsFixer' => true, + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + 'declare_strict_types' => true, + 'dir_constant' => true, + 'final_class' => true, + 'is_null' => true, + 'linebreak_after_opening_tag' => true, + 'list_syntax' => true, + 'method_chaining_indentation' => false, + 'no_php4_constructor' => true, + 'ordered_interfaces' => true, + 'php_unit_dedicate_assert_internal_type' => true, + 'php_unit_dedicate_assert' => true, + 'php_unit_expectation' => true, + 'php_unit_mock' => true, + 'php_unit_namespaced' => true, + 'php_unit_no_expectation_annotation' => true, + 'single_line_throw' => false, + 'ternary_to_null_coalescing' => true, + ]) + ->setRiskyAllowed(true) + ->setFinder($finder) +; diff --git a/.travis.yml b/.travis.yml index 8eb342c..b5c092f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,20 +5,30 @@ matrix: - php: 7.0 env: dependencies=lowest - php: 7.0 - env: dependencies=highest - php: 7.1 env: dependencies=lowest - php: 7.1 - env: dependencies=highest - php: 7.2 env: dependencies=lowest - php: 7.2 - env: dependencies=highest + - php: 7.3 + env: dependencies=lowest + - php: 7.3 + - php: 7.4snapshot + env: dependencies=lowest + - php: 7.4snapshot + allow_failures: + - php: 7.4snapshot before_script: + - echo 'extension=apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/apcu.ini + - echo 'Europe/Zurich' | sudo tee /etc/timezone + - echo 'date.timezone = "Europe/Zurich"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - composer self-update -q - - if [ -z "$dependencies" ]; then composer install; fi; + - composer global require hirak/prestissimo + - if [ -z "$dependencies" ]; then composer update -n; fi; - if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest -n; fi; - - if [ "$dependencies" = "highest" ]; then composer update -n; fi; -script: vendor/bin/phpunit --coverage-text --verbose +script: + - composer test + - vendor/bin/php-coveralls --coverage_clover=build/phpunit/phpunit.clover.xml --json_path=build/coveralls.json -v diff --git a/README.md b/README.md index d3cc12d..2b31816 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # chubbyphp-lazy-command [![Build Status](https://api.travis-ci.org/chubbyphp/chubbyphp-lazy-command.png?branch=master)](https://travis-ci.org/chubbyphp/chubbyphp-lazy-command) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/chubbyphp/chubbyphp-lazy-command/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/chubbyphp/chubbyphp-lazy-command/?branch=master) -[![Code Coverage](https://scrutinizer-ci.com/g/chubbyphp/chubbyphp-lazy-command/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/chubbyphp/chubbyphp-lazy-command/?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/chubbyphp/chubbyphp-lazy-command/badge.svg?branch=master)](https://coveralls.io/github/chubbyphp/chubbyphp-lazy-command?branch=master) [![Total Downloads](https://poser.pugx.org/chubbyphp/chubbyphp-lazy-command/downloads.png)](https://packagist.org/packages/chubbyphp/chubbyphp-lazy-command) [![Monthly Downloads](https://poser.pugx.org/chubbyphp/chubbyphp-lazy-command/d/monthly)](https://packagist.org/packages/chubbyphp/chubbyphp-lazy-command) [![Latest Stable Version](https://poser.pugx.org/chubbyphp/chubbyphp-lazy-command/v/stable.png)](https://packagist.org/packages/chubbyphp/chubbyphp-lazy-command) @@ -14,16 +13,16 @@ Allow to lazyload commands. ## Requirements - * php: ~7.0 - * psr/container: ~1.0 - * symfony/console: ~2.3|~3.0|~4.0 + * php: ^7.0 + * psr/container: ^1.0 + * symfony/console: ^2.8|^3.4|^4.2|^5.0 ## Installation Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-lazy-command][1]. ```sh -composer require chubbyphp/chubbyphp-lazy-command "~1.2" +composer require chubbyphp/chubbyphp-lazy-command "^1.3" ``` ## Usage @@ -89,4 +88,4 @@ $command->run(); ## Copyright -Dominik Zogg 2016 +Dominik Zogg 2019 diff --git a/composer.json b/composer.json index ff153a1..fe3ce8e 100644 --- a/composer.json +++ b/composer.json @@ -10,20 +10,41 @@ } ], "require": { - "php": "~7.0", + "php": "^7.0", "psr/container": "^1.0", - "symfony/console": "~2.3|~3.0|~4.0" + "symfony/console": "^2.8|^3.4|^4.2|^5.0" }, "require-dev": { - "phpunit/phpunit": "^6.5.8", - "container-interop/container-interop": "~1.2" + "container-interop/container-interop": "^1.2", + "friendsofphp/php-cs-fixer": "^2.16", + "phpunit/phpunit": "^6.5.14|^7.5.17|^8.4.3", + "php-coveralls/php-coveralls": "^2.1", + "phploc/phploc": "^4.0.1||^5.0" }, "autoload": { "psr-4": { "Chubbyphp\\Lazy\\": "src/" } }, + "autoload-dev": { + "psr-4": { "Chubbyphp\\Tests\\Lazy\\": "tests/" } + }, "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } + }, + "scripts": { + "fix:cs": "mkdir -p build && vendor/bin/php-cs-fixer fix --cache-file=build/phpcs.cache", + "test": [ + "@test:lint", + "@test:unit", + "@test:integration", + "@test:loc", + "@test:cs" + ], + "test:cs": "mkdir -p build && vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --cache-file=build/phpcs.cache", + "test:integration": "vendor/bin/phpunit --testsuite=Integration", + "test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log", + "test:loc": "mkdir -p build && vendor/bin/phploc src --verbose | tee build/phploc.log", + "test:unit": "phpdbg -qrr vendor/bin/phpunit --testsuite=Unit --coverage-text --coverage-clover=build/phpunit/phpunit.clover.xml --coverage-html=build/phpunit/coverage-html --coverage-xml=build/phpunit/coverage-xml --log-junit=build/phpunit/phpunit.junit.xml" } } diff --git a/phpunit.xml.dist b/phpunit.xml similarity index 66% rename from phpunit.xml.dist rename to phpunit.xml index 9fb42a5..e13e7e7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml @@ -5,14 +5,16 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" + executionOrder="random" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" - bootstrap="tests/bootstrap.php" > - - ./tests + + ./tests/Integration + + + ./tests/Unit @@ -20,7 +22,4 @@ ./src - - - diff --git a/src/CommandAdapter.php b/src/CommandAdapter.php index c670bde..ed81c1b 100644 --- a/src/CommandAdapter.php +++ b/src/CommandAdapter.php @@ -15,18 +15,12 @@ final class CommandAdapter */ private $command; - /** - * @param Command $command - */ public function __construct(Command $command) { $this->command = $command; } /** - * @param InputInterface $input - * @param OutputInterface $output - * * @return int|null */ public function __invoke(InputInterface $input, OutputInterface $output) diff --git a/src/LazyCommand.php b/src/LazyCommand.php index fe76ad3..6ba142c 100644 --- a/src/LazyCommand.php +++ b/src/LazyCommand.php @@ -21,14 +21,6 @@ final class LazyCommand extends Command */ private $serviceId; - /** - * @param ContainerInterface $container - * @param string $serviceId - * @param string $name - * @param array $definition - * @param string|null $description - * @param string|null $help - */ public function __construct( ContainerInterface $container, string $serviceId, @@ -48,9 +40,6 @@ public function __construct( } /** - * @param Input $input - * @param Output $output - * * @return int|null */ protected function execute(Input $input, Output $output) diff --git a/tests/CommandAdapterTest.php b/tests/Unit/CommandAdapterTest.php similarity index 89% rename from tests/CommandAdapterTest.php rename to tests/Unit/CommandAdapterTest.php index 005c5e5..29b6c25 100644 --- a/tests/CommandAdapterTest.php +++ b/tests/Unit/CommandAdapterTest.php @@ -1,6 +1,8 @@ writeln($input->getArgument('name')); diff --git a/tests/LazyCommandTest.php b/tests/Unit/LazyCommandTest.php similarity index 94% rename from tests/LazyCommandTest.php rename to tests/Unit/LazyCommandTest.php index fd814d4..0c78966 100644 --- a/tests/LazyCommandTest.php +++ b/tests/Unit/LazyCommandTest.php @@ -1,6 +1,8 @@ run($input, $output)); } - /** - * @param array $services - * - * @return InteropContainerInterface - */ private function getInteroptContainer(array $services): InteropContainerInterface { /** @var InteropContainerInterface|MockObject $container */ @@ -95,11 +94,6 @@ private function getInteroptContainer(array $services): InteropContainerInterfac return $container; } - /** - * @param array $services - * - * @return PsrContainerInterface - */ private function getPsrContainer(array $services): PsrContainerInterface { /** @var PsrContainerInterface|MockObject $container */ diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index 1f81eda..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,4 +0,0 @@ -setPsr4('Chubbyphp\Tests\Lazy\\', __DIR__);