diff --git a/.gitattributes b/.gitattributes index b3675d0..257ddcd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,7 +6,7 @@ core.autocrlf=lf .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore -.php_cs export-ignore +.php-cs-fixer.dist.php export-ignore .github export-ignore phpunit.xml.dist export-ignore /tests export-ignore diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.md b/.github/ISSUE_TEMPLATE/1_Bug_report.md new file mode 100644 index 0000000..1e26723 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/1_Bug_report.md @@ -0,0 +1,20 @@ +--- +name: "\U0001F41B Bug Report" +about: Report errors and problems +title: "[bug] " +labels: Potential Bug +assignees: '' + +--- + +**Description** + + +**How to reproduce** + + +**Possible Solution** + + +**Additional context** + diff --git a/.github/ISSUE_TEMPLATE/2_Feature_request.md b/.github/ISSUE_TEMPLATE/2_Feature_request.md new file mode 100644 index 0000000..c21e708 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/2_Feature_request.md @@ -0,0 +1,15 @@ +--- +name: "\U0001F680 Feature Request" +about: "I have a suggestion (and may want to implement it \U0001F642)!" +title: "[Feature] " +labels: Feature +assignees: '' + +--- + +**Description** + + +**Example** + diff --git a/.github/ISSUE_TEMPLATE/3_Support_question.md b/.github/ISSUE_TEMPLATE/3_Support_question.md new file mode 100644 index 0000000..f933bf2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/3_Support_question.md @@ -0,0 +1,13 @@ +--- +name: 👩‍🏫 Support Question +about: Questions about using this library +labels: Question / Support + +--- + +**Description** + diff --git a/.github/ISSUE_TEMPLATE/4_Security_issue.md b/.github/ISSUE_TEMPLATE/4_Security_issue.md new file mode 100644 index 0000000..ea75484 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/4_Security_issue.md @@ -0,0 +1,14 @@ +--- +name: ⛔ Security Issue +about: Report security issues and problems (PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY) + +--- + +⚠ PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, SEE BELOW. + +If you have found a security issue in this project, please send the details to +security [at] rollerscapes.net and don't disclose it publicly until we can provide a +fix for it. + +**Note:** Please don't blindly send reports about automated tools, make sure the +reported issue is in fact exploitable. Thanks. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..da9f029 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +| Q | A +| ------------- | --- +| Bug fix? | yes/no +| New feature? | yes/no +| BC breaks? | yes/no +| Deprecations? | yes/no +| Fixed tickets | Fix #... +| License | MIT + + diff --git a/.github/composer-config.json b/.github/composer-config.json new file mode 100644 index 0000000..3cf8468 --- /dev/null +++ b/.github/composer-config.json @@ -0,0 +1,13 @@ +{ + "config": { + "cache-vcs-dir": "/dev/null", + "platform-check": false, + "preferred-install": { + "*": "dist" + }, + "allow-plugins": { + "ergebnis/composer-normalize": true, + "symfony/flex": true + } + } +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index e8f9b46..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,68 +0,0 @@ -name: Full CI process -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - test: - name: PHP ${{ matrix.php-versions }} - runs-on: 'ubuntu-latest' - strategy: - fail-fast: false - matrix: - php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0'] - - steps: - # —— Setup Github actions 🐙 ————————————————————————————————————————————— - # https://github.com/actions/checkout (official) - - - name: Checkout - uses: actions/checkout@v4 - - # https://github.com/shivammathur/setup-php (community) - - - name: Setup PHP and composer with shivammathur/setup-php - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php-versions }}' - coverage: none - - # —— Composer 🧙‍️ ————————————————————————————————————————————————————————— - - - name: Install Composer dependencies - run: composer update --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi - - ## —— Tests ✅ ——————————————————————————————————————————————————————————— - - - name: Run Tests - run: vendor/bin/phpunit --disallow-test-output --verbose - phpstan: - name: PHPStan - runs-on: 'ubuntu-latest' - strategy: - fail-fast: false - steps: - - - name: Checkout - uses: actions/checkout@v4 - - # https://github.com/shivammathur/setup-php (community) - - - name: Setup PHP and composer with shivammathur/setup-php - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - coverage: none - - # —— Composer 🧙‍️ ————————————————————————————————————————————————————————— - - - name: Install Composer dependencies - run: composer update --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi - - - - name: Run PHPStan - run: vendor/bin/phpstan analyse diff --git a/.github/workflows/composer-validate.yaml b/.github/workflows/composer-validate.yaml new file mode 100644 index 0000000..4eaa602 --- /dev/null +++ b/.github/workflows/composer-validate.yaml @@ -0,0 +1,51 @@ +name: Composer Validate + +on: + push: + paths: + - 'composer.json' + pull_request: + paths: + - 'composer.json' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + composer-sync: + name: 'Composer validation' + runs-on: ubuntu-24.04 + env: + php-version: '8.4' + + steps: + - + name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.php-version }} + ini-values: "memory_limit=-1" + coverage: none + + - + name: Checkout target branch + uses: actions/checkout@v6 + + - + name: 'Install dependencies' + run: | + COMPOSER_HOME="$(composer config home)" + ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" + composer global require -q "ergebnis/composer-normalize" + composer install --no-progress + + - + name: 'Normalized composer.json' + run: | + echo "composer.json" + composer validate + composer normalize diff --git a/.github/workflows/inspector-bot.yaml b/.github/workflows/inspector-bot.yaml new file mode 100644 index 0000000..eab2933 --- /dev/null +++ b/.github/workflows/inspector-bot.yaml @@ -0,0 +1,16 @@ +name: CS + +on: + pull_request: + +permissions: + contents: read + +jobs: + call-inspector-bot: + name: InspectorBot + uses: rollerscapes/inspector-bot/.github/workflows/inspector-bot.yml@main + with: + package: RollerworksVersion + check_license: true + diff --git a/.github/workflows/phpstan.yaml b/.github/workflows/phpstan.yaml new file mode 100644 index 0000000..6169481 --- /dev/null +++ b/.github/workflows/phpstan.yaml @@ -0,0 +1,62 @@ +name: PHPStan + +on: + pull_request: + +defaults: + run: + shell: bash + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-24.04 + + env: + php-version: '8.2' + steps: + - + name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.php-version }} + ini-values: "memory_limit=-1" + coverage: none + + - + name: Checkout target branch + uses: actions/checkout@v6 + with: + ref: ${{ github.base_ref }} + + - + name: Checkout PR + uses: actions/checkout@v6 + + - + name: Install dependencies + run: | + COMPOSER_HOME="$(composer config home)" + ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" + composer install --no-progress --ansi --no-plugins + + - + name: Generate PHPStan baseline + run: | + git checkout composer.json + git checkout -m ${{ github.base_ref }} + vendor/bin/phpstan analyze --generate-baseline --allow-empty-baseline --no-progress + git checkout -m FETCH_HEAD + + - + name: PHPStan + run: | + vendor/bin/phpstan analyze --no-progress --error-format=github + diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..908469e --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,50 @@ +name: CI +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + + test: + + name: 'PHPUnit with PHP ${{ matrix.php-version }}' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - php-version: '8.1' + - php-version: '8.2' + - php-version: '8.3' + - php-version: '8.4' + - php-version: '8.5' + steps: + - + name: Checkout + uses: actions/checkout@v6 + + - + name: 'Set up PHP' + uses: 'shivammathur/setup-php@v2' + with: + php-version: '${{ matrix.php-version }}' + coverage: none + env: + update: true + + - + name: 'Install dependencies' + env: + COMPOSER_OPTIONS: '${{ matrix.composer-options }}' + SYMFONY_REQUIRE: '${{ matrix.symfony-version }}' + run: | + composer update --no-progress --no-interaction --optimize-autoloader $COMPOSER_OPTIONS + + - + name: Run Tests + run: make phpunit diff --git a/.gitignore b/.gitignore index fa169ce..767ccde 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ /composer.lock *.phar /vendor/ -/.php_cs.cache .phpunit.result.cache +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..80e4b82 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,34 @@ + + +This source file is subject to the MIT license that is bundled +with this source code in the file LICENSE. +EOF; + +/** @var \Symfony\Component\Finder\Finder $finder */ +$finder = PhpCsFixer\Finder::create(); +$finder + ->in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]); + +$config = new PhpCsFixer\Config(); +$config + ->setRiskyAllowed(true) + ->setRules( + array_merge( + require __DIR__ . '/vendor/rollerscapes/standards/php-cs-fixer-rules.php', + [ + 'header_comment' => ['header' => $header], + 'mb_str_functions' => false, + 'php_unit_test_annotation' => ['style' => 'annotation'], // For now + ]) + ) + ->setFinder($finder); + +return $config; diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 7348014..0000000 --- a/.php_cs +++ /dev/null @@ -1,47 +0,0 @@ - - -This source file is subject to the MIT license that is bundled -with this source code in the file LICENSE. -EOF; - -return PhpCsFixer\Config::create() - ->setRiskyAllowed(true) - ->setRules([ - '@Symfony' => true, - '@Symfony:risky' => true, - '@PHP70Migration' => true, - '@PHP71Migration' => true, - 'array_syntax' => ['syntax' => 'short'], - 'combine_consecutive_unsets' => true, - 'declare_strict_types' => true, - 'header_comment' => ['header' => $header], - 'heredoc_to_nowdoc' => true, - 'linebreak_after_opening_tag' => true, - 'mb_str_functions' => false, - 'no_short_echo_tag' => true, - 'no_unreachable_default_argument_value' => false, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'ordered_class_elements' => false, - 'ordered_imports' => true, - 'phpdoc_annotation_without_dot' => true, - 'phpdoc_order' => true, - 'native_function_invocation' => false, - - // This breaks for variable @var blocks - 'phpdoc_to_comment' => false, - 'phpdoc_var_without_name' => false, - 'strict_comparison' => true, - 'strict_param' => true, - 'yoda_style' => false, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__) - ) -; diff --git a/LICENSE b/LICENSE index 3446e71..c6b65a9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2017-2018 Sebastiaan Stok +Copyright (c) 2017-present Sebastiaan Stok Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2ba1948 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +include vendor/rollerscapes/standards/Makefile + +phpunit: + ./vendor/bin/phpunit diff --git a/UPGRADE.md b/UPGRADE.md index 863f6f4..886524a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,6 +1,10 @@ UPGRADE ======= +## Upgrade FROM 0.3 to 0.4 + +* Support for PHP < 8.1 was dropped. + ## Upgrade FROM 0.2 to 0.3 * The method `increase` of `Version` is renamed to `getNextIncreaseOf`. diff --git a/composer.json b/composer.json index e19f97b..85702dc 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,11 @@ } ], "require": { - "php": "^7.1|^8.0" + "php": "^8.1" }, "require-dev": { - "phpunit/phpunit": "^7.3.2|^8.5.12|^9.6", - "phpstan/phpstan": "^0.12.33", - "phpstan/phpstan-phpunit": "^0.12.13", - "symfony/phpunit-bridge": "^5.2 || ^6.4" + "phpunit/phpunit": "^10.5 || ^11.0", + "rollerscapes/standards": "^0.3" }, "autoload": { "psr-4": { @@ -33,7 +31,7 @@ }, "extra": { "branch-alias": { - "dev-master": "0.2-dev" + "dev-master": "0.3-dev" } } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..3438bfe --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,25 @@ +parameters: + ignoreErrors: + - + message: '#^Method Rollerworks\\Component\\Version\\ContinuesVersionsValidator\:\:getLastArrayIndex\(\) should return int but returns int\|null\.$#' + identifier: return.type + count: 1 + path: src/ContinuesVersionsValidator.php + + - + message: '#^Yield can be used only with these return types\: Generator, Iterator, Traversable, iterable\.$#' + identifier: generator.returnType + count: 17 + path: tests/ContinuesVersionsValidatorTest.php + + - + message: '#^Method Rollerworks\\Component\\Version\\Tests\\VersionTest\:\:provideExpectedNextVersionCandidates\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: tests/VersionTest.php + + - + message: '#^PHPDoc tag @return has invalid value \(array\\|string\>\>\>\)\: Unexpected token "\>", expected TOKEN_HORIZONTAL_WS at offset 70 on line 2$#' + identifier: phpDoc.parseError + count: 1 + path: tests/VersionTest.php diff --git a/phpstan.neon b/phpstan.neon index c05fef4..a2e113b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,9 +1,12 @@ includes: - - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/rollerscapes/standards/phpstan.neon + - phpstan-baseline.neon parameters: - level: 7 + #reportUnmatchedIgnoredErrors: false + paths: - - src - - tests - ignoreErrors: + - ./src + - ./tests + + #ignoreErrors: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b50c7d8..574533f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,10 @@ @@ -18,14 +17,14 @@ - - + + ./src - - ./vendor/ - ./tests/ - - - + + + ./vendor/ + ./tests/ + + diff --git a/src/ContinuesVersionsValidator.php b/src/ContinuesVersionsValidator.php index 8cb4d90..b79aefc 100644 --- a/src/ContinuesVersionsValidator.php +++ b/src/ContinuesVersionsValidator.php @@ -13,8 +13,6 @@ namespace Rollerworks\Component\Version; -use function count; - final class ContinuesVersionsValidator { /** @var Version[] */ @@ -33,7 +31,7 @@ public function __construct(Version ...$versions) public function isContinues(Version $new): bool { - if (count($this->versions) === 0) { + if (\count($this->versions) === 0) { $this->possibleVersions = [ Version::fromString('0.1.0'), Version::fromString('1.0.0-ALPHA1'), @@ -53,9 +51,7 @@ public function isContinues(Version $new): bool return false; } - /** - * @return Version[] - */ + /** @return Version[] */ public function getPossibleVersions(): array { return $this->possibleVersions; @@ -68,13 +64,13 @@ private function computePossibleVersions(Version $new): void $major = $new->major; $minor = $new->minor; - if (!isset($this->resolveVersions[$major])) { + if (! isset($this->resolveVersions[$major])) { $this->computePossibleVersionsFromLastExisting(); return; } - if (!isset($this->resolveVersions[$major][$minor])) { + if (! isset($this->resolveVersions[$major][$minor])) { $minor = $this->getLastArrayIndex($this->resolveVersions[$major]); } @@ -83,7 +79,7 @@ private function computePossibleVersions(Version $new): void private function arrangeExistingVersions(): void { - usort($this->versions, function (Version $a, Version $b) { + usort($this->versions, static function (Version $a, Version $b) { return version_compare(strtolower($a->full), strtolower($b->full), '<') ? -1 : 1; }); @@ -106,9 +102,7 @@ private function computePossibleVersionsFromLastExisting(): void $this->possibleVersions = $version->getNextVersionCandidates(); } - /** - * @param array $array - */ + /** @param array $array */ private function getLastArrayIndex(array $array): int { end($array); diff --git a/src/Version.php b/src/Version.php index c134216..5cd0b37 100644 --- a/src/Version.php +++ b/src/Version.php @@ -61,7 +61,7 @@ final class Version private function __construct(int $major, int $minor, int $patch, int $stability, int $metaver = 0) { - if (0 === $major) { + if ($major === 0) { $stability = self::STABILITY_ALPHA; } @@ -71,12 +71,12 @@ private function __construct(int $major, int $minor, int $patch, int $stability, $this->stability = $stability; $this->metaver = $metaver; - if (self::STABILITY_STABLE === $stability && $this->metaver > 0) { + if ($stability === self::STABILITY_STABLE && $this->metaver > 0) { throw new \InvalidArgumentException('Meta version of the stability flag cannot be set for stable.'); } if ($major > 0 && $stability < self::STABILITY_STABLE) { - $this->full = sprintf( + $this->full = \sprintf( '%d.%d.%d-%s%d', $this->major, $this->minor, @@ -85,7 +85,7 @@ private function __construct(int $major, int $minor, int $patch, int $stability, $this->metaver ); } else { - $this->full = sprintf('%d.%d.%d', $this->major, $this->minor, $this->patch); + $this->full = \sprintf('%d.%d.%d', $this->major, $this->minor, $this->patch); } } @@ -96,7 +96,7 @@ public function __toString() public static function fromString(string $version): self { - if (preg_match('/^v?'.self::VERSION_REGEX.'$/i', $version, $matches)) { + if (preg_match('/^v?' . self::VERSION_REGEX . '$/i', $version, $matches)) { return new self( (int) $matches['major'], (int) $matches['minor'], @@ -107,8 +107,8 @@ public static function fromString(string $version): self } throw new \InvalidArgumentException( - sprintf( - 'Unable to parse version "%s" Expects an SemVer compatible version without build-metadata. '. + \sprintf( + 'Unable to parse version "%s" Expects an SemVer compatible version without build-metadata. ' . 'Either "1.0.0", "1.0", "1.0" or "1.0.0-beta1", "1.0.0-beta-1"', $version ) @@ -134,7 +134,7 @@ public function getNextVersionCandidates(): array // Pre first-stable, so 0.x-[rc,beta,stable] releases are not considered. // Use alpha as stability with metaver 1, 0.2-alpha2 is simple ignored. // If anyone really uses this... not our problem :) - if (0 === $this->major) { + if ($this->major === 0) { $candidates[] = $this->getNextIncreaseOf('patch'); $candidates[] = $this->getNextIncreaseOf('minor'); $candidates[] = self::fromString('1.0.0-BETA1'); @@ -220,7 +220,7 @@ public function getNextIncreaseOf(string $stability): self default: throw new \InvalidArgumentException( - sprintf( + \sprintf( 'Unknown stability "%s", accepts "%s".', $stability, implode('", "', ['alpha', 'beta', 'rc', 'stable', 'major', 'next', 'minor', 'patch']) diff --git a/tests/ContinuesVersionsValidatorTest.php b/tests/ContinuesVersionsValidatorTest.php index 5fe2ece..5610e2d 100644 --- a/tests/ContinuesVersionsValidatorTest.php +++ b/tests/ContinuesVersionsValidatorTest.php @@ -17,12 +17,13 @@ use Rollerworks\Component\Version\ContinuesVersionsValidator; use Rollerworks\Component\Version\Version; +/** + * @internal + */ class ContinuesVersionsValidatorTest extends TestCase { - /** - * @return array - */ - public function provideInitialContinuesVersions(): iterable + /** @return iterable */ + public static function provideInitialContinuesVersions(): iterable { yield ['0.1.0']; yield ['1.0-ALPHA1']; @@ -31,8 +32,9 @@ public function provideInitialContinuesVersions(): iterable } /** - * @test * @dataProvider provideInitialContinuesVersions + * + * @test */ public function it_accepts_a_continues_version_with_no_pre_existing(string $new): void { @@ -50,10 +52,8 @@ public function it_accepts_a_continues_version_with_no_pre_existing(string $new) ); } - /** - * @return array> - */ - public function provideContinuesVersions(): iterable + /** @return iterable> */ + public static function provideContinuesVersions(): iterable { yield 'unstable #1' => ['0.3', ['0.2', '0.1'], ['0.2.1', '0.3', '1.0-BETA1', '1.0']]; yield 'unstable #2' => ['0.2.1', ['0.2', '0.1'], ['0.2.1', '0.3', '1.0-BETA1', '1.0']]; @@ -67,17 +67,18 @@ public function provideContinuesVersions(): iterable } /** - * @test * @dataProvider provideContinuesVersions * * @param array $existing * @param array $possible + * + * @test */ public function it_accepts_a_continues_version(string $new, array $existing, array $possible): void { $validator = new ContinuesVersionsValidator(...$this->createVersions($existing)); - self::assertTrue($validator->isContinues(Version::fromString($new)), sprintf('Excepts instead %s', implode(',', $validator->getPossibleVersions()))); + self::assertTrue($validator->isContinues(Version::fromString($new)), \sprintf('Excepts instead %s', implode(',', $validator->getPossibleVersions()))); self::assertEquals($this->createVersions($possible), array_merge([], $validator->getPossibleVersions())); } @@ -89,17 +90,15 @@ public function it_accepts_a_continues_version(string $new, array $existing, arr private function createVersions(array $existing): array { return array_map( - function (string $version) { + static function (string $version) { return Version::fromString($version); }, $existing ); } - /** - * @return array - */ - public function provideNotInitialContinuesVersions(): iterable + /** @return iterable */ + public static function provideNotInitialContinuesVersions(): iterable { yield ['0.2.0']; yield ['2.0-ALPHA1']; @@ -109,8 +108,9 @@ public function provideNotInitialContinuesVersions(): iterable } /** - * @test * @dataProvider provideNotInitialContinuesVersions + * + * @test */ public function it_rejects_non_continues_version_with_no_pre_existing(string $new): void { @@ -128,10 +128,8 @@ public function it_rejects_non_continues_version_with_no_pre_existing(string $ne ); } - /** - * @return iterable> - */ - public function provideNonContinuesVersions(): iterable + /** @return iterable> */ + public static function provideNonContinuesVersions(): iterable { yield 'unstable #1' => ['0.5', ['0.2', '0.1'], ['0.2.1', '0.3', '1.0-BETA1', '1.0']]; yield 'unstable #2' => ['0.2.4', ['0.2', '0.1'], ['0.2.1', '0.3', '1.0-BETA1', '1.0']]; @@ -146,11 +144,12 @@ public function provideNonContinuesVersions(): iterable } /** - * @test * @dataProvider provideNonContinuesVersions * * @param array $existing * @param array $possible + * + * @test */ public function it_rejects_non_continues_version(string $new, array $existing, array $possible): void { diff --git a/tests/VersionTest.php b/tests/VersionTest.php index cfd8849..f957294 100644 --- a/tests/VersionTest.php +++ b/tests/VersionTest.php @@ -16,6 +16,9 @@ use PHPUnit\Framework\TestCase; use Rollerworks\Component\Version\Version; +/** + * @internal + */ class VersionTest extends TestCase { /** @test */ @@ -60,10 +63,8 @@ public function it_creates_without_patch(): void self::assertEquals('1.0.0', (string) $version); } - /** - * @return array - */ - public function provideValidFormats(): array + /** @return array */ + public static function provideValidFormats(): array { return [ 'with prefix in lowercase' => ['v1.0.0', '1.0.0'], @@ -77,8 +78,9 @@ public function provideValidFormats(): array } /** - * @test * @dataProvider provideValidFormats + * + * @test */ public function it_supports_various_formats(string $version, string $expectedOutput): void { @@ -116,10 +118,8 @@ public function it_fails_with_stable_plus_metaver(): void Version::fromString('1.0.0-stable-5'); } - /** - * @return array|string>>> - */ - public function provideExpectedNextVersionCandidates(): array + /** @return array|string>>> */ + public static function provideExpectedNextVersionCandidates(): array { return [ 'alpha 0' => ['0.1.0', ['0.1.1', '0.2.0', '1.0.0-BETA1', '1.0.0']], @@ -136,10 +136,11 @@ public function provideExpectedNextVersionCandidates(): array } /** - * @test * @dataProvider provideExpectedNextVersionCandidates * * @param array $expected + * + * @test */ public function it_provides_next_version_candidates(string $current, array $expected): void { @@ -149,10 +150,8 @@ public function it_provides_next_version_candidates(string $current, array $expe self::assertEquals($expected, $candidates); } - /** - * @return array - */ - public function provideExpectedIncreasedVersion(): array + /** @return array */ + public static function provideExpectedIncreasedVersion(): array { return [ 'patch with patch 0' => ['0.1.0', '0.1.1', 'patch'], @@ -210,8 +209,9 @@ public function provideExpectedIncreasedVersion(): array } /** - * @test * @dataProvider provideExpectedIncreasedVersion + * + * @test */ public function it_increases_to_next_version(string $current, string $expected, string $stability): void {