diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..aa00f85 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,64 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events + push: + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # Composer config validation + composer: + name: Composer config validation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Validate composer.json + run: composer validate --strict + + # PHP syntax validation + php: + name: PHP syntax validation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check PHP syntax of package + run: php -l src/ tests/ + + phpunit: + name: PHPUnit tests + runs-on: ubuntu-latest + strategy: + matrix: + php_version: [ 7.4, 8.0, 8.1, 8.2, 8.3 ] + steps: + - uses: actions/checkout@v3 + - uses: php-actions/composer@v6 + with: + php_version: ${{ matrix.php_version }} + - run: vendor/bin/phpunit + + # phpstan for several php versions + phpstan: + runs-on: ubuntu-latest + strategy: + matrix: + php_version: [ 7.4, 8.0, 8.1, 8.2, 8.3 ] + steps: + - uses: actions/checkout@v3 + - uses: php-actions/composer@v6 + with: + php_version: ${{ matrix.php_version }} + #php_extensions: redis intl + + - name: PHPStan Static Analysis + uses: php-actions/phpstan@v3 + with: + php_version: ${{ matrix.php_version }} + configuration: phpstan.neon diff --git a/.gitignore b/.gitignore index 57872d0..4fbb073 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /vendor/ +/composer.lock diff --git a/.travis.yml b/.travis.yml index 996ddd0..815a08a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ php: - 7.0 - 7.1 - 7.2 +- 7.4 +- 8.1 env: global: - CC_TEST_REPORTER_ID=5ae2c3f73f4475bd0ada0a042a8f581dfeb12745ee9fbb3d1e590f15dbb0ec5c diff --git a/composer.json b/composer.json index 4e7a7d9..b4f6e9c 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,11 @@ ], "minimum-stability": "stable", "require": { - "php": "^7.0", + "php": ">7.0, <8.4", "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^9.5" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 2eae477..0000000 --- a/composer.lock +++ /dev/null @@ -1,1202 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "2bf91e3bd1862b68ff07a1eacf617370", - "packages": [], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14T21:17:01+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "time": "2017-09-11T18:02:19+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "4.3.4", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", - "shasum": "" - }, - "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" - }, - "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpdocumentor/type-resolver": "0.4.*", - "phpunit/phpunit": "^6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-12-28T18:55:12+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "0.5.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "cf842904952e64e703800d094cdf34e715a8a3ae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/cf842904952e64e703800d094cdf34e715a8a3ae", - "reference": "cf842904952e64e703800d094cdf34e715a8a3ae", - "shasum": "" - }, - "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "time": "2017-12-30T13:23:38+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.10.2", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9", - "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2020-01-20T15:57:02+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-10-06T15:47:00+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2017-11-27T13:52:08+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2017-02-26T11:10:40+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.12", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2017-12-04T08:55:13+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "4.8.36", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.8.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2017-06-21T08:07:12+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2015-10-02T06:51:40+00:00" - }, - { - "name": "sebastian/comparator", - "version": "1.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2017-01-29T09:50:25+00:00" - }, - { - "name": "sebastian/diff", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2017-05-22T07:24:03+00:00" - }, - { - "name": "sebastian/environment", - "version": "1.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2016-08-18T05:49:44+00:00" - }, - { - "name": "sebastian/exporter", - "version": "1.2.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2016-06-17T09:04:28+00:00" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-10-12T03:26:01+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-10-03T07:41:43+00:00" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21T13:59:46+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/yaml", - "version": "v3.4.37", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "aa46bc2233097d5212332c907f9911533acfbf80" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/aa46bc2233097d5212332c907f9911533acfbf80", - "reference": "aa46bc2233097d5212332c907f9911533acfbf80", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2020-01-13T08:00:59+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.6.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "vimeo/psalm": "<3.6.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" - }, - "type": "library", - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "time": "2019-11-24T13:36:37+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": "^7.0", - "ext-json": "*" - }, - "platform-dev": [] -} diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..1517ec8 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 9 + paths: + - src/ + - tests/ diff --git a/phpunit.xml b/phpunit.xml index 0318fac..84820b6 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,21 @@ - - - - tests/ - - - - - src/ - - + + + src/ + + + + + tests/ + + diff --git a/src/AbstractVersion.php b/src/AbstractVersion.php index 691dd12..eae0bc1 100644 --- a/src/AbstractVersion.php +++ b/src/AbstractVersion.php @@ -20,6 +20,7 @@ abstract class AbstractVersion implements IVersion * which is a value of any type other than a resource. * @since 5.4.0 */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return [ @@ -39,13 +40,13 @@ public function exists(): bool /** * Get the branch string. - * @return string + * @return string|null */ abstract public function getBranch(); /** * Get the latest commit ID. - * @return string + * @return string|null */ abstract public function getCommit(); } diff --git a/src/FileVersion.php b/src/FileVersion.php index 472742c..54f8d7e 100644 --- a/src/FileVersion.php +++ b/src/FileVersion.php @@ -24,7 +24,7 @@ class FileVersion extends AbstractVersion private $fileExists; /** - * @var string Cache fileContents() function reply. + * @var array Cache fileContents() function reply. */ private $fileContents; @@ -52,7 +52,7 @@ private function fileExists(): bool /** * Get the contents of the JSON encoded file. - * @return array + * @return array */ private function fileContents(): array { @@ -63,6 +63,7 @@ private function fileContents(): array if ($this->fileExists()) { $jsonStr = file_get_contents($this->file); if ($jsonStr !== false) { + /** @var array $json */ $json = json_decode($jsonStr, true); if ($json !== null) { if (array_key_exists('branch', $json)) { @@ -80,7 +81,7 @@ private function fileContents(): array /** * Get the branch string. - * @return string + * @return string|null */ public function getBranch() { @@ -92,7 +93,7 @@ public function getBranch() /** * Get the latest commit ID. - * @return string + * @return string|null */ public function getCommit() { diff --git a/src/GitVersion.php b/src/GitVersion.php index 9d5dda8..87c5ade 100644 --- a/src/GitVersion.php +++ b/src/GitVersion.php @@ -29,7 +29,7 @@ class GitVersion extends AbstractVersion private $isRepo; /** - * @var string The current branch name in the git repository. + * @var string|null The current branch name in the git repository. */ private $branch; @@ -62,7 +62,7 @@ private function isRepo(): bool /** * Get the branch string. - * @return string + * @return string|null */ public function getBranch() { diff --git a/src/Version.php b/src/Version.php index e44a7d2..a482f4e 100644 --- a/src/Version.php +++ b/src/Version.php @@ -14,12 +14,12 @@ class Version extends AbstractVersion { /** - * @var array of IVersion objects. + * @var array of IVersion objects. */ private $versions; /** - * @var array Branch and commit. + * @var array Branch and commit. */ private $version; @@ -34,6 +34,7 @@ public function __construct() /** * Register a new way to determine the version. * @param \kbATeam\Version\IVersion $version + * @return void */ public function register(IVersion $version) { @@ -42,7 +43,7 @@ public function register(IVersion $version) /** * Determine the current version. - * @return array + * @return array */ private function determineVersion(): array { @@ -65,7 +66,7 @@ private function determineVersion(): array /** * Get the branch string. - * @return string + * @return string|null */ public function getBranch() { @@ -77,7 +78,7 @@ public function getBranch() /** * Get the latest commit ID. - * @return string + * @return string|null */ public function getCommit() { diff --git a/tests/FileVersionTest.php b/tests/FileVersionTest.php index 995a8d9..cb562ea 100644 --- a/tests/FileVersionTest.php +++ b/tests/FileVersionTest.php @@ -4,6 +4,7 @@ use kbATeam\Version\FileVersion; use kbATeam\Version\IVersion; +use PHPUnit\Framework\TestCase; /** * Class Tests\kbATeam\Version\FileVersionTest @@ -14,8 +15,11 @@ * @author Gregor J. * @license MIT */ -class FileVersionTest extends \PHPUnit_Framework_TestCase +class FileVersionTest extends TestCase { + /** + * @var string + */ private $tempDir; use TempDirTrait; @@ -23,11 +27,12 @@ class FileVersionTest extends \PHPUnit_Framework_TestCase /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. + * @return void */ - protected function setUp() + protected function setUp(): void { parent::setUp(); - $this->tempDir = static::tempdir(); + $this->tempDir = $this->tempdir(); file_put_contents($this->tempDir.'/commit.json', json_encode([ 'branch' => 'master', 'commit' => '9c9e437' @@ -37,48 +42,50 @@ protected function setUp() /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. + * @return void */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); - static::rmDir($this->tempDir); + $this->rmDir($this->tempDir); } /** * Test retrieving branch and commit from a JSON encoded file. - * @throws \PHPUnit_Framework_AssertionFailedError - * @throws \PHPUnit_Framework_Exception + * @return void */ public function testFileVersionRetrieval() { $fileVersion = new FileVersion($this->tempDir.'/commit.json'); - static::assertInstanceOf(IVersion::class, $fileVersion); - static::assertTrue($fileVersion->exists()); - static::assertSame('master', $fileVersion->getBranch()); - static::assertSame('9c9e437', $fileVersion->getCommit()); - $actual = json_encode($fileVersion); - $expected = json_encode([ + $this->assertInstanceOf(IVersion::class, $fileVersion); + $this->assertTrue($fileVersion->exists()); + $this->assertSame('master', $fileVersion->getBranch()); + $this->assertSame('9c9e437', $fileVersion->getCommit()); + $actual = (string)json_encode($fileVersion); + $expected = (string)json_encode([ 'branch' => 'master', 'commit' => '9c9e437' ]); - static::assertJsonStringEqualsJsonString($expected, $actual); + $this->assertJsonStringEqualsJsonString($expected, $actual); } /** * Test retrieving commit from a JSON encoded file. + * @return void */ public function testGettingCommit() { $fileVersion = new FileVersion($this->tempDir.'/commit.json'); - static::assertSame('9c9e437', $fileVersion->getCommit()); + $this->assertSame('9c9e437', $fileVersion->getCommit()); } /** * Test retrieving branch from a JSON encoded file. + * @return void */ public function testGettingBranch() { $fileVersion = new FileVersion($this->tempDir.'/commit.json'); - static::assertSame('master', $fileVersion->getBranch()); + $this->assertSame('master', $fileVersion->getBranch()); } } diff --git a/tests/GitVersionTest.php b/tests/GitVersionTest.php index 94a9071..4b6a1dd 100644 --- a/tests/GitVersionTest.php +++ b/tests/GitVersionTest.php @@ -4,6 +4,7 @@ use kbATeam\Version\GitVersion; use kbATeam\Version\IVersion; +use PHPUnit\Framework\TestCase; /** * Class Tests\kbATeam\Version\GitVersionTest @@ -14,8 +15,11 @@ * @author Gregor J. * @license MIT */ -class GitVersionTest extends \PHPUnit_Framework_TestCase +class GitVersionTest extends TestCase { + /** + * @var string + */ private $tempDir; use TempDirTrait; @@ -23,11 +27,12 @@ class GitVersionTest extends \PHPUnit_Framework_TestCase /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. + * @return void */ - protected function setUp() + protected function setUp(): void { parent::setUp(); - $this->tempDir = static::tempdir(); + $this->tempDir = $this->tempdir(); mkdir($this->tempDir.'/.git/refs/heads/', 0777, true); file_put_contents($this->tempDir.'/.git/HEAD', 'ref: refs/heads/master'); file_put_contents($this->tempDir.'/.git/refs/heads/master', '9c9e4373dbd136a4f405a828a9ecf445f207e49c'); @@ -36,27 +41,27 @@ protected function setUp() /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. + * @return void */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); - static::rmDir($this->tempDir); + $this->rmDir($this->tempDir); } /** * Test retrieving version information from git. - * @throws \PHPUnit_Framework_AssertionFailedError - * @throws \PHPUnit_Framework_Exception + * @return void */ public function testGitVersionRetrieval() { $gitVersion = new GitVersion($this->tempDir); - static::assertInstanceOf(IVersion::class, $gitVersion); - static::assertTrue($gitVersion->exists()); - static::assertSame('master', $gitVersion->getBranch()); - static::assertSame('9c9e437', $gitVersion->getCommit()); - $actual = json_encode($gitVersion); - $expected = json_encode([ + $this->assertInstanceOf(IVersion::class, $gitVersion); + $this->assertTrue($gitVersion->exists()); + $this->assertSame('master', $gitVersion->getBranch()); + $this->assertSame('9c9e437', $gitVersion->getCommit()); + $actual = (string)json_encode($gitVersion); + $expected = (string)json_encode([ 'branch' => 'master', 'commit' => '9c9e437' ]); diff --git a/tests/TempDirTrait.php b/tests/TempDirTrait.php index 09cf535..bb64bf8 100644 --- a/tests/TempDirTrait.php +++ b/tests/TempDirTrait.php @@ -23,6 +23,9 @@ private static function tempdir() ob_start(); $result = system('mktemp -d', $exitCode); ob_end_clean(); + if (!is_string($result)) { + throw new \RuntimeException('Could not create temporary directory!'); + } if ($exitCode !== 0) { throw new \RuntimeException('Could not create temporary directory!'); } @@ -33,6 +36,7 @@ private static function tempdir() * Remove a directory and all its contents. * @param string $dir * @throws \RuntimeException + * @return void */ private static function rmDir($dir) { diff --git a/tests/VersionTest.php b/tests/VersionTest.php index 40652ed..1d96f4f 100644 --- a/tests/VersionTest.php +++ b/tests/VersionTest.php @@ -6,6 +6,7 @@ use kbATeam\Version\GitVersion; use kbATeam\Version\IVersion; use kbATeam\Version\Version; +use PHPUnit\Framework\TestCase; /** * Class Tests\kbATeam\Version\VersionTest @@ -16,8 +17,11 @@ * @author Gregor J. * @license MIT */ -class VersionTest extends \PHPUnit_Framework_TestCase +class VersionTest extends TestCase { + /** + * @var string + */ private $tempDir; use TempDirTrait; @@ -25,11 +29,12 @@ class VersionTest extends \PHPUnit_Framework_TestCase /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. + * @return void */ - protected function setUp() + protected function setUp(): void { parent::setUp(); - $this->tempDir = static::tempdir(); + $this->tempDir = $this->tempdir(); file_put_contents($this->tempDir.'/commit.json', json_encode([ 'branch' => 'retsam', 'commit' => '765e9c9' @@ -42,57 +47,56 @@ protected function setUp() /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. + * @return void */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); - static::rmDir($this->tempDir); + $this->rmDir($this->tempDir); } /** * Test retrieving the version from the JSON encoded file rather that from the * git repository. - * @throws \PHPUnit_Framework_AssertionFailedError - * @throws \PHPUnit_Framework_Exception + * @return void */ public function testRetrievingFileVersion() { $version = new Version(); - static::assertInstanceOf(IVersion::class, $version); + $this->assertInstanceOf(IVersion::class, $version); $version->register(new FileVersion($this->tempDir.'/commit.json')); //$version->register(new GitVersion($this->tempDir)); - static::assertTrue($version->exists()); - static::assertSame('retsam', $version->getBranch()); - static::assertSame('765e9c9', $version->getCommit()); - $actual = json_encode($version); - $expected = json_encode([ + $this->assertTrue($version->exists()); + $this->assertSame('retsam', $version->getBranch()); + $this->assertSame('765e9c9', $version->getCommit()); + $actual = (string)json_encode($version); + $expected = (string)json_encode([ 'branch' => 'retsam', 'commit' => '765e9c9' ]); - static::assertJsonStringEqualsJsonString($expected, $actual); + $this->assertJsonStringEqualsJsonString($expected, $actual); } /** * Test retrieving the version from the git repository rather that from the JSON * encoded file. - * @throws \PHPUnit_Framework_AssertionFailedError - * @throws \PHPUnit_Framework_Exception + * @return void */ public function testRetrievingGitVersion() { $version = new Version(); - static::assertInstanceOf(IVersion::class, $version); + $this->assertInstanceOf(IVersion::class, $version); $version->register(new GitVersion($this->tempDir)); $version->register(new FileVersion($this->tempDir.'/commit.json')); - static::assertSame('9c9e437', $version->getCommit()); - static::assertTrue($version->exists()); - static::assertSame('master', $version->getBranch()); - $actual = json_encode($version); - $expected = json_encode([ + $this->assertSame('9c9e437', $version->getCommit()); + $this->assertTrue($version->exists()); + $this->assertSame('master', $version->getBranch()); + $actual = (string)json_encode($version); + $expected = (string)json_encode([ 'branch' => 'master', 'commit' => '9c9e437' ]); - static::assertJsonStringEqualsJsonString($expected, $actual); + $this->assertJsonStringEqualsJsonString($expected, $actual); } }