From f0c58fc06fc2bbbc3d7a7d90ad925c557fd4d3b6 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Mon, 11 May 2020 09:26:50 +0200 Subject: [PATCH] Fix PHPStan warnings. --- .github/workflows/continuous-integration.yml | 87 +++++++++++--------- composer.json | 7 +- src/Combinatorics.php | 3 - src/Generators/Fibonacci.php | 3 - src/Generators/NGrams.php | 3 - src/Generators/Perfect.php | 3 - src/Generators/Permutations.php | 3 - src/Generators/Prime.php | 3 - src/Generators/PrimeFactors.php | 3 - src/Generators/Product.php | 3 - src/Generators/Shift.php | 3 - src/Iterators.php | 5 +- src/Iterators/Combinations.php | 7 +- src/Iterators/Cycle.php | 7 +- src/Iterators/Fibonacci.php | 9 +- src/Iterators/FiniteGroup.php | 8 ++ src/Iterators/NGrams.php | 7 +- src/Iterators/Perfect.php | 11 ++- src/Iterators/Prime.php | 11 ++- src/Iterators/PrimeFactors.php | 9 +- src/Iterators/Product.php | 9 +- src/Iterators/Rotation.php | 7 +- src/Iterators/Shift.php | 9 +- 23 files changed, 119 insertions(+), 101 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ad87565..ddc1b5d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,44 +1,57 @@ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions on: - - pull_request - - push + - pull_request + - push name: "Continuous Integration" jobs: - grumphp: - name: "Grumphp" - - runs-on: ubuntu-latest - - strategy: - matrix: - php-binary: - - php7.1 - - php7.2 - - php7.3 - - steps: - - name: "Checkout" - uses: actions/checkout@master - with: - fetch-depth: 1 - - - name: "Composer install" - run: ${{ matrix.php-binary }} $(which composer) install --no-interaction --no-progress --no-suggest - - - name: "Composer install lowest dependencies" - if: matrix.dependencies == 'lowest' - run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest --prefer-lowest - - - name: "Install Graphviz" - run: sudo apt-get install graphviz - - - name: "Run Grumphp" - run: ${{ matrix.php-binary }} vendor/bin/grumphp run - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - - - name: "Scrutinizer" - run: wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml + run: + name: "Grumphp" + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macOS-latest] + php-versions: ['7.1', '7.2', '7.3', '7.4'] + + steps: + - name: Checkout + uses: actions/checkout@master + with: + fetch-depth: 1 + + - name: Install PHP + uses: shivammathur/setup-php@master + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring,xdebug + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader + + - name: Run Grumphp + run: vendor/bin/grumphp run --no-ansi -n + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + + - name: Send PSALM data + run: vendor/bin/psalm --shepherd --stats + continue-on-error: true + + - name: Scrutinizer + run: | + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml + continue-on-error: true diff --git a/composer.json b/composer.json index a20fc6a..86870c8 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "product" ], "homepage": "https://github.com/drupol/phpermutations", - "license": "GPL-3.0-only", + "license": "MIT", "authors": [ { "name": "Pol Dellaiera", @@ -24,10 +24,9 @@ "php": ">= 7.1.3" }, "require-dev": { - "drupol/php-conventions": "^1.6.8", + "drupol/php-conventions": "^1.7.1", "phpunit/php-code-coverage": "^4 || ^5", - "phpunit/phpunit": "^6 || ^7", - "symfony/process": "^4.4.1" + "phpunit/phpunit": "^6 || ^7" }, "config": { "sort-packages": true diff --git a/src/Combinatorics.php b/src/Combinatorics.php index d0da466..23156a2 100644 --- a/src/Combinatorics.php +++ b/src/Combinatorics.php @@ -6,9 +6,6 @@ use function count; -/** - * Class Combinatorics. - */ abstract class Combinatorics { /** diff --git a/src/Generators/Fibonacci.php b/src/Generators/Fibonacci.php index e15ce00..ba81d89 100644 --- a/src/Generators/Fibonacci.php +++ b/src/Generators/Fibonacci.php @@ -8,9 +8,6 @@ use drupol\phpermutations\Iterators\Fibonacci as FibonacciIterator; use Generator; -/** - * Class Fibonacci. - */ class Fibonacci extends FibonacciIterator implements GeneratorInterface { /** diff --git a/src/Generators/NGrams.php b/src/Generators/NGrams.php index 127f5dd..9b92f31 100644 --- a/src/Generators/NGrams.php +++ b/src/Generators/NGrams.php @@ -8,9 +8,6 @@ use drupol\phpermutations\Iterators\NGrams as NGramsIterator; use Generator; -/** - * Class NGrams. - */ class NGrams extends NGramsIterator implements GeneratorInterface { /** diff --git a/src/Generators/Perfect.php b/src/Generators/Perfect.php index 9a28d30..171536d 100644 --- a/src/Generators/Perfect.php +++ b/src/Generators/Perfect.php @@ -7,9 +7,6 @@ use drupol\phpermutations\GeneratorInterface; use drupol\phpermutations\Iterators\Perfect as PerfectIterator; -/** - * Class Perfect. - */ class Perfect extends PerfectIterator implements GeneratorInterface { /** diff --git a/src/Generators/Permutations.php b/src/Generators/Permutations.php index 5065594..4e63971 100644 --- a/src/Generators/Permutations.php +++ b/src/Generators/Permutations.php @@ -10,9 +10,6 @@ use function count; -/** - * Class Permutations. - */ class Permutations extends Combinatorics implements GeneratorInterface { /** diff --git a/src/Generators/Prime.php b/src/Generators/Prime.php index 35253b9..cc91f32 100644 --- a/src/Generators/Prime.php +++ b/src/Generators/Prime.php @@ -7,9 +7,6 @@ use drupol\phpermutations\GeneratorInterface; use drupol\phpermutations\Iterators\Prime as PrimeIterator; -/** - * Class Prime. - */ class Prime extends PrimeIterator implements GeneratorInterface { /** diff --git a/src/Generators/PrimeFactors.php b/src/Generators/PrimeFactors.php index 25be5db..80eae06 100644 --- a/src/Generators/PrimeFactors.php +++ b/src/Generators/PrimeFactors.php @@ -7,9 +7,6 @@ use drupol\phpermutations\GeneratorInterface; use drupol\phpermutations\Iterators\PrimeFactors as PrimeFactorsIterator; -/** - * Class PrimeFactors. - */ class PrimeFactors extends PrimeFactorsIterator implements GeneratorInterface { /** diff --git a/src/Generators/Product.php b/src/Generators/Product.php index 3250a44..fd52f3c 100644 --- a/src/Generators/Product.php +++ b/src/Generators/Product.php @@ -10,9 +10,6 @@ use function count; -/** - * Class Product. - */ class Product extends ProductIterator implements GeneratorInterface { /** diff --git a/src/Generators/Shift.php b/src/Generators/Shift.php index 2b5d4c6..ef1f584 100644 --- a/src/Generators/Shift.php +++ b/src/Generators/Shift.php @@ -7,9 +7,6 @@ use drupol\phpermutations\GeneratorInterface; use drupol\phpermutations\Iterators\Shift as ShiftIterator; -/** - * Class Shift. - */ class Shift extends ShiftIterator implements GeneratorInterface { /** diff --git a/src/Iterators.php b/src/Iterators.php index dfb8c48..093606f 100644 --- a/src/Iterators.php +++ b/src/Iterators.php @@ -6,9 +6,6 @@ use Countable; -/** - * Class Iterators. - */ abstract class Iterators extends Combinatorics implements Countable, IteratorInterface { /** @@ -41,6 +38,8 @@ public function key() /** * {@inheritdoc} + * + * @return void */ public function rewind() { diff --git a/src/Iterators/Combinations.php b/src/Iterators/Combinations.php index b2221a6..e4a9dca 100644 --- a/src/Iterators/Combinations.php +++ b/src/Iterators/Combinations.php @@ -6,9 +6,6 @@ use drupol\phpermutations\Iterators; -/** - * Class Combinations. - */ class Combinations extends Iterators { /** @@ -62,6 +59,8 @@ public function current() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -83,6 +82,8 @@ public function rewind() /** * {@inheritdoc} + * + * @return bool */ public function valid() { diff --git a/src/Iterators/Cycle.php b/src/Iterators/Cycle.php index a0583cf..f933f11 100644 --- a/src/Iterators/Cycle.php +++ b/src/Iterators/Cycle.php @@ -8,9 +8,6 @@ use function count; -/** - * Class Cycle. - */ class Cycle extends Iterators { /** @@ -31,6 +28,8 @@ public function current() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -47,6 +46,8 @@ public function rewind() /** * {@inheritdoc} + * + * @return bool */ public function valid() { diff --git a/src/Iterators/Fibonacci.php b/src/Iterators/Fibonacci.php index 7112ddb..c382e82 100644 --- a/src/Iterators/Fibonacci.php +++ b/src/Iterators/Fibonacci.php @@ -8,9 +8,6 @@ use const PHP_INT_MAX; -/** - * Class Fibonacci. - */ class Fibonacci extends Iterators { /** @@ -54,6 +51,8 @@ public function getMaxLimit() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -76,6 +75,8 @@ public function rewind() * * @param int $max * The limit + * + * @return void */ public function setMaxLimit($max) { @@ -84,6 +85,8 @@ public function setMaxLimit($max) /** * {@inheritdoc} + * + * @return bool */ public function valid() { diff --git a/src/Iterators/FiniteGroup.php b/src/Iterators/FiniteGroup.php index 331a1a2..45a9c89 100644 --- a/src/Iterators/FiniteGroup.php +++ b/src/Iterators/FiniteGroup.php @@ -61,6 +61,8 @@ public function getSize() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -94,6 +96,8 @@ public function order($generator) * * @param int $size * The size + * + * @return void */ public function setSize($size) { @@ -103,6 +107,8 @@ public function setSize($size) /** * {@inheritdoc} + * + * @return bool */ public function valid() { @@ -111,6 +117,8 @@ public function valid() /** * Clean out the group from unwanted values. + * + * @return void */ private function computeGroup() { diff --git a/src/Iterators/NGrams.php b/src/Iterators/NGrams.php index 4bc0a36..c39f9e2 100644 --- a/src/Iterators/NGrams.php +++ b/src/Iterators/NGrams.php @@ -6,9 +6,6 @@ use function array_slice; -/** - * Class NGrams. - */ class NGrams extends Shift { /** @@ -45,6 +42,8 @@ public function current() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -54,6 +53,8 @@ public function next() /** * {@inheritdoc} + * + * @return void */ public function rewind() { diff --git a/src/Iterators/Perfect.php b/src/Iterators/Perfect.php index 57f4b30..5140002 100644 --- a/src/Iterators/Perfect.php +++ b/src/Iterators/Perfect.php @@ -8,9 +8,6 @@ use const PHP_INT_MAX; -/** - * Class Perfect. - */ class Perfect extends Iterators { /** @@ -77,6 +74,8 @@ public function getMinLimit() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -96,6 +95,8 @@ public function rewind() * * @param int $max * The limit + * + * @return void */ public function setMaxLimit($max) { @@ -107,6 +108,8 @@ public function setMaxLimit($max) * * @param int $min * The limit + * + * @return void */ public function setMinLimit($min) { @@ -115,6 +118,8 @@ public function setMinLimit($min) /** * {@inheritdoc} + * + * @return bool */ public function valid() { diff --git a/src/Iterators/Prime.php b/src/Iterators/Prime.php index adb90bd..e0ef377 100644 --- a/src/Iterators/Prime.php +++ b/src/Iterators/Prime.php @@ -8,9 +8,6 @@ use const PHP_INT_MAX; -/** - * Class Prime. - */ class Prime extends Iterators { /** @@ -77,6 +74,8 @@ public function getMinLimit() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -96,6 +95,8 @@ public function rewind() * * @param int $max * The limit + * + * @return void */ public function setMaxLimit($max) { @@ -107,6 +108,8 @@ public function setMaxLimit($max) * * @param int $min * The limit + * + * @return void */ public function setMinLimit($min) { @@ -115,6 +118,8 @@ public function setMinLimit($min) /** * {@inheritdoc} + * + * @return bool */ public function valid() { diff --git a/src/Iterators/PrimeFactors.php b/src/Iterators/PrimeFactors.php index c074615..22f8635 100644 --- a/src/Iterators/PrimeFactors.php +++ b/src/Iterators/PrimeFactors.php @@ -8,9 +8,6 @@ use function count; -/** - * Class PrimeFactors. - */ class PrimeFactors extends Iterators { /** @@ -59,6 +56,8 @@ public function getNumber() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -79,6 +78,8 @@ public function rewind() * * @param int $number * The number + * + * @return void */ public function setNumber($number) { @@ -88,6 +89,8 @@ public function setNumber($number) /** * {@inheritdoc} + * + * @return bool */ public function valid() { diff --git a/src/Iterators/Product.php b/src/Iterators/Product.php index cf31565..e1741bc 100644 --- a/src/Iterators/Product.php +++ b/src/Iterators/Product.php @@ -10,9 +10,6 @@ use function count; -/** - * Class Product. - */ class Product extends Iterators { /** @@ -69,6 +66,8 @@ public function current() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -93,6 +92,8 @@ public function next() /** * {@inheritdoc} + * + * @return void */ public function rewind() { @@ -105,6 +106,8 @@ public function rewind() /** * {@inheritdoc} + * + * @return bool */ public function valid() { diff --git a/src/Iterators/Rotation.php b/src/Iterators/Rotation.php index 62860aa..e688b63 100644 --- a/src/Iterators/Rotation.php +++ b/src/Iterators/Rotation.php @@ -9,9 +9,6 @@ use function array_slice; use function count; -/** - * Class Rotation. - */ class Rotation extends Iterators { /** @@ -54,6 +51,8 @@ public function current() * * @param int|null $offset * The offset + * + * @return void */ public function next($offset = 1) { @@ -81,6 +80,8 @@ public function rewind() /** * {@inheritdoc} + * + * @return bool */ public function valid() { diff --git a/src/Iterators/Shift.php b/src/Iterators/Shift.php index 21a6945..f82a7eb 100644 --- a/src/Iterators/Shift.php +++ b/src/Iterators/Shift.php @@ -9,9 +9,6 @@ use function array_slice; use function count; -/** - * Class Shift. - */ class Shift extends Iterators { /** @@ -38,6 +35,8 @@ public function count() /** * {@inheritdoc} + * + * @return void */ public function next() { @@ -54,6 +53,8 @@ public function rewind() /** * {@inheritdoc} + * + * @return bool */ public function valid() { @@ -64,6 +65,8 @@ public function valid() * Internal function to do the shift. * * @param int $length + * + * @return void */ protected function doShift($length = 1) {