From 98a959012b69323a43d0667f986af845624c3e01 Mon Sep 17 00:00:00 2001 From: NanoSector Date: Wed, 3 Nov 2021 11:19:34 +0100 Subject: [PATCH] Introduce quality tools & migrate to GitHub Actions --- .github/workflows/analysis.yml | 46 + .gitignore | 84 +- .idea/.gitignore | 8 + .idea/command-parser.iml | 57 + .idea/inspectionProfiles/Project_Default.xml | 145 ++ .idea/modules.xml | 8 + .idea/php-test-framework.xml | 14 + .idea/php.xml | 75 + .idea/phpunit.xml | 10 + .idea/vcs.xml | 6 + .scrutinizer.yml | 21 - composer.json | 51 +- composer.lock | 1240 +++++++++++++++-- phpmd_ruleset.xml | 20 + phpstan.neon | 5 + src/Command.php | 23 +- src/CommandParser.php | 16 +- src/CommandProcessor.php | 48 +- src/Exceptions/CommandNotFoundException.php | 6 +- .../InvalidParameterCountException.php | 4 +- .../NoApplicableStrategiesException.php | 6 +- src/Exceptions/ParseException.php | 6 +- src/Exceptions/ValidationException.php | 6 +- src/ParameterStrategy.php | 35 +- .../ConvertibleParameterInterface.php | 3 +- src/Parameters/NumericParameter.php | 7 +- src/Parameters/Parameter.php | 7 +- src/Parameters/ParameterInterface.php | 4 +- src/Parameters/PredefinedStringParameter.php | 5 +- src/Parameters/StringParameter.php | 3 +- src/ParsedCommand.php | 24 +- src/ProcessedCommand.php | 26 +- tests/CommandParserTest.php | 40 +- tests/CommandProcessorTest.php | 37 +- tests/CommandTest.php | 46 +- tests/MockConvertibleParameter.php | 5 +- tests/MockRejectAllParameter.php | 5 +- tests/NumericParameterTest.php | 5 +- tests/ParameterStrategyTest.php | 49 +- tests/ParsedCommandTest.php | 5 +- tests/PredefinedStringParameterTest.php | 5 +- tests/ProcessedCommandTest.php | 12 +- 42 files changed, 1870 insertions(+), 358 deletions(-) create mode 100644 .github/workflows/analysis.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/command-parser.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php-test-framework.xml create mode 100644 .idea/php.xml create mode 100644 .idea/phpunit.xml create mode 100644 .idea/vcs.xml delete mode 100644 .scrutinizer.yml create mode 100644 phpmd_ruleset.xml create mode 100644 phpstan.neon diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml new file mode 100644 index 0000000..4de48b5 --- /dev/null +++ b/.github/workflows/analysis.yml @@ -0,0 +1,46 @@ +name: Code analysis + +on: + pull_request: + workflow_dispatch: + +jobs: + tests: + name: PHPUnit tests + runs-on: ubuntu-latest + steps: + - uses: shivammathur/setup-php@2.10.0 + with: + php-version: '7.2' + + - uses: actions/checkout@v2 + + - name: Install Dependencies + run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --dev + + - name: Run PHPUnit + run: composer run phpunit + static-analysis: + name: Static analysis + runs-on: ubuntu-latest + steps: + - uses: shivammathur/setup-php@2.10.0 + with: + php-version: '7.2' + tools: composer, cs2pr + + - uses: actions/checkout@v2 + + - name: Install Dependencies + run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --dev + + - name: Run PHP Code Sniffer + run: composer run phpcs-github | cs2pr + + - name: Run PHP Mess Detector + run: composer run phpmd-github + if: ${{ always() }} + + - name: Run PHPStan + run: composer run phpstan + if: ${{ always() }} diff --git a/.gitignore b/.gitignore index e61b1fb..37f9377 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,83 @@ +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Composer template composer.phar -vendor/ -.idea/ \ No newline at end of file +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +# composer.lock +.phpunit.result.cache +.idea/sonarlint +composer.lock diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/command-parser.iml b/.idea/command-parser.iml new file mode 100644 index 0000000..fa6fdd5 --- /dev/null +++ b/.idea/command-parser.iml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..d82aa10 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,145 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2d3c37e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php-test-framework.xml b/.idea/php-test-framework.xml new file mode 100644 index 0000000..0cbead5 --- /dev/null +++ b/.idea/php-test-framework.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..521328a --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml new file mode 100644 index 0000000..4f8104c --- /dev/null +++ b/.idea/phpunit.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index afd1920..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,21 +0,0 @@ -build: - tests: - override: - - command: vendor/bin/phpunit - coverage: - file: /tmp/coverage.xml - format: clover - - nodes: - tests-php72: - environment: - php: 7.2 - - tests-php73: - environment: - php: 7.3 - - analysis: - tests: - override: - - php-scrutinizer-run \ No newline at end of file diff --git a/composer.json b/composer.json index 9b193ab..c3187e0 100644 --- a/composer.json +++ b/composer.json @@ -2,25 +2,56 @@ "name": "wildphp/command-parser", "description": "Command parser subsystem used in WildPHP", "type": "library", + "minimum-stability": "stable", "license": "MIT", "autoload": { "psr-4": { - "WildPHP\\Commands\\": "src/", - "WildPHP\\Tests\\": "tests/" + "WildPHP\\Commands\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "WildPHP\\Commands\\Tests\\": "tests/" } }, "require": { "php": ">=7.2.0", "yoshi2889/validation-closures": "^0.2", - "yoshi2889/collections": "^0.1" + "yoshi2889/collections": "^0.2" }, "require-dev": { - "phpunit/phpunit": "^8", - "squizlabs/php_codesniffer": "^3.0" + "phpunit/phpunit": "^8.5", + "squizlabs/php_codesniffer": "^3.6.0", + "phpmd/phpmd": "^2.9.1", + "phpstan/phpstan": "^0.12.84" }, - "config": { - "platform": { - "php": "7.2.0" - } + "scripts": { + "qc": [ + "@phpunit", + "@phpcs", + "@phpmd", + "@phpstan" + ], + "phpunit": [ + "@php vendor/bin/phpunit" + ], + "phpcs": [ + "@php vendor/bin/phpcs --standard=PSR12 src/ tests/" + ], + "phpcs-github": [ + "@php vendor/bin/phpcs --standard=PSR12 --report=checkstyle src/ tests/" + ], + "phpcbf": [ + "@php vendor/bin/phpcbf --standard=PSR12 src/ tests/" + ], + "phpmd": [ + "@php vendor/bin/phpmd src/ text phpmd_ruleset.xml --suffixes php" + ], + "phpmd-github": [ + "@php vendor/bin/phpmd src/ github phpmd_ruleset.xml --suffixes php" + ], + "phpstan": [ + "@php vendor/bin/phpstan analyse -c phpstan.neon -n src/" + ] } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 3719052..7c0e8d1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,79 +4,75 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aeea27b7bbca1eb8fb26c2dfb27a6e6b", + "content-hash": "94222b9ad1e0d58b53ae21e365c278ff", "packages": [ { - "name": "evenement/evenement", - "version": "v3.0.1", + "name": "yoshi2889/collections", + "version": "v0.2", "source": { "type": "git", - "url": "https://github.com/igorw/evenement.git", - "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7" + "url": "https://github.com/Yoshi2889/collections.git", + "reference": "b6f90995527c5e19e048decf156a212fdaa0c1ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7", - "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7", + "url": "https://api.github.com/repos/Yoshi2889/collections/zipball/b6f90995527c5e19e048decf156a212fdaa0c1ca", + "reference": "b6f90995527c5e19e048decf156a212fdaa0c1ca", "shasum": "" }, "require": { - "php": ">=7.0" + "php": ">=7.2.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpmd/phpmd": "^2.9.1", + "phpstan/phpstan": "^0.12.84 || ^1.0.0", + "phpunit/phpunit": "^8", + "squizlabs/php_codesniffer": "^3.6.0" + }, + "suggest": { + "yoshi2889/validation-closures": "Closures to use for validating data." }, "type": "library", "autoload": { - "psr-0": { - "Evenement": "src" + "psr-4": { + "Yoshi2889\\Collections\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "Événement is a very simple event dispatching library for PHP", - "keywords": [ - "event-dispatcher", - "event-emitter" - ], - "time": "2017-07-23T21:35:13+00:00" + "description": "Simple Collection class allowing storage of specific data.", + "support": { + "issues": "https://github.com/Yoshi2889/collections/issues", + "source": "https://github.com/Yoshi2889/collections/tree/v0.2" + }, + "time": "2021-11-03T10:15:43+00:00" }, { - "name": "yoshi2889/collections", - "version": "v0.1.6", + "name": "yoshi2889/validation-closures", + "version": "v0.2", "source": { "type": "git", - "url": "https://github.com/Yoshi2889/collections.git", - "reference": "32d9531f66584bfae51c09c7a505db1ce5a559b0" + "url": "https://github.com/Yoshi2889/validation-closures.git", + "reference": "e51dc6a8fd17369a1545181a8d0c304e7a3e0527" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Yoshi2889/collections/zipball/32d9531f66584bfae51c09c7a505db1ce5a559b0", - "reference": "32d9531f66584bfae51c09c7a505db1ce5a559b0", + "url": "https://api.github.com/repos/Yoshi2889/validation-closures/zipball/e51dc6a8fd17369a1545181a8d0c304e7a3e0527", + "reference": "e51dc6a8fd17369a1545181a8d0c304e7a3e0527", "shasum": "" }, "require": { - "evenement/evenement": "^3.0 || ^2.0", - "php": ">=7.0.0" + "php": ">=7.1.0" }, "require-dev": { "phpunit/phpunit": "^6.2" }, - "suggest": { - "yoshi2889/validation-closures": "Closures to use for validating data." - }, "type": "library", "autoload": { "psr-4": { - "Yoshi2889\\Collections\\": "src/" + "ValidationClosures\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -91,33 +87,41 @@ "role": "Lead Developer" } ], - "description": "Simple Collection class allowing storage of specific data.", - "time": "2017-08-27T19:19:15+00:00" - }, + "description": "Closures useful for validating data. Provides type validation amongst other filters.", + "support": { + "issues": "https://github.com/Yoshi2889/validation-closures/issues", + "source": "https://github.com/Yoshi2889/validation-closures/tree/master" + }, + "time": "2017-07-22T22:58:02+00:00" + } + ], + "packages-dev": [ { - "name": "yoshi2889/validation-closures", - "version": "v0.2", + "name": "composer/xdebug-handler", + "version": "2.0.2", "source": { "type": "git", - "url": "https://github.com/Yoshi2889/validation-closures.git", - "reference": "e51dc6a8fd17369a1545181a8d0c304e7a3e0527" + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Yoshi2889/validation-closures/zipball/e51dc6a8fd17369a1545181a8d0c304e7a3e0527", - "reference": "e51dc6a8fd17369a1545181a8d0c304e7a3e0527", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339", "shasum": "" }, "require": { - "php": ">=7.1.0" + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1 || ^2 || ^3" }, "require-dev": { - "phpunit/phpunit": "^6.2" + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "autoload": { "psr-4": { - "ValidationClosures\\": "src/" + "Composer\\XdebugHandler\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -126,17 +130,36 @@ ], "authors": [ { - "name": "Yoshi2889", - "email": "rick.2889@gmail.com", - "homepage": "https://nanosector.nl", - "role": "Lead Developer" + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" } ], - "description": "Closures useful for validating data. Provides type validation amongst other filters.", - "time": "2017-07-22T22:58:02+00:00" - } - ], - "packages-dev": [ + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/2.0.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-07-31T17:03:58+00:00" + }, { "name": "doctrine/instantiator", "version": "1.4.0", @@ -186,6 +209,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -248,6 +275,10 @@ "object", "object graph" ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, "funding": [ { "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", @@ -256,6 +287,63 @@ ], "time": "2020-11-13T09:40:50+00:00" }, + { + "name": "pdepend/pdepend", + "version": "2.10.1", + "source": { + "type": "git", + "url": "https://github.com/pdepend/pdepend.git", + "reference": "30452fdabb3dfca89f4bf977abc44adc5391e062" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/30452fdabb3dfca89f4bf977abc44adc5391e062", + "reference": "30452fdabb3dfca89f4bf977abc44adc5391e062", + "shasum": "" + }, + "require": { + "php": ">=5.3.7", + "symfony/config": "^2.3.0|^3|^4|^5", + "symfony/dependency-injection": "^2.3.0|^3|^4|^5", + "symfony/filesystem": "^2.3.0|^3|^4|^5" + }, + "require-dev": { + "easy-doc/easy-doc": "0.0.0|^1.2.3", + "gregwar/rst": "^1.0", + "phpunit/phpunit": "^4.8.36|^5.7.27", + "squizlabs/php_codesniffer": "^2.0.0" + }, + "bin": [ + "src/bin/pdepend" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "PDepend\\": "src/main/php/PDepend" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of pdepend to be handled with Composer", + "support": { + "issues": "https://github.com/pdepend/pdepend/issues", + "source": "https://github.com/pdepend/pdepend/tree/2.10.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/pdepend/pdepend", + "type": "tidelift" + } + ], + "time": "2021-10-11T12:15:18+00:00" + }, { "name": "phar-io/manifest", "version": "2.0.3", @@ -310,6 +398,10 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, "time": "2021-07-20T11:28:43+00:00" }, { @@ -357,6 +449,10 @@ } ], "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.1.0" + }, "time": "2021-02-23T14:00:09+00:00" }, { @@ -406,20 +502,24 @@ "reflection", "static analysis" ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.2.2", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", "shasum": "" }, "require": { @@ -430,7 +530,8 @@ "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2" + "mockery/mockery": "~1.3.2", + "psalm/phar": "^4.8" }, "type": "library", "extra": { @@ -458,20 +559,24 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2020-09-03T19:13:55+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + }, + "time": "2021-10-19T17:43:47+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.4.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" + "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae", + "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae", "shasum": "" }, "require": { @@ -479,7 +584,8 @@ "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "*" + "ext-tokenizer": "*", + "psalm/phar": "^4.8" }, "type": "library", "extra": { @@ -503,37 +609,124 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-09-17T18:55:26+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1" + }, + "time": "2021-10-02T14:08:47+00:00" + }, + { + "name": "phpmd/phpmd", + "version": "2.10.2", + "source": { + "type": "git", + "url": "https://github.com/phpmd/phpmd.git", + "reference": "1bc74db7cf834662d83abebae265be11bb2eec3a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/1bc74db7cf834662d83abebae265be11bb2eec3a", + "reference": "1bc74db7cf834662d83abebae265be11bb2eec3a", + "shasum": "" + }, + "require": { + "composer/xdebug-handler": "^1.0 || ^2.0", + "ext-xml": "*", + "pdepend/pdepend": "^2.10.0", + "php": ">=5.3.9" + }, + "require-dev": { + "easy-doc/easy-doc": "0.0.0 || ^1.3.2", + "ext-json": "*", + "ext-simplexml": "*", + "gregwar/rst": "^1.0", + "mikey179/vfsstream": "^1.6.8", + "phpunit/phpunit": "^4.8.36 || ^5.7.27", + "squizlabs/php_codesniffer": "^2.0" + }, + "bin": [ + "src/bin/phpmd" + ], + "type": "library", + "autoload": { + "psr-0": { + "PHPMD\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Manuel Pichler", + "email": "github@manuel-pichler.de", + "homepage": "https://github.com/manuelpichler", + "role": "Project Founder" + }, + { + "name": "Marc Würth", + "email": "ravage@bluewin.ch", + "homepage": "https://github.com/ravage84", + "role": "Project Maintainer" + }, + { + "name": "Other contributors", + "homepage": "https://github.com/phpmd/phpmd/graphs/contributors", + "role": "Contributors" + } + ], + "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", + "homepage": "https://phpmd.org/", + "keywords": [ + "mess detection", + "mess detector", + "pdepend", + "phpmd", + "pmd" + ], + "support": { + "irc": "irc://irc.freenode.org/phpmd", + "issues": "https://github.com/phpmd/phpmd/issues", + "source": "https://github.com/phpmd/phpmd/tree/2.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/phpmd/phpmd", + "type": "tidelift" + } + ], + "time": "2021-07-22T09:56:23+00:00" }, { "name": "phpspec/prophecy", - "version": "1.13.0", + "version": "1.14.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", "shasum": "" }, "require": { "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.1", + "php": "^7.2 || ~8.0, <8.2", "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0", "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^6.0", + "phpspec/phpspec": "^6.0 || ^7.0", "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { @@ -566,7 +759,75 @@ "spy", "stub" ], - "time": "2021-03-17T13:42:18+00:00" + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/1.14.0" + }, + "time": "2021-09-10T09:02:12+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "0.12.99", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", + "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/0.12.99" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2021-09-12T20:09:55+00:00" }, { "name": "phpunit/php-code-coverage", @@ -629,6 +890,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/7.0.15" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -685,6 +950,10 @@ "filesystem", "iterator" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -732,6 +1001,10 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" + }, "time": "2015-06-21T13:50:34+00:00" }, { @@ -781,6 +1054,10 @@ "keywords": [ "timer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/2.1.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -791,29 +1068,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.1.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9c1da83261628cb24b6a6df371b6e312b3954768" + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9c1da83261628cb24b6a6df371b6e312b3954768", - "reference": "9c1da83261628cb24b6a6df371b6e312b3954768", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/a853a0e183b9db7eed023d7933a858fa1c8d25a3", + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -836,6 +1113,10 @@ "keywords": [ "tokenizer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -843,20 +1124,20 @@ } ], "abandoned": true, - "time": "2021-07-26T12:15:06+00:00" + "time": "2020-08-04T08:28:15+00:00" }, { "name": "phpunit/phpunit", - "version": "8.5.20", + "version": "8.5.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9deefba183198398a09b927a6ac6bc1feb0b7b70" + "reference": "50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9deefba183198398a09b927a6ac6bc1feb0b7b70", - "reference": "9deefba183198398a09b927a6ac6bc1feb0b7b70", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984", + "reference": "50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984", "shasum": "" }, "require": { @@ -926,6 +1207,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.21" + }, "funding": [ { "url": "https://phpunit.de/donate.html", @@ -936,75 +1221,177 @@ "type": "github" } ], - "time": "2021-08-31T06:44:38+00:00" + "time": "2021-09-25T07:37:20+00:00" }, { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.2", + "name": "psr/container", + "version": "1.1.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" + "url": "https://github.com/php-fig/container.git", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { - "php": ">=5.6" - }, - "require-dev": { - "phpunit/phpunit": "^8.5" + "php": ">=7.2.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Psr\\Container\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" } ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" ], - "time": "2020-11-30T08:15:22+00:00" + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.1" + }, + "time": "2021-03-05T17:36:06+00:00" }, { - "name": "sebastian/comparator", - "version": "3.0.3", + "name": "psr/log", + "version": "3.0.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", "shasum": "" }, "require": { - "php": ">=7.1", + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "^8.5" + }, + "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": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:15:22+00:00" + }, + { + "name": "sebastian/comparator", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", + "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", + "shasum": "" + }, + "require": { + "php": ">=7.1", "sebastian/diff": "^3.0", "sebastian/exporter": "^3.1" }, @@ -1051,6 +1438,10 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1113,6 +1504,10 @@ "unidiff", "unified diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/3.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1172,6 +1567,10 @@ "environment", "hhvm" ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/4.2.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1245,6 +1644,10 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1305,6 +1708,10 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/3.0.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1358,6 +1765,10 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1409,6 +1820,10 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1468,6 +1883,10 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1516,6 +1935,10 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/2.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1568,6 +1991,10 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/1.1.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1617,6 +2044,10 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/master" + }, "time": "2016-10-03T07:35:21+00:00" }, { @@ -1668,8 +2099,310 @@ "phpcs", "standards" ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, "time": "2021-10-11T04:00:11+00:00" }, + { + "name": "symfony/config", + "version": "v5.3.10", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "ac23c2f24d5634966d665d836c3933d54347e5d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/ac23c2f24d5634966d665d836c3933d54347e5d4", + "reference": "ac23c2f24d5634966d665d836c3933d54347e5d4", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/filesystem": "^4.4|^5.0", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php81": "^1.22" + }, + "conflict": { + "symfony/finder": "<4.4" + }, + "require-dev": { + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/messenger": "^4.4|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/yaml": "^4.4|^5.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "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": "Helps you find, load, combine, autofill and validate configuration values of any kind", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/config/tree/v5.3.10" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-22T09:06:52+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v5.3.10", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "be833dd336c248ef2bdabf24665351455f52afdb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/be833dd336c248ef2bdabf24665351455f52afdb", + "reference": "be833dd336c248ef2bdabf24665351455f52afdb", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1.1", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1.6|^2" + }, + "conflict": { + "ext-psr": "<1.1|>=2", + "symfony/config": "<5.3", + "symfony/finder": "<4.4", + "symfony/proxy-manager-bridge": "<4.4", + "symfony/yaml": "<4.4" + }, + "provide": { + "psr/container-implementation": "1.0", + "symfony/service-implementation": "1.0|2.0" + }, + "require-dev": { + "symfony/config": "^5.3", + "symfony/expression-language": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "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": "Allows you to standardize and centralize the way objects are constructed in your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/dependency-injection/tree/v5.3.10" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-22T18:11:05+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "343f4fe324383ca46792cae728a3b6e2f708fb32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/343f4fe324383ca46792cae728a3b6e2f708fb32", + "reference": "343f4fe324383ca46792cae728a3b6e2f708fb32", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "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": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-21T12:40:44+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.23.0", @@ -1730,6 +2463,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -1746,6 +2482,247 @@ ], "time": "2021-02-19T12:13:01+00:00" }, + { + "name": "symfony/polyfill-php80", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-28T13:41:28+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "e66119f3de95efc359483f810c4c3e6436279436" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/e66119f3de95efc359483f810c4c3e6436279436", + "reference": "e66119f3de95efc359483f810c4c3e6436279436", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-21T13:25:03+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-04-01T10:43:52+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", @@ -1784,6 +2761,10 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, "funding": [ { "url": "https://github.com/theseer", @@ -1844,6 +2825,10 @@ "check", "validate" ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.10.0" + }, "time": "2021-03-09T10:59:23+00:00" } ], @@ -1856,8 +2841,5 @@ "php": ">=7.2.0" }, "platform-dev": [], - "platform-overrides": { - "php": "7.2.0" - }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.1.0" } diff --git a/phpmd_ruleset.xml b/phpmd_ruleset.xml new file mode 100644 index 0000000..1ab30e2 --- /dev/null +++ b/phpmd_ruleset.xml @@ -0,0 +1,20 @@ + + + + Custom PHPMD ruleset + + + + + + + + + + + + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..1cd333b --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 8 + paths: + - src + - tests diff --git a/src/Command.php b/src/Command.php index 359de10..4df667f 100644 --- a/src/Command.php +++ b/src/Command.php @@ -1,4 +1,5 @@ setCallback($callback); } - /** - * @return callable - */ public function getCallback(): callable { return $this->callback; } - /** - * @param callable $callback - */ - public function setCallback(callable $callback) + public function setCallback(callable $callback): void { $this->callback = $callback; } /** - * @return array + * @return ParameterStrategy[] */ public function getParameterStrategies(): array { @@ -65,12 +62,12 @@ public function getParameterStrategies(): array /** * @param ParameterStrategy[] $parameterStrategies */ - public function setParameterStrategies(array $parameterStrategies) + public function setParameterStrategies(array $parameterStrategies): void { if (!Utils::validateArray(Types::instanceof(ParameterStrategy::class), $parameterStrategies)) { - throw new \InvalidArgumentException('Invalid array passed'); + throw new InvalidArgumentException('Invalid array passed'); } $this->parameterStrategies = $parameterStrategies; } -} \ No newline at end of file +} diff --git a/src/CommandParser.php b/src/CommandParser.php index 247150a..b056eb6 100644 --- a/src/CommandParser.php +++ b/src/CommandParser.php @@ -16,7 +16,7 @@ class CommandParser { /** * @param Command $commandObject - * @param array $parameters + * @param string[] $parameters * * @return ParameterStrategy * @throws Exceptions\InvalidParameterCountException @@ -27,12 +27,12 @@ public static function findApplicableStrategy(Command $commandObject, array $par { $parameterStrategies = $commandObject->getParameterStrategies(); - /** @var ParameterStrategy $parameterStrategy */ foreach ($parameterStrategies as $parameterStrategy) { $result = $parameterStrategy->validateParameterArray($parameters); - if ($result) + if ($result) { return $parameterStrategy; + } } throw new NoApplicableStrategiesException(); @@ -49,11 +49,11 @@ public static function parseFromString(string $string, string $prefix = '!'): Pa $messageParts = explode(' ', trim($string)); $firstPart = array_shift($messageParts); - if (strlen($firstPart) == strlen($prefix)) { + if (strlen($firstPart) === strlen($prefix)) { throw new ParseException(); } - if (substr($firstPart, 0, strlen($prefix)) != $prefix) { + if (strpos($firstPart, $prefix) !== 0) { throw new ParseException(); } @@ -64,8 +64,6 @@ public static function parseFromString(string $string, string $prefix = '!'): Pa return !preg_match('/^$|\s/', $parameter); }))); - $parsedCommand = new ParsedCommand($command, $parameters); - - return $parsedCommand; + return new ParsedCommand($command, $parameters); } -} \ No newline at end of file +} diff --git a/src/CommandProcessor.php b/src/CommandProcessor.php index 78455b8..b613d85 100644 --- a/src/CommandProcessor.php +++ b/src/CommandProcessor.php @@ -14,22 +14,27 @@ class CommandProcessor { + /** - * @var Collection + * @var Collection<\WildPHP\Commands\Command> */ protected $commandCollection = null; /** * CommandProcessor constructor. - * @param Command[] $initialValues + * + * @param Command[] $initialValues */ public function __construct(array $initialValues = []) { - $this->setCommandCollection(new Collection(Types::instanceof(Command::class), $initialValues)); + $this->setCommandCollection( + new Collection(Types::instanceof(Command::class), $initialValues) + ); } /** - * @param ParsedCommand $parsedCommand + * @param ParsedCommand $parsedCommand + * * @return ProcessedCommand * @throws Exceptions\CommandNotFoundException * @throws Exceptions\InvalidParameterCountException @@ -42,12 +47,6 @@ public function process(ParsedCommand $parsedCommand): ProcessedCommand return self::processParsedCommand($parsedCommand, $commandObject); } - /** - * @param string $command - * @param Command $commandObject - * - * @return bool - */ public function registerCommand(string $command, Command $commandObject): bool { if ($this->getCommandCollection()->offsetExists($command)) { @@ -60,7 +59,7 @@ public function registerCommand(string $command, Command $commandObject): bool } /** - * @param string $command + * @param string $command * * @return Command * @throws Exceptions\CommandNotFoundException @@ -69,26 +68,31 @@ public function findCommand(string $command): Command { $dictionary = $this->getCommandCollection(); - if (!$dictionary->offsetExists($command)) { + if (!$dictionary->offsetExists($command) || is_null($dictionary[$command])) { throw new Exceptions\CommandNotFoundException(); } - /** @var Command $commandObject */ return $dictionary[$command]; } /** - * @param ParsedCommand $parsedCommand - * @param Command $command + * @param ParsedCommand $parsedCommand + * @param Command $command + * * @return ProcessedCommand * @throws Exceptions\InvalidParameterCountException * @throws Exceptions\NoApplicableStrategiesException * @throws Exceptions\ValidationException */ - public static function processParsedCommand(ParsedCommand $parsedCommand, Command $command): ProcessedCommand - { + public static function processParsedCommand( + ParsedCommand $parsedCommand, + Command $command + ): ProcessedCommand { $parameters = $parsedCommand->getArguments(); - $applicableStrategy = CommandParser::findApplicableStrategy($command, $parameters); + $applicableStrategy = CommandParser::findApplicableStrategy( + $command, + $parameters + ); return new ProcessedCommand( $parsedCommand->getCommand(), @@ -100,7 +104,7 @@ public static function processParsedCommand(ParsedCommand $parsedCommand, Comman } /** - * @return Collection + * @return Collection */ public function getCommandCollection(): Collection { @@ -108,10 +112,10 @@ public function getCommandCollection(): Collection } /** - * @param Collection $commandCollection + * @param Collection $commandCollection */ - public function setCommandCollection(Collection $commandCollection) + public function setCommandCollection(Collection $commandCollection): void { $this->commandCollection = $commandCollection; } -} \ No newline at end of file +} diff --git a/src/Exceptions/CommandNotFoundException.php b/src/Exceptions/CommandNotFoundException.php index 2ec144d..654dfe8 100644 --- a/src/Exceptions/CommandNotFoundException.php +++ b/src/Exceptions/CommandNotFoundException.php @@ -1,4 +1,5 @@ + */ class ParameterStrategy extends Collection { /** @@ -47,7 +52,7 @@ public function __construct( bool $concatLeftover = false ) { if ($maximumParameters >= 0 && $minimumParameters > $maximumParameters) { - throw new \InvalidArgumentException('Invalid parameter range (minimum cannot be larger than maximum)'); + throw new InvalidArgumentException('Invalid parameter range (minimum cannot be larger than maximum)'); } parent::__construct(Types::instanceof(ParameterInterface::class), $initialValues); @@ -76,7 +81,7 @@ public function validateParameter(string $parameterName, string $parameterValue) } /** - * @param array $args + * @param string[] $args * * @return bool * @throws \InvalidArgumentException @@ -109,7 +114,7 @@ public function validateParameterArray(array $args): bool } /** - * @param array $args + * @param string[] $args * * @return bool */ @@ -133,19 +138,19 @@ public function validateParameterCount(array $args): bool public function convertParameter(string $parameterName, string $parameterValue) { if (!$this->offsetExists($parameterName)) { - throw new \InvalidArgumentException('Parameter name does not exist'); + throw new InvalidArgumentException('Parameter name does not exist'); } - if (!($this[$parameterName] instanceof ConvertibleParameterInterface)) { - return $parameterValue; + if ($this[$parameterName] instanceof ConvertibleParameterInterface) { + return $this[$parameterName]->convert($parameterValue); } - return $this[$parameterName]->convert($parameterValue); + return $parameterValue; } /** - * @param array $parameters - * @return array + * @param array $parameters + * @return array */ public function convertParameterArray(array $parameters): array { @@ -157,8 +162,8 @@ public function convertParameterArray(array $parameters): array } /** - * @param array $parameters - * @return array + * @param array $parameters + * @return array */ public function remapNumericParameterIndexes(array $parameters): array { @@ -180,17 +185,11 @@ public function remapNumericParameterIndexes(array $parameters): array return $remappedParameters; } - /** - * @return bool - */ public function shouldConcatLeftover(): bool { return $this->concatLeftover; } - /** - * @param bool $concatLeftover - */ public function setConcatLeftover(bool $concatLeftover): void { $this->concatLeftover = $concatLeftover; @@ -208,4 +207,4 @@ public static function implodeLeftoverParameters(array $arguments, int $offset): $array2 = [implode(' ', array_slice($arguments, $offset))]; return array_merge($array1, $array2); } -} \ No newline at end of file +} diff --git a/src/Parameters/ConvertibleParameterInterface.php b/src/Parameters/ConvertibleParameterInterface.php index 39bba53..5181e0c 100644 --- a/src/Parameters/ConvertibleParameterInterface.php +++ b/src/Parameters/ConvertibleParameterInterface.php @@ -9,7 +9,6 @@ namespace WildPHP\Commands\Parameters; - interface ConvertibleParameterInterface extends ParameterInterface { /** @@ -17,4 +16,4 @@ interface ConvertibleParameterInterface extends ParameterInterface * @return mixed Output may be unpredictable. */ public function convert(string $input); -} \ No newline at end of file +} diff --git a/src/Parameters/NumericParameter.php b/src/Parameters/NumericParameter.php index 7ef349d..a423b52 100644 --- a/src/Parameters/NumericParameter.php +++ b/src/Parameters/NumericParameter.php @@ -1,4 +1,5 @@ validationClosure = $validationClosure; } @@ -32,4 +35,4 @@ public function validate(string $input): bool { return ($this->validationClosure)($input); } -} \ No newline at end of file +} diff --git a/src/Parameters/ParameterInterface.php b/src/Parameters/ParameterInterface.php index 76f3127..341404f 100644 --- a/src/Parameters/ParameterInterface.php +++ b/src/Parameters/ParameterInterface.php @@ -1,4 +1,5 @@ setArguments($arguments); } - /** - * @return string - */ public function getCommand(): string { return $this->command; } - /** - * @param string $command - */ public function setCommand(string $command): void { $this->command = $command; } /** - * @return array + * @return string[] */ public function getArguments(): array { @@ -58,13 +53,10 @@ public function getArguments(): array } /** - * @param array $arguments + * @param string[] $arguments */ public function setArguments(array $arguments): void { $this->arguments = $arguments; } - - - -} \ No newline at end of file +} diff --git a/src/ProcessedCommand.php b/src/ProcessedCommand.php index 8bbc13a..b6a0281 100644 --- a/src/ProcessedCommand.php +++ b/src/ProcessedCommand.php @@ -9,7 +9,6 @@ namespace WildPHP\Commands; - class ProcessedCommand extends ParsedCommand { /** @@ -18,7 +17,7 @@ class ProcessedCommand extends ParsedCommand protected $applicableStrategy = null; /** - * @var array + * @var mixed[] */ protected $convertedParameters = []; @@ -30,40 +29,39 @@ class ProcessedCommand extends ParsedCommand /** * ProcessedCommand constructor. * @param string $command - * @param array $arguments + * @param string[] $arguments * @param ParameterStrategy $applicableStrategy - * @param array $convertedParameters + * @param mixed[] $convertedParameters * @param callable $callback */ - public function __construct(string $command, array $arguments, ParameterStrategy $applicableStrategy, array $convertedParameters, callable $callback) - { + public function __construct( + string $command, + array $arguments, + ParameterStrategy $applicableStrategy, + array $convertedParameters, + callable $callback + ) { parent::__construct($command, $arguments); $this->convertedParameters = $convertedParameters; $this->applicableStrategy = $applicableStrategy; $this->callback = $callback; } - /** - * @return ParameterStrategy - */ public function getApplicableStrategy(): ParameterStrategy { return $this->applicableStrategy; } /** - * @return array + * @return mixed[] */ public function getConvertedParameters(): array { return $this->convertedParameters; } - /** - * @return callable - */ public function getCallback(): callable { return $this->callback; } -} \ No newline at end of file +} diff --git a/tests/CommandParserTest.php b/tests/CommandParserTest.php index 55d99a5..32aefcb 100644 --- a/tests/CommandParserTest.php +++ b/tests/CommandParserTest.php @@ -1,4 +1,5 @@ assertSame($parameterStrategy, CommandParser::findApplicableStrategy($command, ['1'])); - $parameterStrategy = new \WildPHP\Commands\ParameterStrategy(1, 1, [ - new \WildPHP\Tests\MockRejectAllParameter() + $parameterStrategy = new ParameterStrategy(1, 1, [ + new MockRejectAllParameter() ]); - $command = new \WildPHP\Commands\Command([$this, 'foo'], [$parameterStrategy]); + $command = new Command([$this, 'foo'], [$parameterStrategy]); - $this->expectException(\WildPHP\Commands\Exceptions\NoApplicableStrategiesException::class); + $this->expectException(NoApplicableStrategiesException::class); CommandParser::findApplicableStrategy($command, ['test']); } - public function testParseFromString() + public function testParseFromString(): void { $string = '!test param1'; - $expected = new \WildPHP\Commands\ParsedCommand('test', ['param1']); + $expected = new ParsedCommand('test', ['param1']); $this->assertEquals($expected, CommandParser::parseFromString($string, '!')); } - public function testParseFromStringFirstPartIsPrefix() + public function testParseFromStringFirstPartIsPrefix(): void { $string = '! test param1'; - $this->expectException(\WildPHP\Commands\Exceptions\ParseException::class); + $this->expectException(ParseException::class); CommandParser::parseFromString($string, '!'); } - public function testParseFromStringNoPrefix() + public function testParseFromStringNoPrefix(): void { $string = 'test param1'; - $this->expectException(\WildPHP\Commands\Exceptions\ParseException::class); + $this->expectException(ParseException::class); CommandParser::parseFromString($string, '!'); } } diff --git a/tests/CommandProcessorTest.php b/tests/CommandProcessorTest.php index dfacf10..e36e6ac 100644 --- a/tests/CommandProcessorTest.php +++ b/tests/CommandProcessorTest.php @@ -1,4 +1,5 @@ assertTrue($commandProcessor->registerCommand('test', $command)); @@ -27,25 +36,25 @@ public function testRegisterCommand() $this->assertSame($command, $commandProcessor->findCommand('test')); } - public function testInvalidFindCommand() + public function testInvalidFindCommand(): void { - $command = new \WildPHP\Commands\Command([$this, 'foo'], new \WildPHP\Commands\ParameterStrategy()); + $command = new Command([$this, 'foo'], new ParameterStrategy()); $commandProcessor = new CommandProcessor(); $commandProcessor->registerCommand('test', $command); - $this->expectException(\WildPHP\Commands\Exceptions\CommandNotFoundException::class); + $this->expectException(CommandNotFoundException::class); $commandProcessor->findCommand('ing'); } - public function testProcess() + public function testProcess(): void { - $parameterStrategy = new \WildPHP\Commands\ParameterStrategy(1, 1, [ - new \WildPHP\Commands\Parameters\NumericParameter() + $parameterStrategy = new ParameterStrategy(1, 1, [ + new NumericParameter() ]); - $command = new \WildPHP\Commands\Command([$this, 'foo'], [$parameterStrategy]); + $command = new Command([$this, 'foo'], [$parameterStrategy]); - $expectedProcessedCommand = new \WildPHP\Commands\ProcessedCommand( + $expected = new ProcessedCommand( 'test', ['1'], $parameterStrategy, @@ -56,8 +65,8 @@ public function testProcess() $commandProcessor = new CommandProcessor(); $commandProcessor->registerCommand('test', $command); - $parsedCommand = new \WildPHP\Commands\ParsedCommand('test', ['1']); + $parsedCommand = new ParsedCommand('test', ['1']); - $this->assertEquals($expectedProcessedCommand, $commandProcessor->process($parsedCommand)); + $this->assertEquals($expected, $commandProcessor->process($parsedCommand)); } } diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 179e611..50f6312 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -1,4 +1,5 @@ setCallback([$this, 'bar']); $this->assertEquals([$this, 'bar'], $command->getCallback()); } - public function testGetParameterStrategies() + public function testGetParameterStrategies(): void { $parameterStrategies = [ - new \WildPHP\Commands\ParameterStrategy(), - new \WildPHP\Commands\ParameterStrategy(), - new \WildPHP\Commands\ParameterStrategy(), - new \WildPHP\Commands\ParameterStrategy() + new ParameterStrategy(), + new ParameterStrategy(), + new ParameterStrategy(), + new ParameterStrategy() ]; $command = new Command([$this, 'foo'], $parameterStrategies); $this->assertSame($parameterStrategies, $command->getParameterStrategies()); } - public function testGetCallback() + public function testGetCallback(): void { - $parameterStrategy = new \WildPHP\Commands\ParameterStrategy(); + $parameterStrategy = new ParameterStrategy(); $command = new Command([$this, 'foo'], $parameterStrategy); $this->assertEquals([$this, 'foo'], $command->getCallback()); } - public function testSetParameterStrategies() + public function testSetParameterStrategies(): void { $parameterStrategies = [ - new \WildPHP\Commands\ParameterStrategy(), - new \WildPHP\Commands\ParameterStrategy(), - new \WildPHP\Commands\ParameterStrategy(), - new \WildPHP\Commands\ParameterStrategy() + new ParameterStrategy(), + new ParameterStrategy(), + new ParameterStrategy(), + new ParameterStrategy() ]; - $command = new Command([$this, 'foo'], new \WildPHP\Commands\ParameterStrategy()); + $command = new Command([$this, 'foo'], new ParameterStrategy()); $command->setParameterStrategies($parameterStrategies); $this->assertSame($parameterStrategies, $command->getParameterStrategies()); - $this->expectException(\InvalidArgumentException::class); - $command->setParameterStrategies([new \WildPHP\Commands\Parameters\NumericParameter()]); + $this->expectException(InvalidArgumentException::class); + $command->setParameterStrategies([new NumericParameter()]); } } diff --git a/tests/MockConvertibleParameter.php b/tests/MockConvertibleParameter.php index e5ce4f4..caa46f4 100644 --- a/tests/MockConvertibleParameter.php +++ b/tests/MockConvertibleParameter.php @@ -1,4 +1,5 @@ assertSame(3, $numericParameter->convert('3')); diff --git a/tests/ParameterStrategyTest.php b/tests/ParameterStrategyTest.php index add6e5e..37f4de6 100644 --- a/tests/ParameterStrategyTest.php +++ b/tests/ParameterStrategyTest.php @@ -1,4 +1,5 @@ assertFalse($parameterStrategy->validateParameterCount(['test', 'ing'])); // 2 } - public function testImplodeLeftoverParameters() + public function testImplodeLeftoverParameters(): void { $parameterStrategy = new ParameterStrategy(0, 1, [], true); $parameters = ['test', 'ing', 'something', 'large']; @@ -56,21 +63,21 @@ public function testImplodeLeftoverParameters() ); } - public function testValidateParameter() + public function testValidateParameter(): void { $parameterStrategy = new ParameterStrategy(1, 1, [ - 'test' => new \WildPHP\Commands\Parameters\NumericParameter() + 'test' => new NumericParameter() ]); $this->assertTrue($parameterStrategy->validateParameter('test', 1)); $this->assertFalse($parameterStrategy->validateParameter('test', 'ing')); } - public function testRemapNumericParameterIndexes() + public function testRemapNumericParameterIndexes(): void { $parameterStrategy = new ParameterStrategy(1, 1, [ - 'test' => new \WildPHP\Commands\Parameters\NumericParameter(), - 'ing' => new \WildPHP\Commands\Parameters\NumericParameter() + 'test' => new NumericParameter(), + 'ing' => new NumericParameter() ]); $parameters = [1, 2]; @@ -82,7 +89,7 @@ public function testRemapNumericParameterIndexes() $this->assertEquals($expected, $parameterStrategy->remapNumericParameterIndexes($parameters)); } - public function testConvertParameter() + public function testConvertParameter(): void { $parameterStrategy = new \WildPHP\Commands\ParameterStrategy(1, 4, [ new MockConvertibleParameter(), @@ -104,7 +111,7 @@ public function testConvertParameter() ); $parameterStrategy = new \WildPHP\Commands\ParameterStrategy(1, 1, [ - 'test' => new \WildPHP\Commands\Parameters\StringParameter() + 'test' => new StringParameter() ]); $this->assertEquals( @@ -117,16 +124,16 @@ public function testConvertParameter() $parameterStrategy->convertParameter('test', 'test') ); - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $parameterStrategy->convertParameter('testing', 'ing'); } - public function testValidateParameterArray() + public function testValidateParameterArray(): void { $parameterStrategy = new ParameterStrategy(3, 3, [ - 'test' => new \WildPHP\Commands\Parameters\NumericParameter(), - 'test2' => new \WildPHP\Commands\Parameters\NumericParameter(), - 'test3' => new \WildPHP\Commands\Parameters\StringParameter() + 'test' => new NumericParameter(), + 'test2' => new NumericParameter(), + 'test3' => new StringParameter() ]); $this->assertTrue($parameterStrategy->validateParameterArray([1, 2, 3])); @@ -140,32 +147,32 @@ public function testValidateParameterArray() $this->assertTrue($parameterStrategy->validateParameterArray([1, 2, 'test', 'ing'])); } - public function testInvalidParameterCount() + public function testInvalidParameterCount(): void { $parameterStrategy = new ParameterStrategy(1, 1, [ 'test' => new MockConvertibleParameter() ]); - $this->expectException(\WildPHP\Commands\Exceptions\InvalidParameterCountException::class); + $this->expectException(InvalidParameterCountException::class); $parameterStrategy->validateParameterArray([1, 2, 3]); } - public function testMinMaxParameters() + public function testMinMaxParameters(): void { new ParameterStrategy(3, -1); new ParameterStrategy(0, 0); new ParameterStrategy(1, 2); - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); new ParameterStrategy(3, 1); } - public function testInvalidParameterName() + public function testInvalidParameterName(): void { $parameterStrategy = new ParameterStrategy(1, 1, [ 'test' => new MockConvertibleParameter() ]); - $this->expectException(\WildPHP\Commands\Exceptions\ValidationException::class); + $this->expectException(ValidationException::class); $parameterStrategy->validateParameter('testing', 'test'); } } diff --git a/tests/ParsedCommandTest.php b/tests/ParsedCommandTest.php index de5e05d..4eea637 100644 --- a/tests/ParsedCommandTest.php +++ b/tests/ParsedCommandTest.php @@ -1,4 +1,5 @@ assertSame($parameterStrategy, $processedCommand->getApplicableStrategy()); $this->assertSame(['ing'], $processedCommand->getConvertedParameters()); + $this->assertSame([$this, 'foo'], $processedCommand->getCallback()); } }