diff --git a/composer.json b/composer.json index da6a2d48..b43593e3 100644 --- a/composer.json +++ b/composer.json @@ -37,9 +37,8 @@ "phpunit/phpunit": "^8.5", "composer/composer": "^2.0", "squizlabs/php_codesniffer": "^3.4", - "phpstan/phpstan": "^0.12.50", + "phpstan/phpstan": "^1.8", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan-symfony": "^0.12.8", "yoast/phpunit-polyfills": "^0.2.0" }, "autoload" : { @@ -66,5 +65,10 @@ "phpcbf test --standard=PSR12 --encoding=UTF-8" ], "static": "phpstan --ansi analyse --level max src" + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } } } diff --git a/composer.lock b/composer.lock index ce50c74f..6121e233 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3f2147488b7e710f371eb015fa68fc06", + "content-hash": "681f3d9fa7830e342caf3135f7d68d2c", "packages": [ { "name": "aydin-hassan/cli-md-renderer", @@ -86,12 +86,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "Assert\\": "lib/Assert" - }, "files": [ "lib/Assert/functions.php" - ] + ], + "psr-4": { + "Assert\\": "lib/Assert" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -566,16 +566,16 @@ }, { "name": "league/commonmark", - "version": "1.6.2", + "version": "1.6.7", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "7d70d2f19c84bcc16275ea47edabee24747352eb" + "reference": "2b8185c13bc9578367a5bf901881d1c1b5bbd09b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/7d70d2f19c84bcc16275ea47edabee24747352eb", - "reference": "7d70d2f19c84bcc16275ea47edabee24747352eb", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/2b8185c13bc9578367a5bf901881d1c1b5bbd09b", + "reference": "2b8185c13bc9578367a5bf901881d1c1b5bbd09b", "shasum": "" }, "require": { @@ -593,7 +593,7 @@ "github/gfm": "0.29.0", "michelf/php-markdown": "~1.4", "mikehaertl/php-shellcommand": "^1.4", - "phpstan/phpstan": "^0.12", + "phpstan/phpstan": "^0.12.90", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.2", "scrutinizer/ocular": "^1.5", "symfony/finder": "^4.2" @@ -638,10 +638,6 @@ "source": "https://github.com/thephpleague/commonmark" }, "funding": [ - { - "url": "https://enjoy.gitstore.app/repositories/thephpleague/commonmark", - "type": "custom" - }, { "url": "https://www.colinodell.com/sponsor", "type": "custom" @@ -654,29 +650,25 @@ "url": "https://github.com/colinodell", "type": "github" }, - { - "url": "https://www.patreon.com/colinodell", - "type": "patreon" - }, { "url": "https://tidelift.com/funding/github/packagist/league/commonmark", "type": "tidelift" } ], - "time": "2021-05-12T11:39:41+00:00" + "time": "2022-01-13T17:18:13+00:00" }, { "name": "myclabs/php-enum", - "version": "1.8.0", + "version": "1.8.4", "source": { "type": "git", "url": "https://github.com/myclabs/php-enum.git", - "reference": "46cf3d8498b095bd33727b13fd5707263af99421" + "reference": "a867478eae49c9f59ece437ae7f9506bfaa27483" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/php-enum/zipball/46cf3d8498b095bd33727b13fd5707263af99421", - "reference": "46cf3d8498b095bd33727b13fd5707263af99421", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/a867478eae49c9f59ece437ae7f9506bfaa27483", + "reference": "a867478eae49c9f59ece437ae7f9506bfaa27483", "shasum": "" }, "require": { @@ -686,13 +678,16 @@ "require-dev": { "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "1.*", - "vimeo/psalm": "^4.5.1" + "vimeo/psalm": "^4.6.2" }, "type": "library", "autoload": { "psr-4": { "MyCLabs\\Enum\\": "src/" - } + }, + "classmap": [ + "stubs/Stringable.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -711,7 +706,7 @@ ], "support": { "issues": "https://github.com/myclabs/php-enum/issues", - "source": "https://github.com/myclabs/php-enum/tree/1.8.0" + "source": "https://github.com/myclabs/php-enum/tree/1.8.4" }, "funding": [ { @@ -723,7 +718,7 @@ "type": "tidelift" } ], - "time": "2021-02-15T16:11:48+00:00" + "time": "2022-08-04T09:53:51+00:00" }, { "name": "nikic/php-parser", @@ -809,12 +804,12 @@ } }, "autoload": { - "psr-4": { - "Opis\\Closure\\": "src/" - }, "files": [ "functions.php" - ] + ], + "psr-4": { + "Opis\\Closure\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -939,12 +934,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "DI\\": "src/" - }, "files": [ "src/functions.php" - ] + ], + "psr-4": { + "DI\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1021,16 +1016,16 @@ }, { "name": "php-school/cli-menu", - "version": "4.1.0", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/php-school/cli-menu.git", - "reference": "d25ae866d86b1ac95f026e7147c0e30ef4996dcd" + "reference": "bad5e0177f2b3ada6dc14eee4011fee4001b7679" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/cli-menu/zipball/d25ae866d86b1ac95f026e7147c0e30ef4996dcd", - "reference": "d25ae866d86b1ac95f026e7147c0e30ef4996dcd", + "url": "https://api.github.com/repos/php-school/cli-menu/zipball/bad5e0177f2b3ada6dc14eee4011fee4001b7679", + "reference": "bad5e0177f2b3ada6dc14eee4011fee4001b7679", "shasum": "" }, "require": { @@ -1047,12 +1042,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "PhpSchool\\CliMenu\\": "src" - }, "files": [ "src/Util/ArrayUtils.php" - ] + ], + "psr-4": { + "PhpSchool\\CliMenu\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1079,9 +1074,9 @@ ], "support": { "issues": "https://github.com/php-school/cli-menu/issues", - "source": "https://github.com/php-school/cli-menu/tree/4.1.0" + "source": "https://github.com/php-school/cli-menu/tree/4.3.0" }, - "time": "2020-10-24T09:18:48+00:00" + "time": "2021-12-16T09:40:06+00:00" }, { "name": "php-school/keylighter", @@ -1112,12 +1107,12 @@ ], "type": "library", "autoload": { - "psr-4": { - "Kadet\\Highlighter\\": "." - }, "files": [ "./functions.php" - ] + ], + "psr-4": { + "Kadet\\Highlighter\\": "." + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2635,9 +2630,6 @@ "require": { "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" - }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", @@ -2645,12 +2637,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2678,16 +2670,16 @@ }, { "name": "phar-io/manifest", - "version": "2.0.1", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133" + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", - "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", "shasum": "" }, "require": { @@ -2732,9 +2724,9 @@ "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/master" + "source": "https://github.com/phar-io/manifest/tree/2.0.3" }, - "time": "2020-06-27T14:33:11+00:00" + "time": "2021-07-20T11:28:43+00:00" }, { "name": "phar-io/version", @@ -2787,255 +2779,29 @@ }, "time": "2021-02-23T14:00:09+00:00" }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.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" - ], - "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", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.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" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" - }, - "time": "2020-09-03T19:13:55+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.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": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" - }, - "time": "2020-09-17T18:55:26+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "1.13.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.1", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11.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" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.13.0" - }, - "time": "2021-03-17T13:42:18+00:00" - }, { "name": "phpstan/extension-installer", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/phpstan/extension-installer.git", - "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" + "reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", - "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f06dbb052ddc394e7896fcd1cfcd533f9f6ace40", + "reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40", "shasum": "" }, "require": { - "composer-plugin-api": "^1.1 || ^2.0", - "php": "^7.1 || ^8.0", - "phpstan/phpstan": ">=0.11.6" + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.8.0" }, "require-dev": { - "composer/composer": "^1.8", - "phing/phing": "^2.16.3", + "composer/composer": "^2.0", "php-parallel-lint/php-parallel-lint": "^1.2.0", - "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" }, "type": "composer-plugin", "extra": { @@ -3053,26 +2819,26 @@ "description": "Composer plugin for automatic installation of PHPStan extensions", "support": { "issues": "https://github.com/phpstan/extension-installer/issues", - "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" + "source": "https://github.com/phpstan/extension-installer/tree/1.2.0" }, - "time": "2020-12-13T13:06:13+00:00" + "time": "2022-10-17T12:59:16+00:00" }, { "name": "phpstan/phpstan", - "version": "0.12.88", + "version": "1.8.10", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "464d1a81af49409c41074aa6640ed0c4cbd9bb68" + "reference": "0c4459dc42c568b818b3f25186589f3acddc1823" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/464d1a81af49409c41074aa6640ed0c4cbd9bb68", - "reference": "464d1a81af49409c41074aa6640ed0c4cbd9bb68", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0c4459dc42c568b818b3f25186589f3acddc1823", + "reference": "0c4459dc42c568b818b3f25186589f3acddc1823", "shasum": "" }, "require": { - "php": "^7.1|^8.0" + "php": "^7.2|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -3082,11 +2848,6 @@ "phpstan.phar" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - } - }, "autoload": { "files": [ "bootstrap.php" @@ -3097,9 +2858,13 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.88" + "source": "https://github.com/phpstan/phpstan/tree/1.8.10" }, "funding": [ { @@ -3107,97 +2872,28 @@ "type": "github" }, { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" + "url": "https://github.com/phpstan", + "type": "github" }, { "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", "type": "tidelift" } ], - "time": "2021-05-17T12:24:49+00:00" - }, - { - "name": "phpstan/phpstan-symfony", - "version": "0.12.35", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-symfony.git", - "reference": "0cd5b0d7666294c2a983aa276bb2d7fa125d0ae4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/0cd5b0d7666294c2a983aa276bb2d7fa125d0ae4", - "reference": "0cd5b0d7666294c2a983aa276bb2d7fa125d0ae4", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^0.12.86" - }, - "conflict": { - "symfony/framework-bundle": "<3.0" - }, - "require-dev": { - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^0.12.16", - "phpstan/phpstan-strict-rules": "^0.12.5", - "phpunit/phpunit": "^9.5", - "symfony/config": "^4.2 || ^5.0", - "symfony/console": "^4.0 || ^5.0", - "symfony/framework-bundle": "^4.4 || ^5.0", - "symfony/http-foundation": "^4.0 || ^5.0", - "symfony/messenger": "^4.2 || ^5.0", - "symfony/serializer": "^4.0 || ^5.0" - }, - "type": "phpstan-extension", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - }, - "phpstan": { - "includes": [ - "extension.neon", - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Lukáš Unger", - "email": "looky.msc@gmail.com", - "homepage": "https://lookyman.net" - } - ], - "description": "Symfony Framework extensions and rules for PHPStan", - "support": { - "issues": "https://github.com/phpstan/phpstan-symfony/issues", - "source": "https://github.com/phpstan/phpstan-symfony/tree/0.12.35" - }, - "time": "2021-06-02T11:44:45+00:00" + "time": "2022-10-17T14:23:35+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "7.0.14", + "version": "7.0.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c" + "reference": "819f92bba8b001d4363065928088de22f25a3a48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/bb7c9a210c72e4709cdde67f8b7362f672f2225c", - "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/819f92bba8b001d4363065928088de22f25a3a48", + "reference": "819f92bba8b001d4363065928088de22f25a3a48", "shasum": "" }, "require": { @@ -3206,7 +2902,7 @@ "php": ">=7.2", "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.1.1 || ^4.0", + "phpunit/php-token-stream": "^3.1.3 || ^4.0", "sebastian/code-unit-reverse-lookup": "^1.0.1", "sebastian/environment": "^4.2.2", "sebastian/version": "^2.0.1", @@ -3249,7 +2945,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/7.0.14" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/7.0.15" }, "funding": [ { @@ -3257,20 +2953,20 @@ "type": "github" } ], - "time": "2020-12-02T13:39:03+00:00" + "time": "2021-07-26T12:20:09+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "2.0.3", + "version": "2.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357" + "reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/4b49fb70f067272b659ef0174ff9ca40fdaa6357", - "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5", + "reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5", "shasum": "" }, "require": { @@ -3309,7 +3005,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.3" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.5" }, "funding": [ { @@ -3317,7 +3013,7 @@ "type": "github" } ], - "time": "2020-11-30T08:25:21+00:00" + "time": "2021-12-02T12:42:26+00:00" }, { "name": "phpunit/php-text-template", @@ -3485,16 +3181,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.16", + "version": "8.5.30", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "cc66f2fc61296be66c99931a862200e7456b9a01" + "reference": "4fd448df9affda65a5faa58f8b93087d415216ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/cc66f2fc61296be66c99931a862200e7456b9a01", - "reference": "cc66f2fc61296be66c99931a862200e7456b9a01", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4fd448df9affda65a5faa58f8b93087d415216ce", + "reference": "4fd448df9affda65a5faa58f8b93087d415216ce", "shasum": "" }, "require": { @@ -3506,27 +3202,23 @@ "ext-xml": "*", "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.10.0", - "phar-io/manifest": "^2.0.1", + "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.2", - "phpspec/prophecy": "^1.10.3", "phpunit/php-code-coverage": "^7.0.12", - "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-file-iterator": "^2.0.4", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.1.2", - "sebastian/comparator": "^3.0.2", + "sebastian/comparator": "^3.0.5", "sebastian/diff": "^3.0.2", "sebastian/environment": "^4.2.3", - "sebastian/exporter": "^3.1.2", + "sebastian/exporter": "^3.1.5", "sebastian/global-state": "^3.0.0", "sebastian/object-enumerator": "^3.0.3", "sebastian/resource-operations": "^2.0.1", "sebastian/type": "^1.1.3", "sebastian/version": "^2.0.1" }, - "require-dev": { - "ext-pdo": "*" - }, "suggest": { "ext-soap": "*", "ext-xdebug": "*", @@ -3566,19 +3258,23 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.16" + "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.30" }, "funding": [ { - "url": "https://phpunit.de/donate.html", + "url": "https://phpunit.de/sponsors.html", "type": "custom" }, { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2021-06-05T04:46:20+00:00" + "time": "2022-09-25T03:43:00+00:00" }, { "name": "react/promise", @@ -3713,16 +3409,16 @@ }, { "name": "sebastian/comparator", - "version": "3.0.3", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" + "reference": "1dc7ceb4a24aede938c7af2a9ed1de09609ca770" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dc7ceb4a24aede938c7af2a9ed1de09609ca770", + "reference": "1dc7ceb4a24aede938c7af2a9ed1de09609ca770", "shasum": "" }, "require": { @@ -3775,7 +3471,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.5" }, "funding": [ { @@ -3783,7 +3479,7 @@ "type": "github" } ], - "time": "2020-11-30T08:04:30+00:00" + "time": "2022-09-14T12:31:48+00:00" }, { "name": "sebastian/diff", @@ -3916,16 +3612,16 @@ }, { "name": "sebastian/exporter", - "version": "3.1.3", + "version": "3.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e" + "reference": "73a9676f2833b9a7c36968f9d882589cd75511e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/6b853149eab67d4da22291d36f5b0631c0fd856e", - "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/73a9676f2833b9a7c36968f9d882589cd75511e6", + "reference": "73a9676f2833b9a7c36968f9d882589cd75511e6", "shasum": "" }, "require": { @@ -3934,7 +3630,7 @@ }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { @@ -3981,7 +3677,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.3" + "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.5" }, "funding": [ { @@ -3989,7 +3685,7 @@ "type": "github" } ], - "time": "2020-11-30T07:47:53+00:00" + "time": "2022-09-14T06:00:17+00:00" }, { "name": "sebastian/global-state", @@ -5178,64 +4874,6 @@ ], "time": "2020-07-12T23:59:07+00:00" }, - { - "name": "webmozart/assert", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "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" - ], - "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" - }, { "name": "yoast/phpunit-polyfills", "version": "0.2.0", diff --git a/phpstan.neon b/phpstan.neon index 087f077e..71ba3712 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,5 +12,5 @@ parameters: message: '#Class PHPUnit\\Framework\\TestCase not found#' path: src/TestUtils/WorkshopExerciseTest.php - excludes_analyse: + excludePaths: - src/TestUtils/WorkshopExerciseTest.php diff --git a/src/Application.php b/src/Application.php index 0f104b45..8e9473e0 100644 --- a/src/Application.php +++ b/src/Application.php @@ -6,6 +6,7 @@ use DI\Container; use DI\ContainerBuilder; +use PhpSchool\PhpWorkshop\Check\CheckInterface; use PhpSchool\PhpWorkshop\Check\CheckRepository; use PhpSchool\PhpWorkshop\Event\Event; use PhpSchool\PhpWorkshop\Event\EventDispatcher; @@ -185,6 +186,7 @@ public function configure(bool $debugMode = false): ContainerInterface } } + /** @var CheckRepository $checkRepository */ $checkRepository = $container->get(CheckRepository::class); foreach ($this->checks as $check) { if (false === $container->has($check)) { @@ -193,10 +195,23 @@ public function configure(bool $debugMode = false): ContainerInterface ); } - $checkRepository->registerCheck($container->get($check)); + $checkInstance = $container->get($check); + + if (!$checkInstance instanceof CheckInterface) { + throw new RuntimeException( + sprintf( + 'Check: "%s" does not implement the required interface: "%s".', + $check, + CheckInterface::class + ) + ); + } + + $checkRepository->registerCheck($checkInstance); } if (!empty($this->results)) { + /** @var ResultRendererFactory $resultFactory */ $resultFactory = $container->get(ResultRendererFactory::class); foreach ($this->results as $result) { @@ -234,22 +249,24 @@ public function run(): int $container = $this->configure($debug); try { - $exitCode = $container->get(CommandRouter::class)->route($args); + /** @var CommandRouter $router */ + $router = $container->get(CommandRouter::class); + $exitCode = $router->route($args); } catch (MissingArgumentException $e) { - $container - ->get(OutputInterface::class) - ->printError( - sprintf( - 'Argument%s: "%s" %s missing!', - count($e->getMissingArguments()) > 1 ? 's' : '', - implode('", "', $e->getMissingArguments()), - count($e->getMissingArguments()) > 1 ? 'are' : 'is' - ) - ); + /** @var OutputInterface $output */ + $output = $container->get(OutputInterface::class); + $output->printError( + sprintf( + 'Argument%s: "%s" %s missing!', + count($e->getMissingArguments()) > 1 ? 's' : '', + implode('", "', $e->getMissingArguments()), + count($e->getMissingArguments()) > 1 ? 'are' : 'is' + ) + ); return 1; } catch (\Throwable $e) { $message = $e->getMessage(); - $basePath = canonicalise_path($container->get('basePath')); + $basePath = canonicalise_path(is_string($path = $container->get('basePath')) ? $path : ''); if (strpos($message, $basePath) !== null) { $message = str_replace($basePath, '', $message); @@ -257,9 +274,10 @@ public function run(): int $this->tearDown($container); - $container - ->get(OutputInterface::class) - ->printException($e); + /** @var OutputInterface $output */ + $output = $container->get(OutputInterface::class); + $output->printException($e); + return 1; } @@ -307,11 +325,13 @@ private function getContainer(bool $debugMode): Container private function tearDown(ContainerInterface $container): void { try { - $container - ->get(EventDispatcher::class) - ->dispatch(new Event('application.tear-down')); + /** @var EventDispatcher $eventDispatcher */ + $eventDispatcher = $container->get(EventDispatcher::class); + $eventDispatcher->dispatch(new Event('application.tear-down')); } catch (\Throwable $t) { - $container->get(LoggerInterface::class)->error($t->getMessage(), ['exception' => $t]); + /** @var LoggerInterface $logger */ + $logger = $container->get(LoggerInterface::class); + $logger->error($t->getMessage(), ['exception' => $t]); } } } diff --git a/src/Check/DatabaseCheck.php b/src/Check/DatabaseCheck.php index 118eca13..0a55f4ec 100644 --- a/src/Check/DatabaseCheck.php +++ b/src/Check/DatabaseCheck.php @@ -100,13 +100,17 @@ public function attach(EventDispatcher $eventDispatcher): void } $eventDispatcher->listen('verify.start', function (Event $e) use ($db) { - $e->getParameter('exercise')->seed($db); + /** @var DatabaseExerciseCheck $exercise */ + $exercise = $e->getParameter('exercise'); + $exercise->seed($db); //make a copy - so solution can modify without effecting database user has access to copy($this->userDatabasePath, $this->solutionDatabasePath); }); $eventDispatcher->listen('run.start', function (Event $e) use ($db) { - $e->getParameter('exercise')->seed($db); + /** @var DatabaseExerciseCheck $exercise */ + $exercise = $e->getParameter('exercise'); + $exercise->seed($db); }); $eventDispatcher->listen('cli.verify.reference-execute.pre', function (CliExecuteEvent $e) { @@ -121,7 +125,9 @@ function (CliExecuteEvent $e) { ); $eventDispatcher->insertVerifier('verify.finish', function (Event $e) use ($db) { - $verifyResult = $e->getParameter('exercise')->verify($db); + /** @var DatabaseExerciseCheck $exercise */ + $exercise = $e->getParameter('exercise'); + $verifyResult = $exercise->verify($db); if (false === $verifyResult) { return Failure::fromNameAndReason($this->getName(), 'Database verification failed'); diff --git a/src/Check/FileComparisonCheck.php b/src/Check/FileComparisonCheck.php index 14be805b..3acefd68 100644 --- a/src/Check/FileComparisonCheck.php +++ b/src/Check/FileComparisonCheck.php @@ -80,7 +80,7 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac /** * @param int|string $key * @param string|array $file - * @return array{0: array, 1:string} + * @return array{0: array{strip?: string}, 1:string} */ private function getOptionsAndFile($key, $file): array { diff --git a/src/ComposerUtil/LockFileParser.php b/src/ComposerUtil/LockFileParser.php index afb63593..028f7585 100644 --- a/src/ComposerUtil/LockFileParser.php +++ b/src/ComposerUtil/LockFileParser.php @@ -12,7 +12,7 @@ class LockFileParser { /** - * @var array + * @var array{packages: array} */ private $contents; @@ -26,11 +26,18 @@ public function __construct(string $lockFilePath) throw new InvalidArgumentException(sprintf('Lock File: "%s" does not exist', $lockFilePath)); } - $this->contents = json_decode((string) file_get_contents($lockFilePath), true); + $content = json_decode((string) file_get_contents($lockFilePath), true); - if (!isset($this->contents['packages'])) { + if (!is_array($content)) { + throw new InvalidArgumentException(sprintf('Lock File: "%s" is corrupted', $lockFilePath)); + } + + if (!isset($content['packages']) || !is_array($content['packages'])) { throw new InvalidArgumentException(sprintf('Lock File: "%s" does not contain packages key', $lockFilePath)); } + + /** @var array{packages: array} $content */ + $this->contents = $content; } /** diff --git a/src/Event/CliExecuteEvent.php b/src/Event/CliExecuteEvent.php index 42cb5581..90fcf347 100644 --- a/src/Event/CliExecuteEvent.php +++ b/src/Event/CliExecuteEvent.php @@ -13,13 +13,13 @@ class CliExecuteEvent extends Event { /** - * @var ArrayObject + * @var ArrayObject */ private $args; /** * @param string $name The event name. - * @param ArrayObject $args The arguments that should be/have been passed to the program. + * @param ArrayObject $args The arguments that should be/have been passed to the program. * @param array $parameters The event parameters. */ public function __construct(string $name, ArrayObject $args, array $parameters = []) @@ -52,7 +52,7 @@ public function appendArg(string $arg): void /** * Get the arguments to be passed to the program. * - * @return ArrayObject + * @return ArrayObject */ public function getArgs(): ArrayObject { diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 4804e51d..ddfab528 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -41,8 +41,8 @@ public static function notValidParameter(string $parameterName, array $allowedVa sprintf( 'Parameter: "%s" can only be one of: "%s" Received: "%s"', $parameterName, - static::stringify($allowedValues), - static::stringify($actualValue) + self::stringify($allowedValues), + self::stringify($actualValue) ) ); } diff --git a/src/Exercise/ExerciseType.php b/src/Exercise/ExerciseType.php index 94ea53e8..d9a9e2ba 100644 --- a/src/Exercise/ExerciseType.php +++ b/src/Exercise/ExerciseType.php @@ -45,6 +45,6 @@ class ExerciseType extends Enum */ public function getExerciseInterface(): string { - return static::$exerciseTypeToExerciseInterfaceMap[$this->getKey()]; + return self::$exerciseTypeToExerciseInterfaceMap[$this->getKey()]; } } diff --git a/src/ExerciseRunner/CgiRunner.php b/src/ExerciseRunner/CgiRunner.php index 3a8a41e7..c1bc8dd2 100644 --- a/src/ExerciseRunner/CgiRunner.php +++ b/src/ExerciseRunner/CgiRunner.php @@ -119,7 +119,7 @@ public function getName(): string */ public function getRequiredChecks(): array { - return static::$requiredChecks; + return self::$requiredChecks; } /** diff --git a/src/ExerciseRunner/CliRunner.php b/src/ExerciseRunner/CliRunner.php index 59f3e3aa..d435c7e9 100644 --- a/src/ExerciseRunner/CliRunner.php +++ b/src/ExerciseRunner/CliRunner.php @@ -85,12 +85,12 @@ public function getName(): string */ public function getRequiredChecks(): array { - return static::$requiredChecks; + return self::$requiredChecks; } /** * @param string $fileName - * @param ArrayObject $args + * @param ArrayObject $args * @param string $type * @return string */ @@ -111,7 +111,7 @@ private function executePhpFile(string $fileName, ArrayObject $args, string $typ /** * @param string $fileName - * @param ArrayObject $args + * @param ArrayObject $args * * @return Process */ diff --git a/src/Factory/EventDispatcherFactory.php b/src/Factory/EventDispatcherFactory.php index f6c94888..f4c6e12d 100644 --- a/src/Factory/EventDispatcherFactory.php +++ b/src/Factory/EventDispatcherFactory.php @@ -23,7 +23,9 @@ class EventDispatcherFactory */ public function __invoke(ContainerInterface $container): EventDispatcher { - $dispatcher = new EventDispatcher($container->get(ResultAggregator::class)); + /** @var ResultAggregator $results */ + $results = $container->get(ResultAggregator::class); + $dispatcher = new EventDispatcher($results); //add listeners from config $eventListeners = $container->has('eventListeners') ? $container->get('eventListeners') : []; @@ -48,21 +50,25 @@ public function __invoke(ContainerInterface $container): EventDispatcher } /** - * @param array> $listeners - * @return array + * @param array>> $listeners + * @return array> */ private function mergeListenerGroups(array $listeners): array { $listeners = new Collection($listeners); - return $listeners + /** @var Collection> $mergedListeners */ + $mergedListeners = $listeners ->keys() - ->reduce(function (Collection $carry, $listenerGroup) use ($listeners) { - $events = new Collection($listeners->get($listenerGroup)); + ->reduce(function (Collection $carry, string $listenerGroup) use ($listeners): Collection { + /** @var array> $groupListeners */ + $groupListeners = $listeners->get($listenerGroup); + $events = new Collection($groupListeners); return $events ->keys() - ->reduce(function (Collection $carry, $event) use ($events) { + ->reduce(function (Collection $carry, string $event) use ($events) { + /** @var Collection> $carry */ $listeners = $events->get($event); if (!is_array($listeners)) { @@ -74,8 +80,9 @@ private function mergeListenerGroups(array $listeners): array array_merge($carry->get($event, []), $listeners) ); }, $carry); - }, new Collection()) - ->getArrayCopy(); + }, new Collection()); + + return $mergedListeners->getArrayCopy(); } /** @@ -100,6 +107,7 @@ private function attachListeners( } $dispatcher->listen($eventName, function (...$args) use ($container, $listener) { + /** @var object $service */ $service = $container->get($listener->getService()); if (!method_exists($service, $listener->getMethod())) { diff --git a/src/Factory/MarkdownCliRendererFactory.php b/src/Factory/MarkdownCliRendererFactory.php index 4275a88f..3f783932 100644 --- a/src/Factory/MarkdownCliRendererFactory.php +++ b/src/Factory/MarkdownCliRendererFactory.php @@ -48,6 +48,7 @@ class MarkdownCliRendererFactory */ public function __invoke(ContainerInterface $c): CliRenderer { + /** @var Terminal $terminal */ $terminal = $c->get(Terminal::class); $codeRender = new FencedCodeRenderer(); @@ -72,10 +73,13 @@ public function __invoke(ContainerInterface $c): CliRenderer Link::class => new LinkRenderer(), ]; + /** @var Color $color */ + $color = $c->get(Color::class); + return new CliRenderer( $blockRenderers, $inlineBlockRenderers, - $c->get(Color::class) + $color ); } } diff --git a/src/Factory/MenuFactory.php b/src/Factory/MenuFactory.php index 5c73f923..a1ccc29a 100644 --- a/src/Factory/MenuFactory.php +++ b/src/Factory/MenuFactory.php @@ -11,7 +11,6 @@ use Psr\Container\ContainerInterface; use PhpSchool\CliMenu\CliMenu; use PhpSchool\CliMenu\Builder\CliMenuBuilder; -use PhpSchool\CliMenu\MenuItem\AsciiArtItem; use PhpSchool\PhpWorkshop\Command\CreditsCommand; use PhpSchool\PhpWorkshop\Command\HelpCommand; use PhpSchool\PhpWorkshop\Command\MenuCommandInvoker; @@ -37,18 +36,31 @@ class MenuFactory */ public function __invoke(ContainerInterface $c): CliMenu { - $userStateSerializer = $c->get(UserStateSerializer::class); - $exerciseRepository = $c->get(ExerciseRepository::class); - $userState = $userStateSerializer->deSerialize(); - $exerciseRenderer = $c->get(ExerciseRenderer::class); - $workshopType = $c->get(WorkshopType::class); - $eventDispatcher = $c->get(EventDispatcher::class); - - $builder = (new CliMenuBuilder($c->get(Terminal::class))) + /** @var UserStateSerializer $userStateSerializer */ + $userStateSerializer = $c->get(UserStateSerializer::class); + $userState = $userStateSerializer->deSerialize(); + /** @var ExerciseRepository $exerciseRepository */ + $exerciseRepository = $c->get(ExerciseRepository::class); + /** @var ExerciseRenderer $exerciseRenderer */ + $exerciseRenderer = $c->get(ExerciseRenderer::class); + /** @var WorkshopType $workshopType */ + $workshopType = $c->get(WorkshopType::class); + /** @var EventDispatcher $eventDispatcher */ + $eventDispatcher = $c->get(EventDispatcher::class); + + /** @var Terminal $terminal */ + $terminal = $c->get(Terminal::class); + $builder = (new CliMenuBuilder($terminal)) ->addLineBreak(); - if (null !== $c->get('workshopLogo')) { - $builder->addAsciiArt($c->get('workshopLogo'), AsciiArtItem::POSITION_CENTER); + $logo = $c->get('workshopLogo'); + + if (!is_string($logo)) { + $logo = null; + } + + if ($logo) { + $builder->addAsciiArt($logo); } $builder @@ -69,16 +81,19 @@ function (CliMenu $menu) use ($exerciseRenderer, $eventDispatcher, $exercise) { $this->isExerciseDisabled($exercise, $userState, $workshopType) ); } - + /** @var HelpCommand $helpCommand */ + $helpCommand = $c->get(HelpCommand::class); + /** @var CreditsCommand $creditsCommand */ + $creditsCommand = $c->get(CreditsCommand::class); $builder ->addLineBreak() ->addLineBreak('-') ->addLineBreak() - ->addItem('HELP', new MenuCommandInvoker($c->get(HelpCommand::class))) - ->addItem('CREDITS', new MenuCommandInvoker($c->get(CreditsCommand::class))) + ->addItem('HELP', new MenuCommandInvoker($helpCommand)) + ->addItem('CREDITS', new MenuCommandInvoker($creditsCommand)) ->disableDefaultItems() - ->setBackgroundColour($c->get('bgColour')) - ->setForegroundColour($c->get('fgColour')) + ->setBackgroundColour(is_string($bg = $c->get('bgColour')) ? $bg : 'black') + ->setForegroundColour(is_string($fg = $c->get('fgColour')) ? $fg : 'magenta') ->setMarginAuto() ->setWidth(70) ->modifySelectableStyle(function (SelectableStyle $style) { @@ -89,25 +104,28 @@ function (CliMenu $menu) use ($exerciseRenderer, $eventDispatcher, $exercise) { ->setItemExtra('[COMPLETED]'); $builder - ->addSubMenu('OPTIONS', function (CliMenuBuilder $subMenu) use ($c) { - if (null !== $c->get('workshopLogo')) { - $subMenu->addAsciiArt($c->get('workshopLogo'), AsciiArtItem::POSITION_CENTER); + ->addSubMenu('OPTIONS', function (CliMenuBuilder $subMenu) use ($c, $logo) { + if ($logo) { + $subMenu->addAsciiArt($logo); } + /** @var ResetProgress $reset */ + $reset = $c->get(ResetProgress::class); + $subMenu ->addLineBreak('_') ->addLineBreak() ->addStaticItem('Options') ->addStaticItem('-------') - ->addItem('Reset workshop progress', $c->get(ResetProgress::class)) + ->addItem('Reset workshop progress', $reset) ->addLineBreak() ->addLineBreak('-') ->addLineBreak() ->setGoBackButtonText('GO BACK') ->setExitButtonText('EXIT'); - if (null !== $c->get('workshopTitle')) { - $subMenu->setTitle($c->get('workshopTitle')); + if (is_string($title = $c->get('workshopTitle'))) { + $subMenu->setTitle($title); } }) ->addLineBreak(); @@ -121,8 +139,8 @@ function (CliMenu $menu) use ($exerciseRenderer, $eventDispatcher, $exercise) { }); } - if (null !== $c->get('workshopTitle')) { - $builder->setTitle($c->get('workshopTitle')); + if (is_string($title = $c->get('workshopTitle'))) { + $builder->setTitle($title); } return $builder->build(); diff --git a/src/Listener/SelfCheckListener.php b/src/Listener/SelfCheckListener.php index 424e5675..b70b0951 100644 --- a/src/Listener/SelfCheckListener.php +++ b/src/Listener/SelfCheckListener.php @@ -6,6 +6,7 @@ use PhpSchool\PhpWorkshop\Event\Event; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; +use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\ResultAggregator; /** @@ -34,7 +35,9 @@ public function __invoke(Event $event): void $exercise = $event->getParameter('exercise'); if ($exercise instanceof SelfCheck) { - $this->results->add($exercise->check($event->getParameter('input'))); + /** @var Input $input */ + $input = $event->getParameter('input'); + $this->results->add($exercise->check($input)); } } } diff --git a/src/Logger/ConsoleLogger.php b/src/Logger/ConsoleLogger.php index b491e28a..0ded0d82 100644 --- a/src/Logger/ConsoleLogger.php +++ b/src/Logger/ConsoleLogger.php @@ -27,6 +27,9 @@ public function __construct(OutputInterface $output, Color $color) $this->color = $color; } + /** + * @param string $level + */ public function log($level, $message, array $context = []): void { $parts = [ diff --git a/src/Logger/Logger.php b/src/Logger/Logger.php index 9716bdaa..0bc328b8 100644 --- a/src/Logger/Logger.php +++ b/src/Logger/Logger.php @@ -19,6 +19,9 @@ public function __construct(string $filePath) $this->filePath = $filePath; } + /** + * @param string $level + */ public function log($level, $message, array $context = []): void { if (!file_exists(dirname($this->filePath))) { diff --git a/src/Result/Cgi/GenericFailure.php b/src/Result/Cgi/GenericFailure.php index f46774b5..06e6f8a2 100644 --- a/src/Result/Cgi/GenericFailure.php +++ b/src/Result/Cgi/GenericFailure.php @@ -30,7 +30,7 @@ class GenericFailure extends Failure implements FailureInterface public function __construct(RequestInterface $request, string $reason = null) { $this->request = $request; - parent::__construct(static::$name, $reason); + parent::__construct(self::$name, $reason); } /** diff --git a/src/Result/Cli/GenericFailure.php b/src/Result/Cli/GenericFailure.php index 63504866..f18397f7 100644 --- a/src/Result/Cli/GenericFailure.php +++ b/src/Result/Cli/GenericFailure.php @@ -14,7 +14,7 @@ class GenericFailure extends Failure implements FailureInterface { /** - * @var ArrayObject + * @var ArrayObject */ private $args; @@ -24,19 +24,19 @@ class GenericFailure extends Failure implements FailureInterface private static $name = 'CLI Program Runner'; /** - * @param ArrayObject $args The arguments that caused the failure. + * @param ArrayObject $args The arguments that caused the failure. * @param string|null $reason The reason (if any) of the failure. */ public function __construct(ArrayObject $args, string $reason = null) { $this->args = $args; - parent::__construct(static::$name, $reason); + parent::__construct(self::$name, $reason); } /** * Named constructor, for added code legibility. * - * @param ArrayObject $args The arguments that caused the failure. + * @param ArrayObject $args The arguments that caused the failure. * @param string|null $reason The reason (if any) of the failure. * @return self The result. */ @@ -48,7 +48,7 @@ public static function fromArgsAndReason(ArrayObject $args, string $reason = nul /** * Static constructor to create from a `PhpSchool\PhpWorkshop\Exception\CodeExecutionException` exception. * - * @param ArrayObject $args The arguments that caused the failure. + * @param ArrayObject $args The arguments that caused the failure. * @param CodeExecutionException $e The exception. * @return self The result. */ @@ -58,7 +58,7 @@ public static function fromArgsAndCodeExecutionFailure(ArrayObject $args, CodeEx } /** - * @return ArrayObject + * @return ArrayObject */ public function getArgs(): ArrayObject { diff --git a/src/Result/Cli/RequestFailure.php b/src/Result/Cli/RequestFailure.php index f264fd14..f1000989 100644 --- a/src/Result/Cli/RequestFailure.php +++ b/src/Result/Cli/RequestFailure.php @@ -13,7 +13,7 @@ class RequestFailure implements FailureInterface { /** - * @var ArrayObject + * @var ArrayObject */ private $args; @@ -28,7 +28,7 @@ class RequestFailure implements FailureInterface private $actualOutput; /** - * @param ArrayObject $args The arguments that caused the failure. + * @param ArrayObject $args The arguments that caused the failure. * @param string $expectedOutput The expected output. * @param string $actualOutput The actual output. */ @@ -42,7 +42,7 @@ public function __construct(ArrayObject $args, string $expectedOutput, string $a /** * Named constructor, for added code legibility. * - * @param ArrayObject $args The arguments that caused the failure. + * @param ArrayObject $args The arguments that caused the failure. * @param string $expectedOutput The expected result. * @param string $actualOutput The actual output. * @return self The result. @@ -55,7 +55,7 @@ public static function fromArgsAndOutput(ArrayObject $args, string $expectedOutp /** * Get the arguments that caused the failure. * - * @return ArrayObject + * @return ArrayObject */ public function getArgs(): ArrayObject { diff --git a/src/Result/Cli/ResultInterface.php b/src/Result/Cli/ResultInterface.php index 319d6a93..a43b4000 100644 --- a/src/Result/Cli/ResultInterface.php +++ b/src/Result/Cli/ResultInterface.php @@ -14,7 +14,7 @@ interface ResultInterface extends \PhpSchool\PhpWorkshop\Result\ResultInterface /** * Get the arguments associated with this result. * - * @return ArrayObject + * @return ArrayObject */ public function getArgs(): ArrayObject; } diff --git a/src/Result/Cli/Success.php b/src/Result/Cli/Success.php index 05227669..5d36485f 100644 --- a/src/Result/Cli/Success.php +++ b/src/Result/Cli/Success.php @@ -12,7 +12,7 @@ class Success implements SuccessInterface { /** - * @var ArrayObject + * @var ArrayObject */ private $args; @@ -22,7 +22,7 @@ class Success implements SuccessInterface private $name = 'CLI Program Runner'; /** - * @param ArrayObject $args The arguments for this success. + * @param ArrayObject $args The arguments for this success. */ public function __construct(ArrayObject $args) { @@ -42,7 +42,7 @@ public function getCheckName(): string /** * Get the arguments for this success. * - * @return ArrayObject + * @return ArrayObject */ public function getArgs(): ArrayObject { diff --git a/src/Solution/DirectorySolution.php b/src/Solution/DirectorySolution.php index ff172ab8..6a937c0e 100644 --- a/src/Solution/DirectorySolution.php +++ b/src/Solution/DirectorySolution.php @@ -55,6 +55,7 @@ public function __construct(string $directory, string $entryPoint, array $exclus $files = []; foreach ($iter as $file) { + /** @var \SplFileInfo $file */ if ($file->isFile()) { $files[] = trim(substr($file->getPathname(), strlen($directory)), '/'); } diff --git a/src/Solution/InTempSolutionMapper.php b/src/Solution/InTempSolutionMapper.php index 93b0d33b..2511bc22 100644 --- a/src/Solution/InTempSolutionMapper.php +++ b/src/Solution/InTempSolutionMapper.php @@ -21,6 +21,7 @@ public static function mapDirectory(string $directory): string $iterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file) { + /** @var \SplFileInfo $file */ $target = Path::join($tempDir, $iterator->getSubPathName()); if ($fileSystem->exists($target)) { diff --git a/src/UserStateSerializer.php b/src/UserStateSerializer.php index f7991386..b25af270 100644 --- a/src/UserStateSerializer.php +++ b/src/UserStateSerializer.php @@ -61,7 +61,7 @@ public function __construct( */ public function serialize(UserState $state): void { - $saveFile = sprintf('%s/%s', $this->path, static::SAVE_FILE); + $saveFile = sprintf('%s/%s', $this->path, self::SAVE_FILE); $data = file_exists($saveFile) ? $this->readJson($saveFile) @@ -82,7 +82,7 @@ public function serialize(UserState $state): void */ public function deSerialize(): UserState { - $legacySaveFile = sprintf('%s/%s', $this->path, static::LEGACY_SAVE_FILE); + $legacySaveFile = sprintf('%s/%s', $this->path, self::LEGACY_SAVE_FILE); if (file_exists($legacySaveFile)) { $userState = $this->migrateData($legacySaveFile); @@ -91,17 +91,18 @@ public function deSerialize(): UserState } } - $json = $this->readJson(sprintf('%s/%s', $this->path, static::SAVE_FILE)); + $json = $this->readJson(sprintf('%s/%s', $this->path, self::SAVE_FILE)); if (null === $json) { $this->wipeFile(); return new UserState(); } - if (!isset($json[$this->workshopName])) { + if (!isset($json[$this->workshopName]) || !is_array($json[$this->workshopName])) { return new UserState(); } $json = $json[$this->workshopName]; + if (!array_key_exists('completed_exercises', $json)) { return new UserState(); } @@ -167,7 +168,11 @@ private function migrateData(string $legacySaveFile): ?UserState } } - $userState = new UserState($data['completed_exercises'], $data['current_exercise']); + $userState = new UserState( + $data['completed_exercises'], + is_string($data['current_exercise']) ? $data['current_exercise'] : null + ); + $this->serialize($userState); unlink($legacySaveFile); @@ -196,6 +201,10 @@ private function readJson(string $filePath): ?array return null; } + if (!is_array($data)) { + return null; + } + return $data; } @@ -204,8 +213,8 @@ private function readJson(string $filePath): ?array */ private function wipeFile(): void { - if (file_exists(sprintf('%s/%s', $this->path, static::SAVE_FILE))) { - unlink(sprintf('%s/%s', $this->path, static::SAVE_FILE)); + if (file_exists(sprintf('%s/%s', $this->path, self::SAVE_FILE))) { + unlink(sprintf('%s/%s', $this->path, self::SAVE_FILE)); } } } diff --git a/src/Utils/ArrayObject.php b/src/Utils/ArrayObject.php index 8851d694..0d7b9549 100644 --- a/src/Utils/ArrayObject.php +++ b/src/Utils/ArrayObject.php @@ -12,20 +12,21 @@ * * Utility collection class. * + * @template TKey of array-key * @template T - * @implements IteratorAggregate + * @implements IteratorAggregate */ class ArrayObject implements IteratorAggregate, Countable { /** - * @var array + * @var array */ private $array; /** * Accepts an array of items. * - * @param array $array + * @param array $array */ final public function __construct(array $array = []) { @@ -112,17 +113,26 @@ public function ksort(): self /** * Reduce the items to a single value. * - * @param callable $callback - * @param mixed $initial - * @return mixed + * @template TReduceInitial + * @template TReduceReturnType + * + * @param callable(TReduceInitial|TReduceReturnType, T): TReduceReturnType $callback + * @param TReduceInitial $initial + * @return TReduceInitial|TReduceReturnType */ public function reduce(callable $callback, $initial = null) { - return array_reduce($this->array, $callback, $initial); + $result = $initial; + + foreach ($this->array as $value) { + $result = $callback($result, $value); + } + + return $result; } /** - * @return static + * @return static */ public function keys(): self { @@ -181,9 +191,11 @@ public function append($value): self /** * Get an item at the given key. * + * @template TGetDefault + * * @param string|int $key - * @param mixed $default - * @return T|mixed + * @param TGetDefault $default + * @return T|TGetDefault */ public function get($key, $default = null) { @@ -207,7 +219,7 @@ public function set(string $key, $value): self /** * Return an iterator containing all the items. Allows to `foreach` over. * - * @return ArrayIterator + * @return ArrayIterator */ public function getIterator(): ArrayIterator { @@ -217,7 +229,7 @@ public function getIterator(): ArrayIterator /** * Get all the items in the array. * - * @return array + * @return array */ public function getArrayCopy(): array { diff --git a/src/Utils/Collection.php b/src/Utils/Collection.php index 4e783229..f0dc1136 100644 --- a/src/Utils/Collection.php +++ b/src/Utils/Collection.php @@ -6,9 +6,9 @@ /** * ArrayObject is not a good name... - * + * @template TKey of array-key * @template T - * @extends ArrayObject + * @extends ArrayObject */ class Collection extends ArrayObject { diff --git a/src/Utils/StringUtils.php b/src/Utils/StringUtils.php index d64ce0c8..d3f9cffd 100644 --- a/src/Utils/StringUtils.php +++ b/src/Utils/StringUtils.php @@ -55,8 +55,8 @@ public static function pluralise(string $string, array $items, string ...$args): return vsprintf( str_replace( - array_keys(static::$pluraliseSearchReplace), - array_values(static::$pluraliseSearchReplace), + array_keys(self::$pluraliseSearchReplace), + array_values(self::$pluraliseSearchReplace), $string ), $args diff --git a/src/functions.php b/src/functions.php index b55a5279..334cfb9a 100644 --- a/src/functions.php +++ b/src/functions.php @@ -64,13 +64,16 @@ function pluralise(string $string, array $items, string ...$args): string if (!function_exists('collect')) { /** + * @template TKey of array-key * @template T - * @param array $array - * @return Collection + * @param array $array + * @return Collection */ function collect(array $array): Collection { - return new Collection($array); + /** @var Collection $collection */ + $collection = new Collection($array); + return $collection; } }