diff --git a/.gitignore b/.gitignore index 23a417a9..c97b3747 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ config.cfg *config.yaml !tests/**/config.yaml +.phpunit.result.cache vendor/ composer.phar php_errors.log diff --git a/.php_cs.dist b/.php_cs.dist index e0d99655..d533cfb0 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,5 +1,14 @@ in(__DIR__ . '/src') ->in(__DIR__ . '/tests'); @@ -11,24 +20,40 @@ For the full copyright and license information, please view the LICENSE file that was distributed with this source code. EOF; -return PhpCsFixer\Config::create() +return Config::create() + ->registerCustomFixers(new Fixers()) ->setRiskyAllowed(true) ->setUsingCache(false) ->setRules([ '@PSR2' => true, '@Symfony' => true, + 'class_attributes_separation' => ['elements' => ['method', 'property']], + 'doctrine_annotation_indentation' => true, + 'doctrine_annotation_spaces' => true, 'header_comment' => ['header' => $header, 'separate' => 'bottom', 'commentType' => 'PHPDoc'], + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 'no_useless_else' => true, 'no_useless_return' => true, + 'no_superfluous_phpdoc_tags' => true, 'ordered_class_elements' => true, 'ordered_imports' => true, 'phpdoc_order' => true, 'phpdoc_summary' => false, + 'phpdoc_var_annotation_correct_order' => true, 'blank_line_after_opening_tag' => false, 'concat_space' => ['spacing' => 'one'], 'array_syntax' => ['syntax' => 'short'], 'general_phpdoc_annotation_remove' => [ 'annotations' => ['copyright', 'category'], ], + 'php_unit_test_case_static_method_calls' => true, + 'single_line_throw' => false, + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], + NoUselessCommentFixer::name() => true, + NoUnneededConcatenationFixer::name() => true, + SingleSpaceAfterStatementFixer::name() => true, + SingleSpaceBeforeStatementFixer::name() => true, + PhpdocParamTypeFixer::name() => true, + OperatorLinebreakFixer::name() => ['only_booleans' => true], ]) ->setFinder($finder); diff --git a/README.md b/README.md index df673a54..5159516e 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ On your system at least the following packages needs to be available. * ant * git * curl - * php5-curl + * php7-curl * If you want to use coloring you should enable php.posix in your php.ini ## Available commands diff --git a/composer.json b/composer.json index 3a7dd752..1c856756 100644 --- a/composer.json +++ b/composer.json @@ -6,24 +6,22 @@ "require": { "php": ">=7.2.0", "ext-curl": "*", - "symfony/console": "~2.8", - "symfony/config": "~2.8", - "symfony/yaml": "~2.8", - "symfony/process": "~2.8", - "symfony/dependency-injection": "~2.8", + "symfony/console": "~3.4", + "symfony/config": "~3.4", + "symfony/yaml": "~3.4", + "symfony/process": "~3.4", + "symfony/dependency-injection": "~3.4", "dnoegel/php-xdg-base-dir": "~0.1", "shopwarelabs/plugin-info": "dev-master", - "ramsey/array_column": "~1.1", "fzaninotto/faker": "^1.9.1", "guzzlehttp/guzzle": "^6.5.2", - "php-http/guzzle6-adapter": "^1.0", - "piwik/ini": "^1.0", "padraic/phar-updater": "^1.0.6" }, "require-dev": { "ext-phar": "*", - "phpunit/phpunit": "^4.8.36", - "friendsofphp/php-cs-fixer": "^2.2.20" + "phpunit/phpunit": "^8.5.2", + "friendsofphp/php-cs-fixer": "^2.16.1", + "kubawerlos/php-cs-fixer-custom-fixers": "^1.17" }, "scripts": { "post-install-cmd": "ln -sf ../../hooks/pre-commit .git/hooks/pre-commit", diff --git a/composer.lock b/composer.lock index bc0e56c7..037e43ca 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": "ad7442df3b77232fa92dc8b473e5871b", + "content-hash": "bff5393d8c501441cf4d7ecf8b8f88b9", "packages": [ { "name": "composer/ca-bundle", @@ -522,148 +522,31 @@ "time": "2018-03-30T12:52:15+00:00" }, { - "name": "php-http/guzzle6-adapter", - "version": "v1.1.1", - "source": { - "type": "git", - "url": "https://github.com/php-http/guzzle6-adapter.git", - "reference": "a56941f9dc6110409cfcddc91546ee97039277ab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/guzzle6-adapter/zipball/a56941f9dc6110409cfcddc91546ee97039277ab", - "reference": "a56941f9dc6110409cfcddc91546ee97039277ab", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "^6.0", - "php": ">=5.5.0", - "php-http/httplug": "^1.0" - }, - "provide": { - "php-http/async-client-implementation": "1.0", - "php-http/client-implementation": "1.0" - }, - "require-dev": { - "ext-curl": "*", - "php-http/adapter-integration-tests": "^0.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Adapter\\Guzzle6\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - }, - { - "name": "David de Boer", - "email": "david@ddeboer.nl" - } - ], - "description": "Guzzle 6 HTTP Adapter", - "homepage": "http://httplug.io", - "keywords": [ - "Guzzle", - "http" - ], - "time": "2016-05-10T06:13:32+00:00" - }, - { - "name": "php-http/httplug", - "version": "v1.1.0", + "name": "psr/container", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/php-http/httplug.git", - "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018" + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/httplug/zipball/1c6381726c18579c4ca2ef1ec1498fdae8bdf018", - "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "shasum": "" }, "require": { - "php": ">=5.4", - "php-http/promise": "^1.0", - "psr/http-message": "^1.0" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Eric GELOEN", - "email": "geloen.eric@gmail.com" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "HTTPlug, the HTTP client abstraction for PHP", - "homepage": "http://httplug.io", - "keywords": [ - "client", - "http" - ], - "time": "2016-08-31T08:30:17+00:00" - }, - { - "name": "php-http/promise", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/promise.git", - "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", - "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", - "shasum": "" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { - "Http\\Promise\\": "src/" + "Psr\\Container\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -672,54 +555,20 @@ ], "authors": [ { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - }, - { - "name": "Joel Wurtz", - "email": "joel.wurtz@gmail.com" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "Promise used for asynchronous HTTP requests", - "homepage": "http://httplug.io", + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", "keywords": [ - "promise" - ], - "time": "2016-01-26T13:27:02+00:00" - }, - { - "name": "piwik/ini", - "version": "1.0.8", - "source": { - "type": "git", - "url": "https://github.com/matomo-org/component-ini.git", - "reference": "663d4fdedd8f344407fd1599e623f41912fe2ebd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/matomo-org/component-ini/zipball/663d4fdedd8f344407fd1599e623f41912fe2ebd", - "reference": "663d4fdedd8f344407fd1599e623f41912fe2ebd", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "athletic/athletic": "0.1.*", - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Piwik\\Ini\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0" + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" ], - "abandoned": "matomo/ini", - "time": "2019-12-21T20:06:47+00:00" + "time": "2017-02-14T16:28:37+00:00" }, { "name": "psr/http-message", @@ -858,52 +707,6 @@ "description": "A polyfill for getallheaders.", "time": "2019-03-08T08:55:37+00:00" }, - { - "name": "ramsey/array_column", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/ramsey/array_column.git", - "reference": "f8e52eb28e67eb50e613b451dd916abcf783c1db" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ramsey/array_column/zipball/f8e52eb28e67eb50e613b451dd916abcf783c1db", - "reference": "f8e52eb28e67eb50e613b451dd916abcf783c1db", - "shasum": "" - }, - "require-dev": { - "jakub-onderka/php-parallel-lint": "0.8.*", - "phpunit/phpunit": "~4.5", - "satooshi/php-coveralls": "0.6.*", - "squizlabs/php_codesniffer": "~2.2" - }, - "type": "library", - "autoload": { - "files": [ - "src/array_column.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ben Ramsey", - "homepage": "http://benramsey.com" - } - ], - "description": "Provides functionality for array_column() to projects using PHP earlier than version 5.5.", - "homepage": "https://github.com/ramsey/array_column", - "keywords": [ - "array", - "array_column", - "column" - ], - "abandoned": "it-for-free/array_column", - "time": "2015-03-20T22:07:39+00:00" - }, { "name": "shopwarelabs/plugin-info", "version": "dev-master", @@ -940,25 +743,32 @@ }, { "name": "symfony/config", - "version": "v2.8.52", + "version": "v3.4.37", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "7dd5f5040dc04c118d057fb5886563963eb70011" + "reference": "6abc18b2a97f63508d23929bbb2ae65aaa07bace" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/7dd5f5040dc04c118d057fb5886563963eb70011", - "reference": "7dd5f5040dc04c118d057fb5886563963eb70011", + "url": "https://api.github.com/repos/symfony/config/zipball/6abc18b2a97f63508d23929bbb2ae65aaa07bace", + "reference": "6abc18b2a97f63508d23929bbb2ae65aaa07bace", "shasum": "" }, "require": { - "php": ">=5.3.9", - "symfony/filesystem": "~2.3|~3.0.0", + "php": "^5.5.9|>=7.0.8", + "symfony/filesystem": "~2.8|~3.0|~4.0", "symfony/polyfill-ctype": "~1.8" }, + "conflict": { + "symfony/dependency-injection": "<3.3", + "symfony/finder": "<3.3" + }, "require-dev": { - "symfony/yaml": "~2.7|~3.0.0" + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/event-dispatcher": "~3.3|~4.0", + "symfony/finder": "~3.3|~4.0", + "symfony/yaml": "~3.0|~4.0" }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" @@ -966,7 +776,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.8-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -993,41 +803,52 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2018-11-26T09:38:12+00:00" + "time": "2020-01-04T12:05:51+00:00" }, { "name": "symfony/console", - "version": "v2.8.52", + "version": "v3.4.37", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12" + "reference": "7c5bdd346f9d90a2d22d4e1fe61e02dc19b98f12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12", - "reference": "cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12", + "url": "https://api.github.com/repos/symfony/console/zipball/7c5bdd346f9d90a2d22d4e1fe61e02dc19b98f12", + "reference": "7c5bdd346f9d90a2d22d4e1fe61e02dc19b98f12", "shasum": "" }, "require": { - "php": ">=5.3.9", - "symfony/debug": "^2.7.2|~3.0.0", + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", "symfony/polyfill-mbstring": "~1.0" }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" + }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/process": "~2.1|~3.0.0" + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" }, "suggest": { - "psr/log-implementation": "For using the console logger", + "psr/log": "For using the console logger", "symfony/event-dispatcher": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.8-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1054,37 +875,36 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-11-20T15:55:20+00:00" + "time": "2020-01-10T07:52:48+00:00" }, { "name": "symfony/debug", - "version": "v3.0.9", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a" + "reference": "20236471058bbaa9907382500fc14005c84601f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/697c527acd9ea1b2d3efac34d9806bf255278b0a", - "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a", + "url": "https://api.github.com/repos/symfony/debug/zipball/20236471058bbaa9907382500fc14005c84601f0", + "reference": "20236471058bbaa9907382500fc14005c84601f0", "shasum": "" }, "require": { - "php": ">=5.5.9", + "php": "^7.1.3", "psr/log": "~1.0" }, "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + "symfony/http-kernel": "<3.4" }, "require-dev": { - "symfony/class-loader": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0" + "symfony/http-kernel": "^3.4|^4.0|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -1111,43 +931,51 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-07-30T07:22:48+00:00" + "time": "2020-01-25T12:44:29+00:00" }, { "name": "symfony/dependency-injection", - "version": "v2.8.52", + "version": "v3.4.37", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "c306198fee8f872a8f5f031e6e4f6f83086992d8" + "reference": "22000f10c9e1cfef051e8b4de46815b41a0223fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/c306198fee8f872a8f5f031e6e4f6f83086992d8", - "reference": "c306198fee8f872a8f5f031e6e4f6f83086992d8", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/22000f10c9e1cfef051e8b4de46815b41a0223fc", + "reference": "22000f10c9e1cfef051e8b4de46815b41a0223fc", "shasum": "" }, "require": { - "php": ">=5.3.9" + "php": "^5.5.9|>=7.0.8", + "psr/container": "^1.0" }, "conflict": { - "symfony/expression-language": "<2.6" + "symfony/config": "<3.3.7", + "symfony/finder": "<3.3", + "symfony/proxy-manager-bridge": "<3.4", + "symfony/yaml": "<3.4" + }, + "provide": { + "psr/container-implementation": "1.0" }, "require-dev": { - "symfony/config": "~2.2|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/yaml": "~2.3.42|~2.7.14|~2.8.7|~3.0.7" + "symfony/config": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/yaml": "~3.4|~4.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", "extra": { "branch-alias": { - "dev-master": "2.8-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1174,29 +1002,30 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2019-04-16T11:33:46+00:00" + "time": "2020-01-08T11:20:51+00:00" }, { "name": "symfony/filesystem", - "version": "v3.0.9", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "b2da5009d9bacbd91d83486aa1f44c793a8c380d" + "reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/b2da5009d9bacbd91d83486aa1f44c793a8c380d", - "reference": "b2da5009d9bacbd91d83486aa1f44c793a8c380d", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/266c9540b475f26122b61ef8b23dd9198f5d1cfd", + "reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -1223,7 +1052,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-07-20T05:43:46+00:00" + "time": "2020-01-21T08:20:44+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1344,25 +1173,25 @@ }, { "name": "symfony/process", - "version": "v2.8.52", + "version": "v3.4.37", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "c3591a09c78639822b0b290d44edb69bf9f05dc8" + "reference": "5b9d2bcffe4678911a4c941c00b7c161252cf09a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c3591a09c78639822b0b290d44edb69bf9f05dc8", - "reference": "c3591a09c78639822b0b290d44edb69bf9f05dc8", + "url": "https://api.github.com/repos/symfony/process/zipball/5b9d2bcffe4678911a4c941c00b7c161252cf09a", + "reference": "5b9d2bcffe4678911a4c941c00b7c161252cf09a", "shasum": "" }, "require": { - "php": ">=5.3.9" + "php": "^5.5.9|>=7.0.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.8-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1389,30 +1218,39 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" + "time": "2020-01-01T11:03:25+00:00" }, { "name": "symfony/yaml", - "version": "v2.8.52", + "version": "v3.4.37", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "02c1859112aa779d9ab394ae4f3381911d84052b" + "reference": "aa46bc2233097d5212332c907f9911533acfbf80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/02c1859112aa779d9ab394ae4f3381911d84052b", - "reference": "02c1859112aa779d9ab394ae4f3381911d84052b", + "url": "https://api.github.com/repos/symfony/yaml/zipball/aa46bc2233097d5212332c907f9911533acfbf80", + "reference": "aa46bc2233097d5212332c907f9911533acfbf80", "shasum": "" }, "require": { - "php": ">=5.3.9", + "php": "^5.5.9|>=7.0.8", "symfony/polyfill-ctype": "~1.8" }, + "conflict": { + "symfony/console": "<3.4" + }, + "require-dev": { + "symfony/console": "~3.4|~4.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.8-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1439,7 +1277,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" + "time": "2020-01-13T08:00:59+00:00" } ], "packages-dev": [ @@ -1736,49 +1574,49 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.2.20", + "version": "v2.16.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "f1631f0747ad2a9dd3de8d7873b71f6573f8d0c2" + "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/f1631f0747ad2a9dd3de8d7873b71f6573f8d0c2", - "reference": "f1631f0747ad2a9dd3de8d7873b71f6573f8d0c2", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c8afb599858876e95e8ebfcd97812d383fa23f02", + "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02", "shasum": "" }, "require": { "composer/semver": "^1.4", - "composer/xdebug-handler": "^1.0", + "composer/xdebug-handler": "^1.2", "doctrine/annotations": "^1.2", "ext-json": "*", "ext-tokenizer": "*", - "php": "^5.3.6 || >=7.0 <7.3", - "sebastian/diff": "^1.4", - "symfony/console": "^2.4 || ^3.0 || ^4.0", - "symfony/event-dispatcher": "^2.1 || ^3.0 || ^4.0", - "symfony/filesystem": "^2.4 || ^3.0 || ^4.0", - "symfony/finder": "^2.2 || ^3.0 || ^4.0", - "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0", - "symfony/polyfill-php54": "^1.0", - "symfony/polyfill-php55": "^1.3", + "php": "^5.6 || ^7.0", + "php-cs-fixer/diff": "^1.3", + "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", + "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", + "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", + "symfony/finder": "^3.0 || ^4.0 || ^5.0", + "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", "symfony/polyfill-php70": "^1.0", "symfony/polyfill-php72": "^1.4", - "symfony/process": "^2.3 || ^3.0 || ^4.0", - "symfony/stopwatch": "^2.5 || ^3.0 || ^4.0" - }, - "conflict": { - "hhvm": "<3.18" + "symfony/process": "^3.0 || ^4.0 || ^5.0", + "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" }, "require-dev": { - "johnkary/phpunit-speedtrap": "^1.0.1 || ^2.0 || ^3.0", + "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", "justinrainbow/json-schema": "^5.0", - "keradus/cli-executor": "^1.1", + "keradus/cli-executor": "^1.2", "mikey179/vfsstream": "^1.6", - "php-coveralls/php-coveralls": "^1.0.2", - "phpunit/phpunit": "^4.8.35 || ^5.4.3", - "symfony/phpunit-bridge": "^3.2.2 || ^4.0" + "php-coveralls/php-coveralls": "^2.1", + "php-cs-fixer/accessible-object": "^1.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", + "phpunitgoodpractices/traits": "^1.8", + "symfony/phpunit-bridge": "^4.3 || ^5.0", + "symfony/yaml": "^3.0 || ^4.0 || ^5.0" }, "suggest": { "ext-mbstring": "For handling non-UTF8 characters in cache signature.", @@ -1798,6 +1636,7 @@ "tests/Test/AbstractFixerTestCase.php", "tests/Test/AbstractIntegrationCaseFactory.php", "tests/Test/AbstractIntegrationTestCase.php", + "tests/Test/Assert/AssertTokensTrait.php", "tests/Test/IntegrationCase.php", "tests/Test/IntegrationCaseFactory.php", "tests/Test/IntegrationCaseFactoryInterface.php", @@ -1810,40 +1649,43 @@ "MIT" ], "authors": [ - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" } ], "description": "A tool to automatically fix PHP code style", - "time": "2018-06-02T17:26:04+00:00" + "time": "2019-11-25T22:10:32+00:00" }, { - "name": "ircmaxell/password-compat", - "version": "v1.0.4", + "name": "kubawerlos/php-cs-fixer-custom-fixers", + "version": "v1.17.0", "source": { "type": "git", - "url": "https://github.com/ircmaxell/password_compat.git", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c" + "url": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers.git", + "reference": "1682fd94eefabdf31695bfff2c332680d3281bd0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c", + "url": "https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/1682fd94eefabdf31695bfff2c332680d3281bd0", + "reference": "1682fd94eefabdf31695bfff2c332680d3281bd0", "shasum": "" }, - "require-dev": { - "phpunit/phpunit": "4.*" + "require": { + "ext-tokenizer": "*", + "friendsofphp/php-cs-fixer": "^2.16.1", + "php": "^7.1", + "symfony/finder": "^3.0 || ^4.0 || ^5.0" }, "type": "library", "autoload": { - "files": [ - "lib/password.php" - ] + "psr-4": { + "PhpCsFixerCustomFixers\\": "./src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1851,18 +1693,60 @@ ], "authors": [ { - "name": "Anthony Ferrara", - "email": "ircmaxell@php.net", - "homepage": "http://blog.ircmaxell.com" + "name": "Kuba Werłos", + "email": "werlos@gmail.com" } ], - "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", - "homepage": "https://github.com/ircmaxell/password_compat", + "description": "A set of custom fixers for PHP CS Fixer", + "time": "2019-12-29T12:33:18+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.9.5", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", "keywords": [ - "hashing", - "password" + "clone", + "copy", + "duplicate", + "object", + "object graph" ], - "time": "2014-11-20T16:49:30+00:00" + "time": "2020-01-17T21:11:47+00:00" }, { "name": "paragonie/random_compat", @@ -1910,59 +1794,212 @@ "time": "2018-07-02T15:55:56+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "name": "phar-io/manifest", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", "shasum": "" }, "require": { - "php": ">=7.1" - }, - "require-dev": { - "phpunit/phpunit": "~6" + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "php": "^5.6 || ^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "time": "2018-08-07T13:53:10+00:00" + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2018-07-08T19:23:20+00:00" }, { - "name": "phpdocumentor/reflection-docblock", + "name": "phar-io/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2018-07-08T19:19:57+00:00" + }, + { + "name": "php-cs-fixer/diff", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "SpacePossum" + } + ], + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "time": "2018-02-15T16:58:55+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "~6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "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" + ], + "time": "2018-08-07T13:53:10+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", "version": "4.3.4", "source": { "type": "git", @@ -2125,39 +2162,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.2.4", + "version": "7.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1884187926fbb755a9aaf0b3836ad3165b478bf", + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.2", + "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.1.1", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^4.2.2", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" + "phpunit/phpunit": "^8.2.2" }, "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" + "ext-xdebug": "^2.7.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -2172,7 +2210,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -2183,29 +2221,32 @@ "testing", "xunit" ], - "time": "2015-10-06T15:47:00+00:00" + "time": "2019-11-20T13:55:58+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.5", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -2220,7 +2261,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -2230,7 +2271,7 @@ "filesystem", "iterator" ], - "time": "2017-11-27T13:52:08+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -2275,28 +2316,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -2311,7 +2352,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -2320,33 +2361,33 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "time": "2019-06-07T04:22:29+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.12", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -2369,45 +2410,56 @@ "keywords": [ "tokenizer" ], - "time": "2017-12-04T08:55:13+00:00" + "time": "2019-09-17T06:23:10+00:00" }, { "name": "phpunit/phpunit", - "version": "4.8.36", + "version": "8.5.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" + "reference": "018b6ac3c8ab20916db85fa91bf6465acb64d1e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/018b6ac3c8ab20916db85fa91bf6465acb64d1e0", + "reference": "018b6ac3c8ab20916db85fa91bf6465acb64d1e0", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.2.0", "ext-dom": "*", "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.9.1", + "phar-io/manifest": "^1.0.3", + "phar-io/version": "^2.0.1", + "php": "^7.2", + "phpspec/prophecy": "^1.8.1", + "phpunit/php-code-coverage": "^7.0.7", + "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.1.2", + "sebastian/comparator": "^3.0.2", + "sebastian/diff": "^3.0.2", + "sebastian/environment": "^4.2.2", + "sebastian/exporter": "^3.1.1", + "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": { - "phpunit/php-invoker": "~1.1" + "ext-soap": "*", + "ext-xdebug": "*", + "phpunit/php-invoker": "^2.0.0" }, "bin": [ "phpunit" @@ -2415,7 +2467,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.8.x-dev" + "dev-master": "8.5-dev" } }, "autoload": { @@ -2441,38 +2493,32 @@ "testing", "xunit" ], - "time": "2017-06-21T08:07:12+00:00" + "time": "2020-01-08T08:49:49+00:00" }, { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" + "phpunit/phpunit": "^5.7 || ^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -2487,94 +2533,39 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "abandoned": true, - "time": "2015-10-02T06:51:40+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "email": "sebastian@phpunit.de" } ], - "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": "2017-02-14T16:28:37+00:00" + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" }, { "name": "sebastian/comparator", - "version": "1.2.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2605,38 +2596,39 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-01-29T09:50:25+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "1.4.3", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2661,34 +2653,40 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2017-05-22T07:24:03+00:00" + "time": "2019-02-04T06:01:07+00:00" }, { "name": "sebastian/environment", - "version": "1.3.8", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -2713,34 +2711,34 @@ "environment", "hhvm" ], - "time": "2016-08-18T05:49:44+00:00" + "time": "2019-11-20T08:46:58+00:00" }, { "name": "sebastian/exporter", - "version": "1.2.2", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" + "php": "^7.0", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -2753,6 +2751,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -2761,17 +2763,13 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -2780,27 +2778,30 @@ "export", "exporter" ], - "time": "2016-06-17T09:04:28+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/global-state", - "version": "1.1.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "ext-dom": "*", + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -2808,7 +2809,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2831,32 +2832,34 @@ "keywords": [ "global state" ], - "time": "2015-10-12T03:26:01+00:00" + "time": "2019-02-01T05:30:01+00:00" }, { - "name": "sebastian/recursion-context", - "version": "1.0.5", + "name": "sebastian/object-enumerator", + "version": "3.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -2869,38 +2872,41 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" } ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-10-03T07:41:43+00:00" + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-08-03T12:35:26+00:00" }, { - "name": "sebastian/version", - "version": "1.0.6", + "name": "sebastian/object-reflector", + "version": "1.1.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", "shasum": "" }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -2913,90 +2919,234 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "email": "sebastian@phpunit.de" } ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21T13:59:46+00:00" + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29T09:07:27+00:00" }, { - "name": "symfony/event-dispatcher", - "version": "v3.2.14", + "name": "sebastian/recursion-context", + "version": "3.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "b8de6ee252af19330dd72ad5fc0dd4658a1d6325" + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b8de6ee252af19330dd72ad5fc0dd4658a1d6325", - "reference": "b8de6ee252af19330dd72ad5fc0dd4658a1d6325", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^7.0" }, "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~2.8|~3.0", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" } ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2017-06-02T08:26:05+00:00" + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2017-03-03T06:23:57+00:00" }, { - "name": "symfony/finder", + "name": "sebastian/resource-operations", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2018-10-04T04:07:39+00:00" + }, + { + "name": "sebastian/type", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "time": "2019-07-02T08:10:15+00:00" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "symfony/event-dispatcher", "version": "v4.4.4", "source": { "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "3a50be43515590faf812fbd7708200aabc327ec3" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "9e3de195e5bc301704dd6915df55892f6dfc208b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/3a50be43515590faf812fbd7708200aabc327ec3", - "reference": "3a50be43515590faf812fbd7708200aabc327ec3", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9e3de195e5bc301704dd6915df55892f6dfc208b", + "reference": "9e3de195e5bc301704dd6915df55892f6dfc208b", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.1.3", + "symfony/event-dispatcher-contracts": "^1.1" + }, + "conflict": { + "symfony/dependency-injection": "<3.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "1.1" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/expression-language": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^3.4|^4.0|^5.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", "extra": { @@ -3006,7 +3156,7 @@ }, "autoload": { "psr-4": { - "Symfony\\Component\\Finder\\": "" + "Symfony\\Component\\EventDispatcher\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -3026,40 +3176,41 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Finder Component", + "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2020-01-04T13:00:46+00:00" + "time": "2020-01-10T21:54:01+00:00" }, { - "name": "symfony/options-resolver", - "version": "v4.4.4", + "name": "symfony/event-dispatcher-contracts", + "version": "v1.1.7", "source": { "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0" + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0", - "reference": "9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c43ab685673fb6c8d84220c77897b1d6cdbe1d18", + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18", "shasum": "" }, "require": { "php": "^7.1.3" }, + "suggest": { + "psr/event-dispatcher": "", + "symfony/event-dispatcher-implementation": "" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "1.1-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Symfony\\Contracts\\EventDispatcher\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3067,55 +3218,55 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony OptionsResolver Component", + "description": "Generic abstractions related to dispatching event", "homepage": "https://symfony.com", "keywords": [ - "config", - "configuration", - "options" + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" ], - "time": "2020-01-04T13:00:46+00:00" + "time": "2019-09-17T09:54:03+00:00" }, { - "name": "symfony/polyfill-php54", - "version": "v1.13.1", + "name": "symfony/finder", + "version": "v4.4.4", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php54.git", - "reference": "dd1618047426412036e98d159940d58a81fc392c" + "url": "https://github.com/symfony/finder.git", + "reference": "3a50be43515590faf812fbd7708200aabc327ec3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/dd1618047426412036e98d159940d58a81fc392c", - "reference": "dd1618047426412036e98d159940d58a81fc392c", + "url": "https://api.github.com/repos/symfony/finder/zipball/3a50be43515590faf812fbd7708200aabc327ec3", + "reference": "3a50be43515590faf812fbd7708200aabc327ec3", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "4.4-dev" } }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Php54\\": "" + "Symfony\\Component\\Finder\\": "" }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -3124,54 +3275,47 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions", + "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-04T13:00:46+00:00" }, { - "name": "symfony/polyfill-php55", - "version": "v1.13.1", + "name": "symfony/options-resolver", + "version": "v4.4.4", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php55.git", - "reference": "b0d838f225725e2951af1aafc784d2e5ea7b656e" + "url": "https://github.com/symfony/options-resolver.git", + "reference": "9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/b0d838f225725e2951af1aafc784d2e5ea7b656e", - "reference": "b0d838f225725e2951af1aafc784d2e5ea7b656e", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0", + "reference": "9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0", "shasum": "" }, "require": { - "ircmaxell/password-compat": "~1.0", - "php": ">=5.3.3" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "4.4-dev" } }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Php55\\": "" + "Symfony\\Component\\OptionsResolver\\": "" }, - "files": [ - "bootstrap.php" + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -3180,23 +3324,22 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions", + "description": "Symfony OptionsResolver Component", "homepage": "https://symfony.com", "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" + "config", + "configuration", + "options" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-04T13:00:46+00:00" }, { "name": "symfony/polyfill-php70", @@ -3420,6 +3563,46 @@ "homepage": "https://symfony.com", "time": "2020-01-04T13:00:46+00:00" }, + { + "name": "theseer/tokenizer", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2019-06-13T22:48:21+00:00" + }, { "name": "webmozart/assert", "version": "1.6.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b107d2ef..e845d60b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,7 +6,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="test_bootstrap.php" > diff --git a/src/Application.php b/src/Application.php index a95b334f..72f2b974 100644 --- a/src/Application.php +++ b/src/Application.php @@ -10,7 +10,10 @@ use Composer\Autoload\ClassLoader; use ShopwareCli\Application\DependencyInjection; +use ShopwareCli\Application\ExtensionManager; use ShopwareCli\Services\PathProvider\PathProvider; +use Symfony\Component\Console\Application as SymfonyApplication; +use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -19,16 +22,14 @@ /** * Main application of the cli tools - * - * Class Application */ -class Application extends \Symfony\Component\Console\Application +class Application extends SymfonyApplication { - const NAME = 'sw-cli-tools'; - const VERSION = '@package_version@'; + public const NAME = 'sw-cli-tools'; + public const VERSION = '@package_version@'; /** - * @var \Composer\Autoload\ClassLoader + * @var ClassLoader */ private $loader; @@ -37,16 +38,13 @@ class Application extends \Symfony\Component\Console\Application */ private $container; - /** - * @param ClassLoader $loader - */ public function __construct(ClassLoader $loader) { $this->loader = $loader; parent::__construct(static::NAME, static::VERSION); - $this->container = DependencyInjection::createContainer(dirname(__DIR__)); + $this->container = DependencyInjection::createContainer(\dirname(__DIR__)); } /** @@ -70,10 +68,7 @@ public function doRun(InputInterface $input, OutputInterface $output) return parent::doRun($input, $output); } - /** - * @return ContainerInterface - */ - public function getContainer() + public function getContainer(): ContainerInterface { return $this->container; } @@ -81,7 +76,7 @@ public function getContainer() /** * Add global "--no-extensions" option * - * @return \Symfony\Component\Console\Input\InputDefinition + * @return InputDefinition */ protected function getDefaultInputDefinition() { @@ -95,13 +90,8 @@ protected function getDefaultInputDefinition() /** * Creates the container and sets some services which are only synthetic in the container - * - * @param InputInterface $input - * @param OutputInterface $output - * - * @return ContainerBuilder */ - protected function createContainer(InputInterface $input, OutputInterface $output) + protected function createContainer(InputInterface $input, OutputInterface $output): ContainerBuilder { $questionHelper = $this->getHelperSet()->get('question'); @@ -119,17 +109,18 @@ protected function createContainer(InputInterface $input, OutputInterface $outpu * * @throws \RuntimeException */ - protected function checkDirectories() + protected function checkDirectories(): void { - /** @var $pathProvider PathProvider */ + /** @var PathProvider $pathProvider */ $pathProvider = $this->container->get('path_provider'); - - foreach ([ + $paths = [ $pathProvider->getAssetsPath(), $pathProvider->getCachePath(), $pathProvider->getExtensionPath(), $pathProvider->getConfigPath(), - ] as $dir) { + ]; + + foreach ($paths as $dir) { if (is_dir($dir)) { continue; } @@ -148,7 +139,7 @@ protected function checkDirectories() * * @param bool $noExtensions */ - protected function loadExtensions($noExtensions) + protected function loadExtensions($noExtensions): void { $paths = [$this->container->get('path_provider')->getCliToolPath() . '/src/Extensions']; @@ -156,7 +147,10 @@ protected function loadExtensions($noExtensions) $paths[] = $this->container->get('path_provider')->getExtensionPath(); } - $this->container->get('extension_manager')->discoverExtensions($paths); - $this->container->get('extension_manager')->injectContainer($this->container); + /** @var ExtensionManager $extensionManager */ + $extensionManager = $this->container->get('extension_manager'); + + $extensionManager->discoverExtensions($paths); + $extensionManager->injectContainer($this->container); } } diff --git a/src/Application/CommandManager.php b/src/Application/CommandManager.php index 87664d52..036e51cf 100644 --- a/src/Application/CommandManager.php +++ b/src/Application/CommandManager.php @@ -15,9 +15,10 @@ class CommandManager { /** - * @var \Symfony\Component\DependencyInjection\ContainerBuilder + * @var ContainerBuilder */ private $container; + /** * @var ExtensionManager */ @@ -31,10 +32,8 @@ public function __construct(ExtensionManager $extensionManager, ContainerBuilder /** * Returns all commands - * - * @return array */ - public function getCommands() + public function getCommands(): array { $commands = array_merge( $this->getDefaultCommands(), @@ -52,10 +51,8 @@ public function getCommands() /** * Returns a flat array of all plugin's console commands - * - * @return array */ - public function collectPluginCommands() + public function collectPluginCommands(): array { $commands = []; @@ -70,10 +67,7 @@ public function collectPluginCommands() return $commands; } - /** - * @return array - */ - private function getDefaultCommands() + private function getDefaultCommands(): array { return [ new Command\CacheCommand(), diff --git a/src/Application/ContainerAwareExtension.php b/src/Application/ContainerAwareExtension.php index 325b9290..2e18fce6 100644 --- a/src/Application/ContainerAwareExtension.php +++ b/src/Application/ContainerAwareExtension.php @@ -12,8 +12,5 @@ interface ContainerAwareExtension { - /** - * @param ContainerBuilder $container - */ public function setContainer(ContainerBuilder $container); } diff --git a/src/Application/DependencyInjection.php b/src/Application/DependencyInjection.php index 466d0530..0186cb07 100644 --- a/src/Application/DependencyInjection.php +++ b/src/Application/DependencyInjection.php @@ -8,89 +8,104 @@ namespace ShopwareCli\Application; +use Composer\Autoload\ClassLoader; +use Shopware\PluginInfo\PluginInfo; +use ShopwareCli\Cache\File; +use ShopwareCli\Config; +use ShopwareCli\ConfigFileCollector; +use ShopwareCli\Services\GitIdentityEnvironment; +use ShopwareCli\Services\GitUtil; +use ShopwareCli\Services\IoService; +use ShopwareCli\Services\OpenSSLVerifier; +use ShopwareCli\Services\PathProvider\DirectoryGateway\XdgGateway; +use ShopwareCli\Services\PathProvider\PathProvider; +use ShopwareCli\Services\ProcessExecutor; +use ShopwareCli\Services\Rest\RestServiceFactory; +use ShopwareCli\Services\ShopwareInfo; +use ShopwareCli\Services\StreamFileDownloader; +use ShopwareCli\Utilities; +use Symfony\Component\Console\Helper\QuestionHelper; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; +use XdgBaseDir\Xdg; class DependencyInjection { - const DEFAULT_PROCESS_TIMEOUT = 180; - - /** - * @param $rootDir - * - * @return ContainerBuilder - */ - public static function createContainer($rootDir) + private const DEFAULT_PROCESS_TIMEOUT = 180; + + public static function createContainer($rootDir): ContainerBuilder { $container = new ContainerBuilder( new ParameterBag(['kernel.root_dir' => $rootDir]) ); // synthetic services - $container->setDefinition('autoloader', new Definition('Composer\Autoload\ClassLoader'))->setSynthetic(true); - $container->setDefinition('input_interface', new Definition('Symfony\Component\Console\Input\InputInterface'))->setSynthetic(true); - $container->setDefinition('output_interface', new Definition('Symfony\Component\Console\Input\InputInterface'))->setSynthetic(true); - $container->setDefinition('question_helper', new Definition('Symfony\Component\Console\Helper\QuestionHelper'))->setSynthetic(true); + $container->setDefinition('autoloader', new Definition(ClassLoader::class))->setSynthetic(true); + $container->setDefinition('input_interface', new Definition(InputInterface::class))->setSynthetic(true); + $container->setDefinition('output_interface', new Definition(OutputInterface::class))->setSynthetic(true); + $container->setDefinition('question_helper', new Definition(QuestionHelper::class))->setSynthetic(true); - $container->register('io_service', 'ShopwareCli\Services\IoService') + $container->register('io_service', IoService::class) ->addArgument(new Reference('input_interface')) ->addArgument(new Reference('output_interface')) ->addArgument(new Reference('question_helper')); - $container->register('process_executor', 'ShopwareCli\Services\ProcessExecutor') + $container->register('process_executor', ProcessExecutor::class) ->addArgument(new Reference('output_interface')) ->addArgument(getenv('SW_TIMEOUT') ?: self::DEFAULT_PROCESS_TIMEOUT); - $container->register('git_identity_environment', 'ShopwareCli\Services\GitIdentityEnvironment') + $container->register('git_identity_environment', GitIdentityEnvironment::class) ->addArgument(new Reference('path_provider')) ->addArgument(new Reference('config')); - $container->register('git_util', 'ShopwareCli\Services\GitUtil') + $container->register('git_util', GitUtil::class) ->addArgument(new Reference('output_interface')) ->addArgument(new Reference('git_identity_environment')) ->addArgument(getenv('SW_TIMEOUT') ?: self::DEFAULT_PROCESS_TIMEOUT); - $container->register('utilities', 'ShopwareCli\Utilities') + $container->register('utilities', Utilities::class) ->addArgument(new Reference('io_service')); - $container->register('xdg', '\XdgBaseDir\Xdg'); + $container->register('xdg', Xdg::class); - $container->register('plugin_info', '\Shopware\PluginInfo\PluginInfo'); + $container->register('plugin_info', PluginInfo::class); - $container->register('directory_gateway', 'ShopwareCli\Services\PathProvider\DirectoryGateway\XdgGateway') + $container->register('directory_gateway', XdgGateway::class) ->addArgument(new Reference('xdg')); - $container->register('file_downloader', 'ShopwareCli\Services\StreamFileDownloader') + $container->register('file_downloader', StreamFileDownloader::class) ->addArgument(new Reference('io_service')); - $container->register('path_provider', 'ShopwareCli\Services\PathProvider\PathProvider') + $container->register('path_provider', PathProvider::class) ->addArgument(new Reference('directory_gateway')); - $container->register('cache', 'ShopwareCli\Cache\File') + $container->register('cache', File::class) ->addArgument($container->get('path_provider')); - $container->register('rest_service_factory', 'ShopwareCli\Services\Rest\RestServiceFactory') + $container->register('rest_service_factory', RestServiceFactory::class) ->addArgument(new Reference('service_container')); - $container->register('config_file_collector', 'ShopwareCli\ConfigFileCollector') + $container->register('config_file_collector', ConfigFileCollector::class) ->addArgument(new Reference('path_provider')); - $container->register('config', 'ShopwareCli\Config') + $container->register('config', Config::class) ->addArgument(new Reference('config_file_collector')); - $container->register('extension_manager', 'ShopwareCli\Application\ExtensionManager') + $container->register('extension_manager', ExtensionManager::class) ->addArgument(new Reference('autoloader')); - $container->register('command_manager', 'ShopwareCli\Application\CommandManager') + $container->register('command_manager', CommandManager::class) ->addArgument(new Reference('extension_manager')) ->addArgument(new Reference('service_container')); - $container->register('openssl_verifier', 'ShopwareCli\Services\OpenSSLVerifier') + $container->register('openssl_verifier', OpenSSLVerifier::class) ->addArgument('%kernel.root_dir%/Resources/public.key'); - $container->register('shopware_info', 'ShopwareCli\Services\ShopwareInfo'); + $container->register('shopware_info', ShopwareInfo::class); return $container; } diff --git a/src/Application/ExtensionManager.php b/src/Application/ExtensionManager.php index 8956f0e8..a1fd089a 100644 --- a/src/Application/ExtensionManager.php +++ b/src/Application/ExtensionManager.php @@ -24,8 +24,6 @@ * * Also you can implement the interface RepositoryAwareExtension if you want to provide own repositories like * e.g. github - * - * Class ExtensionManager */ class ExtensionManager { @@ -39,9 +37,6 @@ class ExtensionManager */ private $autoLoader; - /** - * @param ClassLoader $autoLoader - */ public function __construct(ClassLoader $autoLoader) { $this->autoLoader = $autoLoader; @@ -50,15 +45,13 @@ public function __construct(ClassLoader $autoLoader) /** * Read all available plugins * - * @param $extensionDirs - * * @throws \RuntimeException */ - public function discoverExtensions($extensionDirs) + public function discoverExtensions($extensionDirs): void { // iterate all plugin dirs (e.g. ~/.config/sw-cli-tools/extensions and 'Extensions' in the sw-cli-tools directory /src/ foreach ($extensionDirs as $extensionDir) { - /** @var $vendorPath \DirectoryIterator */ + /** @var \DirectoryIterator $vendorPath */ foreach (new \DirectoryIterator($extensionDir) as $vendorPath) { if (!$this->isValidExtensionDir($vendorPath)) { continue; @@ -74,23 +67,17 @@ public function discoverExtensions($extensionDirs) /** * Instantiates a extension * - * @param $className - * * @return object */ public function bootstrapExtension($className) { - $extension = new $className(); - - return $extension; + return new $className(); } /** * Inject the di container into the extension - * - * @param ContainerBuilder $container */ - public function injectContainer(ContainerBuilder $container) + public function injectContainer(ContainerBuilder $container): void { foreach ($this->extensions as $extension) { if ($extension instanceof ContainerAwareExtension) { @@ -104,7 +91,7 @@ public function injectContainer(ContainerBuilder $container) * * @return object[] */ - public function getExtensions() + public function getExtensions(): array { return $this->extensions; } @@ -112,8 +99,6 @@ public function getExtensions() /** * Returns the plugin queried by name * - * @param $name - * * @return object */ public function getExtension($name) @@ -127,7 +112,7 @@ public function getExtension($name) * @param string $name * @param object $class */ - public function setExtension($name, $class) + public function setExtension($name, $class): void { $this->extensions[$name] = $class; } @@ -138,9 +123,9 @@ public function setExtension($name, $class) * * @throws \RuntimeException */ - private function discoverVendorFolder($vendorPath, $vendorName) + private function discoverVendorFolder($vendorPath, $vendorName): void { - /** @var $extensionPath \DirectoryIterator */ + /** @var \DirectoryIterator $extensionPath */ foreach (new \DirectoryIterator($vendorPath) as $extensionPath) { if (!$this->isValidExtensionDir($extensionPath) || $extensionPath->getBasename() === 'vendor') { continue; @@ -157,16 +142,11 @@ private function discoverVendorFolder($vendorPath, $vendorName) } } - /** - * @param \DirectoryIterator $vendorPath - * - * @return bool - */ - private function isValidExtensionDir(\DirectoryIterator $vendorPath) + private function isValidExtensionDir(\DirectoryIterator $vendorPath): bool { return $vendorPath->isDir() && !$vendorPath->isDot() - && stripos($vendorPath->getBasename(), '.') !== 0; // skip dot directories e.g. .git + && strpos($vendorPath->getBasename(), '.') !== 0; // skip dot directories e.g. .git } /** @@ -175,7 +155,7 @@ private function isValidExtensionDir(\DirectoryIterator $vendorPath) * @param string $path * @param string $namespace */ - private function registerExtensionNamespace($path, $namespace) + private function registerExtensionNamespace($path, $namespace): void { $namespace = rtrim($namespace, '\\') . '\\'; $this->autoLoader->addPsr4($namespace, $path); diff --git a/src/Cache/CacheInterface.php b/src/Cache/CacheInterface.php index 3a11922a..61ab2df4 100644 --- a/src/Cache/CacheInterface.php +++ b/src/Cache/CacheInterface.php @@ -14,10 +14,8 @@ interface CacheInterface * @param string $key * @param string $data * @param int $valid - * - * @return bool */ - public function write($key, $data, $valid); + public function write($key, $data, $valid): bool; /** * @param string $key @@ -26,16 +24,11 @@ public function write($key, $data, $valid); */ public function read($key); - public function delete($key); + public function delete($key): void; - /** - * @param $key - * - * @return bool - */ - public function exists($key); + public function exists($key): bool; - public function clear(); + public function clear(): void; - public function getKeys(); + public function getKeys(): array; } diff --git a/src/Cache/File.php b/src/Cache/File.php index 41332a42..6b112f69 100644 --- a/src/Cache/File.php +++ b/src/Cache/File.php @@ -12,28 +12,30 @@ class File implements CacheInterface { + /** + * @var string + */ protected $path; - protected $info; + /** - * @var \ShopwareCli\Services\PathProvider\PathProvider + * @var array|string|bool|null */ - private $pathProvider; + protected $info; public function __construct(PathProvider $pathProvider) { - $this->pathProvider = $pathProvider; $this->path = $pathProvider->getCachePath() . DIRECTORY_SEPARATOR; $this->info = $this->readTable(); } - public function write($key, $data, $valid) + public function write($key, $data, $valid): bool { $file = $this->path . $key; $success = file_put_contents($file, $data); $this->info[$key] = ['valid' => $valid]; - $this->writeTable($key, $valid); + $this->writeTable(); return $success !== false; } @@ -49,7 +51,7 @@ public function read($key) return false; } - public function delete($key) + public function delete($key): void { unlink($this->path . $key); $this->writeTable(); @@ -57,10 +59,8 @@ public function delete($key) /** * @param string $key - * - * @return bool */ - public function exists($key) + public function exists($key): bool { $file = $this->path . $key; @@ -73,7 +73,7 @@ public function exists($key) return time() - filectime($file) < $validTime; } - public function clear() + public function clear(): void { foreach ($this->getKeys() as $key) { unlink($this->path . $key); @@ -82,12 +82,12 @@ public function clear() $this->writeTable(); } - public function getKeys() + public function getKeys(): array { return array_keys($this->info); } - private function getInfoFile() + private function getInfoFile(): string { return $this->path . 'info.json'; } @@ -110,7 +110,7 @@ private function readTable() return $content; } - private function writeTable() + private function writeTable(): void { $file = $this->getInfoFile(); diff --git a/src/Command/BaseCommand.php b/src/Command/BaseCommand.php index 7be2d69f..fbb69acc 100644 --- a/src/Command/BaseCommand.php +++ b/src/Command/BaseCommand.php @@ -14,12 +14,12 @@ /** * The BaseCommand takes care of the container - * - * Class BaseCommand */ abstract class BaseCommand extends Command implements ContainerAwareInterface { - /** @var ContainerInterface */ + /** + * @var ContainerInterface + */ protected $container; /** @@ -29,7 +29,7 @@ abstract class BaseCommand extends Command implements ContainerAwareInterface * * @api */ - public function setContainer(ContainerInterface $container = null) + public function setContainer(ContainerInterface $container = null): void { $this->container = $container; } diff --git a/src/Command/CacheCommand.php b/src/Command/CacheCommand.php index acc862d4..9417085a 100644 --- a/src/Command/CacheCommand.php +++ b/src/Command/CacheCommand.php @@ -13,22 +13,23 @@ /** * Clear the *internal* cache of the CLI tools (used for e.g. plugin repos) - * - * Class CacheCommand */ class CacheCommand extends BaseCommand { protected $utilities; + protected $zipDir; - protected function configure() + protected function configure(): void { $this->setName('cli:cache:clear') ->setDescription('Clear the repository cache'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->container->get('cache')->clear(); + + return 0; } } diff --git a/src/Command/CacheGetCommand.php b/src/Command/CacheGetCommand.php index fb2f14a5..7debc648 100644 --- a/src/Command/CacheGetCommand.php +++ b/src/Command/CacheGetCommand.php @@ -14,15 +14,14 @@ /** * Read the internal CLI cache. Used for e.g. plugin repos - * - * Class CacheGetCommand */ class CacheGetCommand extends BaseCommand { protected $utilities; + protected $zipDir; - protected function configure() + protected function configure(): void { $this->setName('cli:cache:get') ->setDescription('Read the cache') @@ -33,7 +32,7 @@ protected function configure() ); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $keys = $input->getArgument('keys'); @@ -42,12 +41,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln($key); } - return; + return 0; } foreach ($keys as $key) { $output->writeln("{$key}"); $output->writeln($this->container->get('cache')->read($key)); } + + return 0; } } diff --git a/src/Config.php b/src/Config.php index 35d9075f..cff0237e 100644 --- a/src/Config.php +++ b/src/Config.php @@ -12,8 +12,6 @@ /** * Simple config object for the config.yaml file - * - * Class Config */ class Config implements \ArrayAccess { @@ -22,14 +20,14 @@ class Config implements \ArrayAccess */ protected $configArray; - /** - * @param ConfigFileCollector $fileCollector - */ public function __construct(ConfigFileCollector $fileCollector) { $config = []; foreach ($fileCollector->collectConfigFiles() as $configFile) { - $config = array_replace_recursive($config, Yaml::parse(file_get_contents($configFile), true)); + $config = array_replace_recursive( + $config, + Yaml::parse(file_get_contents($configFile), Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE) + ); } $this->configArray = $config; @@ -37,17 +35,12 @@ public function __construct(ConfigFileCollector $fileCollector) $this->validateConfig(); } - /** - * @return mixed - */ - public function getRepositories() + public function getRepositories(): array { return (array) $this->configArray['repositories']; } /** - * @param $offset - * * @return bool */ public function offsetExists($offset) @@ -56,37 +49,24 @@ public function offsetExists($offset) } /** - * @param $offset - * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - if (array_key_exists($offset, $this->configArray)) { - return $this->configArray[$offset]; - } - - return null; + return $this->configArray[$offset] ?? null; } - /** - * @param $offset - * @param $value - */ public function offsetSet($offset, $value) { $this->configArray[$offset] = $value; } - /** - * @param $offset - */ public function offsetUnset($offset) { unset($this->configArray[$offset]); } - private function validateConfig() + private function validateConfig(): void { if (isset($this->configArray['ShopwareInstallConfig'])) { throw new \RuntimeException("The config format changed, 'ShopwareInstallConfig' is not used anymore. Its former options are now distinct options 'ShopConfig', 'DatabaseConfig' and 'ShopwareInstallRepos'. Have a look at config.yaml.dist for more info."); diff --git a/src/ConfigFileCollector.php b/src/ConfigFileCollector.php index d9bba517..a3f5f8b7 100644 --- a/src/ConfigFileCollector.php +++ b/src/ConfigFileCollector.php @@ -17,9 +17,6 @@ class ConfigFileCollector */ private $pathProvider; - /** - * @param PathProvider $pathProvider - */ public function __construct(PathProvider $pathProvider) { $this->pathProvider = $pathProvider; @@ -55,7 +52,7 @@ public function collectConfigFiles() * * @return string[] */ - private function iterateVendors($extensionPath) + private function iterateVendors($extensionPath): array { $files = []; @@ -84,7 +81,7 @@ private function iterateVendors($extensionPath) * * @return string[] */ - private function iterateExtensions($vendorPath) + private function iterateExtensions($vendorPath): array { $files = []; diff --git a/src/DirectoryFilterIterator.php b/src/DirectoryFilterIterator.php index 857f6b43..3c98bb6b 100644 --- a/src/DirectoryFilterIterator.php +++ b/src/DirectoryFilterIterator.php @@ -18,17 +18,11 @@ public function accept() return $this->isValidDir($this->current()); } - /** - * @param \DirectoryIterator $fileInfo - * - * @return bool - */ - private function isValidDir(\DirectoryIterator $fileInfo) + private function isValidDir(\DirectoryIterator $fileInfo): bool { - return - $fileInfo->isDir() && - !$fileInfo->isDot() && + return $fileInfo->isDir() + && !$fileInfo->isDot() // skip dot directories e.g. .git - stripos($fileInfo->getBasename(), '.') !== 0; + && strpos($fileInfo->getBasename(), '.') !== 0; } } diff --git a/src/Extensions/Shopware/AutoUpdate/Bootstrap.php b/src/Extensions/Shopware/AutoUpdate/Bootstrap.php index 05c46561..73ad8f13 100644 --- a/src/Extensions/Shopware/AutoUpdate/Bootstrap.php +++ b/src/Extensions/Shopware/AutoUpdate/Bootstrap.php @@ -17,8 +17,6 @@ /** * Provides self update capability - * - * Class Bootstrap */ class Bootstrap implements ConsoleAwareExtension, ContainerAwareExtension { @@ -60,10 +58,8 @@ public function getConsoleCommands() /** * Checks if script is run as phar archive and manifestUrl is available - * - * @return bool */ - public function isPharFile() + public function isPharFile(): bool { $toolPath = $this->container->get('path_provider')->getCliToolPath(); @@ -78,19 +74,21 @@ private function populateContainer($container) $container->set('updater', $this->createUpdater()); } - /** - * @return Updater - */ - private function createUpdater() + private function createUpdater(): Updater { $config = $this->container->get('config'); - $pharUrl = $config['update']['pharUrl']; - $versionUrl = $config['update']['vesionUrl']; - $verifyKey = (bool) $config['update']['verifyPublicKey']; + $updateConfig = $config['update']; + $pharUrl = $updateConfig['pharUrl']; + $versionUrl = $updateConfig['vesionUrl']; + if ($versionUrl === null) { + $versionUrl = $updateConfig['versionUrl']; + } + $verifyKey = (bool) $updateConfig['verifyPublicKey']; $updater = new Updater(null, $verifyKey); - $updater->getStrategy()->setPharUrl($pharUrl); - $updater->getStrategy()->setVersionUrl($versionUrl); + $strategy = $updater->getStrategy(); + $strategy->setPharUrl($pharUrl); + $strategy->setVersionUrl($versionUrl); return $updater; } @@ -112,7 +110,9 @@ private function runUpdate() $old = $updater->getOldVersion(); exit(sprintf( - "Updated from SHA-1 %s to SHA-1 %s. Please run again\n", $old, $new + "Updated from SHA-1 %s to SHA-1 %s. Please run again\n", + $old, + $new )); } catch (\Exception $e) { echo "\nCheck your connection\n"; @@ -120,10 +120,7 @@ private function runUpdate() } } - /** - * @return bool - */ - private function checkUpdateOnRun() + private function checkUpdateOnRun(): bool { $config = $this->container->get('config'); if (!isset($config['update']['checkOnStartup'])) { diff --git a/src/Extensions/Shopware/AutoUpdate/Command/SelfUpdateCommand.php b/src/Extensions/Shopware/AutoUpdate/Command/SelfUpdateCommand.php index 94c1b5dc..47468ed8 100644 --- a/src/Extensions/Shopware/AutoUpdate/Command/SelfUpdateCommand.php +++ b/src/Extensions/Shopware/AutoUpdate/Command/SelfUpdateCommand.php @@ -51,7 +51,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $old = $this->updater->getOldVersion(); $output->writeln(sprintf( - 'Updated from SHA-1 %s to SHA-1 %s. Please run again', $old, $new + 'Updated from SHA-1 %s to SHA-1 %s. Please run again', + $old, + $new )); return 0; @@ -63,11 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - /** - * @param OutputInterface $output - * @param \Exception $exception - */ - protected function printException(OutputInterface $output, \Exception $exception) + protected function printException(OutputInterface $output, \Exception $exception): void { do { $output->writeln(sprintf('(%d) %s in %s:%d:', $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine())); diff --git a/src/Extensions/Shopware/DataGenerator/Bootstrap.php b/src/Extensions/Shopware/DataGenerator/Bootstrap.php index ae740584..98e1cc05 100644 --- a/src/Extensions/Shopware/DataGenerator/Bootstrap.php +++ b/src/Extensions/Shopware/DataGenerator/Bootstrap.php @@ -8,6 +8,8 @@ namespace Shopware\DataGenerator; +use Shopware\DataGenerator\Struct\Config; +use Shopware\DataGenerator\Writer\WriterManager; use ShopwareCli\Application\ConsoleAwareExtension; use ShopwareCli\Application\ContainerAwareExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -21,27 +23,25 @@ public function setContainer(ContainerBuilder $container) { $this->container = $container; - $this->container->register('random_data_provider', '\Shopware\DataGenerator\RandomDataProvider'); + $this->container->register('random_data_provider', RandomDataProvider::class); - $this->container->register('generator_config', '\Shopware\DataGenerator\Struct\Config'); + $this->container->register('generator_config', Config::class); - $this->container->register('resource_loader', '\Shopware\DataGenerator\ResourceLoader') + $this->container->register('resource_loader', ResourceLoader::class) ->addArgument(new Reference('service_container')); - $this->container->register('data_generator', '\Shopware\DataGenerator\DataGenerator') + $this->container->register('data_generator', DataGenerator::class) ->addArgument(new Reference('random_data_provider')) ->addArgument(new Reference('resource_loader')) ->addArgument(new Reference('generator_config')); - $this->container->register('writer_manager', '\Shopware\DataGenerator\Writer\WriterManager') + $this->container->register('writer_manager', WriterManager::class) ->addArgument(new Reference('generator_config')) ->addArgument(new Reference('io_service')); } /** * Return an array with instances of your console commands here - * - * @return mixed */ public function getConsoleCommands() { diff --git a/src/Extensions/Shopware/DataGenerator/Command/CreateDataCommand.php b/src/Extensions/Shopware/DataGenerator/Command/CreateDataCommand.php index 64f443b1..f956d202 100644 --- a/src/Extensions/Shopware/DataGenerator/Command/CreateDataCommand.php +++ b/src/Extensions/Shopware/DataGenerator/Command/CreateDataCommand.php @@ -18,12 +18,9 @@ class CreateDataCommand extends BaseCommand { protected $utilities; + protected $zipDir; - /** - * @param InputInterface $input - * @param OutputInterface $output - */ public function interact(InputInterface $input, OutputInterface $output) { $articles = $input->getOption('articles'); @@ -45,23 +42,19 @@ public function interact(InputInterface $input, OutputInterface $output) $this->askConfigOptions($input, 'categoriesPerArticle', 'Categories per article', 3); $this->askConfigOptions($input, 'articleMinVariants', 'Minimum variants per article', 1); $this->askConfigOptions($input, 'articleMaxVariants', 'Maximum variants per article', 20); - $this->askConfigOptions($input, 'articleFilterGroups', 'Filter groups', 0); - $this->askConfigOptions($input, 'articleFilterOptions', 'Filter Options', 0); - $this->askConfigOptions($input, 'articleFilterValues', 'Filter Values', 0); - $this->askConfigOptions($input, 'orders', 'Orders', 0); - $this->askConfigOptions($input, 'newsletter', 'Newsletters', 0); + $this->askConfigOptions($input, 'articleFilterGroups', 'Filter groups'); + $this->askConfigOptions($input, 'articleFilterOptions', 'Filter Options'); + $this->askConfigOptions($input, 'articleFilterValues', 'Filter Values'); + $this->askConfigOptions($input, 'orders', 'Orders'); + $this->askConfigOptions($input, 'newsletter', 'Newsletters'); $this->askConfigOptions($input, 'customers', 'Customers', 1000); - $this->askConfigOptions($input, 'vouchers', 'Vouchers', 0); + $this->askConfigOptions($input, 'vouchers', 'Vouchers'); } /** - * @param $input - * * @throws \RuntimeException - * - * @return int */ - public function validateInt($input) + public function validateInt($input): int { if (empty($input)) { return 0; @@ -232,7 +225,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $writerManager = $this->container->get('writer_manager'); if (is_readable($shopwarePath . '/config.php')) { $shopwareConfig = require $shopwarePath . '/config.php'; - if (!array_key_exists('db', $shopwareConfig)) { + if (!\array_key_exists('db', $shopwareConfig)) { $output->writeln('Invalid Shopware configuration file.'); return; @@ -273,23 +266,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - /** - * @param $seed - * @param $articles - * @param $orders - * @param $categories - * @param $categoriesPerArticle - * @param $customers - * @param $newsletter - * @param $vouchers - * @param $articleFilterGroups - * @param $articleFilterOptions - * @param $articleFilterValues - * @param $chunkSize - * @param $minVariants - * @param $maxVariants - * @param $generatorLocale - */ protected function configureGenerator( $seed, $articles, @@ -306,7 +282,7 @@ protected function configureGenerator( $minVariants, $maxVariants, $generatorLocale - ) { + ): void { // Check some pre-conditions if ($articles > 0 && !$categories) { throw new \UnexpectedValueException('Articles require categories'); @@ -343,12 +319,11 @@ protected function configureGenerator( } /** - * @param InputInterface $input - * @param string $optionName - * @param string|null $optionHumanName - * @param int $default + * @param string $optionName + * @param string|null $optionHumanName + * @param int $default */ - private function askConfigOptions(InputInterface $input, $optionName, $optionHumanName = null, $default = 0) + private function askConfigOptions(InputInterface $input, $optionName, $optionHumanName = null, $default = 0): void { $ioService = $this->container->get('io_service'); diff --git a/src/Extensions/Shopware/DataGenerator/DataGenerator.php b/src/Extensions/Shopware/DataGenerator/DataGenerator.php index 7c8426cf..fbf7b1e7 100644 --- a/src/Extensions/Shopware/DataGenerator/DataGenerator.php +++ b/src/Extensions/Shopware/DataGenerator/DataGenerator.php @@ -21,6 +21,7 @@ class DataGenerator * @var RandomDataProvider */ public $generator; + /** * Type of demo data to create * @@ -38,11 +39,6 @@ class DataGenerator */ private $config; - /** - * @param RandomDataProvider $generator - * @param ResourceLoader $resourceLoader - * @param Config $config - */ public function __construct( RandomDataProvider $generator, ResourceLoader $resourceLoader, @@ -58,7 +54,7 @@ public function __construct( * * For performance and memory reasons, different methods for data creation are provided */ - public function run() + public function run(): void { $locale = $this->config->getGeneratorLocale(); if (!empty($locale)) { @@ -76,17 +72,15 @@ public function run() /** * @param string $type */ - public function setType($type) + public function setType($type): void { $this->type = $type; } /** * Init the random number generator with a specific seed. - * - * @param $seed */ - protected function initSeed($seed) + protected function initSeed($seed): void { if (!empty($seed)) { mt_srand($this->config->getSeed()); diff --git a/src/Extensions/Shopware/DataGenerator/RandomDataProvider.php b/src/Extensions/Shopware/DataGenerator/RandomDataProvider.php index 4b651756..5f5ae166 100644 --- a/src/Extensions/Shopware/DataGenerator/RandomDataProvider.php +++ b/src/Extensions/Shopware/DataGenerator/RandomDataProvider.php @@ -28,7 +28,7 @@ public function __construct() /** * @param string|null $locale */ - public function setProviderLocale($locale) + public function setProviderLocale($locale): void { if ($locale === null) { $this->faker = Factory::create(); @@ -37,52 +37,35 @@ public function setProviderLocale($locale) } } - /** - * @return string - */ - public function getRandomCity() + public function getRandomCity(): string { return $this->faker->city; } - /** - * @return string - */ - public function getRandomFirstName() + public function getRandomFirstName(): string { return $this->faker->firstName; } - /** - * @return string - */ - public function getRandomLastName() + public function getRandomLastName(): string { return $this->faker->lastName; } - /** - * @return string - */ - public function getRandomWord() + public function getRandomWord(): string { return $this->faker->word; } /** * @param int $wordCount - * - * @return string */ - public function getSentence($wordCount) + public function getSentence($wordCount): string { return $this->faker->sentence(max($wordCount, 1)); } - /** - * @return string - */ - public function getRandomIpv4() + public function getRandomIpv4(): string { return $this->faker->ipv4; } diff --git a/src/Extensions/Shopware/DataGenerator/ResourceLoader.php b/src/Extensions/Shopware/DataGenerator/ResourceLoader.php index c3748252..223555fa 100644 --- a/src/Extensions/Shopware/DataGenerator/ResourceLoader.php +++ b/src/Extensions/Shopware/DataGenerator/ResourceLoader.php @@ -17,8 +17,9 @@ class ResourceLoader * @var BaseResource[] */ private $resources; + /** - * @var \Symfony\Component\DependencyInjection\Container + * @var Container */ private $container; @@ -27,12 +28,7 @@ public function __construct(Container $container) $this->container = $container; } - /** - * @param $type - * - * @return BaseResource - */ - public function getResource($type) + public function getResource($type): BaseResource { if (!isset($this->resources[$type])) { $className = 'Shopware\DataGenerator\Resources\\' . ucfirst($type); diff --git a/src/Extensions/Shopware/DataGenerator/Resources/Articles.php b/src/Extensions/Shopware/DataGenerator/Resources/Articles.php index 51d0dca5..e28245e6 100644 --- a/src/Extensions/Shopware/DataGenerator/Resources/Articles.php +++ b/src/Extensions/Shopware/DataGenerator/Resources/Articles.php @@ -13,8 +13,8 @@ class Articles extends BaseResource { - const GROUPS = 500; - const OPTIONS = 10; + private const GROUPS = 500; + private const OPTIONS = 10; /** * @var array @@ -59,24 +59,26 @@ class Articles extends BaseResource protected $configuratorsGroups = []; - /** - * @return \SplFixedArray - */ - public function getArticleDetailsFlat() + public function getArticleDetailsFlat(): \SplFixedArray { return $this->articleDetailsFlat; } - public function createConfiguratorOptions() + public function createConfiguratorOptions(): void { for ($group = 0; $group <= self::GROUPS; ++$group) { - $currentGroup = ['id' => $this->getUniqueId( - 'conf_group' - ), 'name' => 'Configurator Group ' . $group, 'position' => $group, $options = []]; + $currentGroup = [ + 'id' => $this->getUniqueId('conf_group'), + 'name' => 'Configurator Group ' . $group, + 'position' => $group, + 'options' => [], + ]; for ($option = 0; $option <= self::OPTIONS; ++$option) { - $currentGroup['options'][] = ['id' => $this->getUniqueId( - 'conf_option' - ), 'name' => 'Option' . $option, 'position' => $option]; + $currentGroup['options'][] = [ + 'id' => $this->getUniqueId('conf_option'), + 'name' => 'Option' . $option, + 'position' => $option, + ]; } $this->configuratorsGroups[] = $currentGroup; } @@ -129,12 +131,12 @@ public function create(WriterInterface $writer) $categoriesFlat = $this->categoryResource->categoriesFlat; $validCategoryIds = array_filter( array_keys($categoriesFlat), - function ($item) { + static function ($item) { return $item >= 1000000; } ); - $categoriesPerArticle = min(count($validCategoryIds), $this->config->getCategoriesPerArticle()); - if (count($validCategoryIds) < $this->config->getCategoriesPerArticle()) { + $categoriesPerArticle = min(\count($validCategoryIds), $this->config->getCategoriesPerArticle()); + if (\count($validCategoryIds) < $this->config->getCategoriesPerArticle()) { $this->ioService->writeln( 'Number of categories per article will be lower than specified' ); @@ -163,18 +165,18 @@ function ($item) { for ($articleCounter = 0; $articleCounter < $number; ++$articleCounter) { $this->advanceProgressBar(); $id = $this->getUniqueId('article'); - $createConfigurator = $id === 1 ? 1 : rand(0, 1); // Force the first article to be a configurator - // number of variants is choosen randomly - $numberOfVariants = $createConfigurator === 1 ? rand( + $createConfigurator = $id === 1 ? 1 : random_int(0, 1); // Force the first article to be a configurator + // number of variants is chosen randomly + $numberOfVariants = $createConfigurator === 1 ? random_int( $this->config->getMinVariants(), $this->config->getMaxVariants() ) : 1; - if ($numberOfVariants == 1) { + if ($numberOfVariants === 1) { $createConfigurator = 0; } - $createFilter = rand(0, 3); + $createFilter = random_int(0, 3); $urls->write("/detail/index/sArticle/{$id}"); @@ -200,8 +202,8 @@ function ($item) { $options = []; $configuratorSets->write("{$id}, Test-Configurator-Set Article {$id}"); $randomGroups = array_rand($this->configuratorsGroups, $numberOfGroups); - // array_rand will not return an array if only one element was choosen - if (!is_array($randomGroups)) { + // array_rand will not return an array if only one element was chosen + if (!\is_array($randomGroups)) { $randomGroups = [$randomGroups]; } @@ -251,8 +253,7 @@ function ($item) { // Images for ($i = 1; $i <= $numImagesPerArticle; ++$i) { $mediaId = $this->getUniqueId('media'); - $name = $physicallyCreateEachImage ? $baseName . $id : $baseName; - $images[] = $name; + $images[] = $physicallyCreateEachImage ? $baseName . $id : $baseName; $mediaValues[] = "({$mediaId}, -1, {$name}, media/image/{$name}.jpg, IMAGE, jpg, 2012-08-15 )"; $main = ($i === 1) ? 1 : 2; $articlesImgValues[] = "({$id},{$name}, {$main}, jpg, {$mediaId} )"; @@ -265,10 +266,10 @@ function ($item) { // Filters $filterGroupId = 1; if ($createFilter === 0) { - $filterGroupId = rand(1, $filterOptions); + $filterGroupId = random_int(1, $filterOptions); for ($option = 1; $option <= $filterOptions; ++$option) { $optionId = $option * $filterGroupId; - $valueId = rand(1, $filterValues) * $optionId; + $valueId = random_int(1, $filterValues) * $optionId; $filterArticles->write("{$id}, {$valueId}"); } } @@ -288,17 +289,15 @@ function ($item) { } $kind = $i === 1 ? 1 : 2; - $purchaseUnit = rand(0, 5); - $referenceUnit = rand($purchaseUnit, $purchaseUnit * 4); + $purchaseUnit = random_int(0, 5); + $referenceUnit = random_int($purchaseUnit, $purchaseUnit * 4); $details->write( "{$articleDetailId}, {$id},sw-{$id}-{$i}, , {$kind}, , 0, 1, 25, 0, 0.000, 0, NULL, NULL, NULL, NULL, 1, NULL, NULL, 1, {$purchaseUnit}, {$referenceUnit}, Flasche(n), 2012-06-13, 0, " ); - $index = rand(0, count($priceVariations) - 1); - $variantPrices = $priceVariations[$index]; - - foreach ($variantPrices as $price) { + $index = random_int(0, \count($priceVariations) - 1); + foreach ($priceVariations[$index] as $price) { $prices->write( "EK,{$price['from']},{$price['to']},{$id},{$articleDetailId},{$price['price']}, 0, 0, 0 " ); @@ -330,8 +329,8 @@ function ($item) { $this->copyImages( $this->config->getImageDir(), $images, - $thumbs = $this->config->getThumbnailSizes(), - $useSmallImage = 1 + $this->config->getThumbnailSizes(), + 1 ); } @@ -379,28 +378,20 @@ function ($item) { $this->finishProgressBar(); } - /** - * @return Categories - */ - public function getCategoryResource() + public function getCategoryResource(): Categories { return $this->categoryResource; } - /** - * @param Categories $categoryResource - */ - public function setCategoryResource(Categories $categoryResource) + public function setCategoryResource(Categories $categoryResource): void { $this->categoryResource = $categoryResource; } /** * Generates SQL which creates filter groups, options and values. - * - * @param WriterInterface $importWriter */ - protected function createFilterGroupSQL(WriterInterface $importWriter) + protected function createFilterGroupSQL(WriterInterface $importWriter): void { $filterGroupValues = []; $filterOptionValues = []; @@ -412,11 +403,11 @@ protected function createFilterGroupSQL(WriterInterface $importWriter) $filterValues = $this->config->getArticleFilterValues(); for ($groupId = 1; $groupId <= $filterGroups; ++$groupId) { - $filterGroupValues[] = "$groupId, Filtergroup #{$groupId}, {$groupId}, " . rand(0, 1) . ', ' . rand(0, 1); + $filterGroupValues[] = "$groupId, Filtergroup #{$groupId}, {$groupId}, " . random_int(0, 1) . ', ' . random_int(0, 1); for ($o = 1; $o <= $filterOptions; ++$o) { $optionId = $o + ($groupId - 1) * $filterOptions; - $filterOptionValues[] = "$optionId, Option #{$o}, " . rand(0, 1); + $filterOptionValues[] = "$optionId, Option #{$o}, " . random_int(0, 1); $filterOptionGroupRelationValues[] = "$groupId, $optionId, $o"; for ($v = 1; $v <= $filterValues; ++$v) { @@ -444,24 +435,18 @@ protected function createFilterGroupSQL(WriterInterface $importWriter) /** * Helper function which creates a cartesian product. - * - * @param $arrays - * - * @return array */ - private function createCartesianProduct($arrays) + private function createCartesianProduct($arrays): array { $cartesian = []; - $dims = array_reverse($arrays); - - foreach ($dims as $dimName => $dim) { + foreach (array_reverse($arrays) as $dimName => $dim) { $buf = []; foreach ($dim as $val) { $buf[] = [$dimName => $val]; } - if (!count($cartesian)) { + if (!\count($cartesian)) { $cartesian = $buf; } else { $tmp = []; @@ -477,13 +462,7 @@ private function createCartesianProduct($arrays) return $cartesian; } - /** - * @param $id - * @param $categories - * - * @return array - */ - private function getCategoryPath($id, $categories) + private function getCategoryPath($id, $categories): array { if (!$id) { return []; @@ -508,12 +487,9 @@ private function getCategoryPath($id, $categories) /** * Copies the default image for each article. * - * @param $imageDir - * @param $images - * @param $thumbs * @param int $useSmallImage */ - private function copyImages($imageDir, $images, $thumbs, $useSmallImage) + private function copyImages($imageDir, $images, $thumbs, $useSmallImage): void { $assetsDir = ''; //TODO: implement real asset loading // Copy the images to media directory @@ -532,7 +508,7 @@ private function copyImages($imageDir, $images, $thumbs, $useSmallImage) /** * @param int $number */ - private function generatePriceVariations($number) + private function generatePriceVariations($number): array { $count = $number / 5; @@ -540,18 +516,18 @@ private function generatePriceVariations($number) for ($v = 0; $v <= $count; ++$v) { // create random number of bulk prices between 1 and 5 - $priceCount = rand(1, 5); + $priceCount = random_int(1, 5); $to = 0; // price will be something between 3 and 2000 - $price = rand(3, 2000); + $price = random_int(3, 2000); for ($i = 1; $i <= $priceCount; ++$i) { $from = $to + 1; - $to = $from + rand(2, 4); + $to = $from + random_int(2, 4); if ($i == $priceCount) { $to = 'beliebig'; } - $price = $price * ((100 - rand(10, 40))) / 100; + $price = $price * ((100 - random_int(10, 40))) / 100; $variations[$v][] = [ 'from' => $from, diff --git a/src/Extensions/Shopware/DataGenerator/Resources/BaseResource.php b/src/Extensions/Shopware/DataGenerator/Resources/BaseResource.php index 0c49e49a..53555c22 100644 --- a/src/Extensions/Shopware/DataGenerator/Resources/BaseResource.php +++ b/src/Extensions/Shopware/DataGenerator/Resources/BaseResource.php @@ -8,6 +8,7 @@ namespace Shopware\DataGenerator\Resources; +use Shopware\DataGenerator\DataGenerator; use Shopware\DataGenerator\RandomDataProvider; use Shopware\DataGenerator\Struct\Config; use Shopware\DataGenerator\Writer\WriterInterface; @@ -35,12 +36,12 @@ abstract class BaseResource protected $config; /** - * @var \Plugin\ShopwarePluginCreator\DataGenerator + * @var DataGenerator */ protected $generator; /** - * @var \ShopwareCli\Services\IoService + * @var IoService */ protected $ioService; @@ -54,12 +55,6 @@ abstract class BaseResource */ protected $progressBar; - /** - * @param Config $config - * @param RandomDataProvider $generator - * @param IoService $ioService - * @param WriterManager $writerManager - */ public function __construct( Config $config, RandomDataProvider $generator, @@ -75,7 +70,7 @@ public function __construct( /** * @param string $field * - * @return int + * @return int|array */ public function getIds($field = null) { @@ -91,10 +86,6 @@ public function getIds($field = null) * provided writer * May create additional writers using the existing WriterManager * All writers are automatically flushed once the data creation ends. - * - * @param WriterInterface $writer - * - * @return mixed */ abstract public function create(WriterInterface $writer); @@ -104,9 +95,9 @@ abstract public function create(WriterInterface $writer); * Flushes data at the end * Handles pre and pos query handling (truncating, enable/disable foreign keys). */ - final public function generateData() + final public function generateData(): void { - $path = explode('\\', get_class($this)); + $path = explode('\\', \get_class($this)); $writer = $this->writerManager->createWriter(strtolower(array_pop($path)), 'sql'); $writer->write($this->prepareTables()); @@ -133,7 +124,7 @@ protected function getUniqueId($type) return 1; } - $this->ids[$type] += 1; + ++$this->ids[$type]; return $this->ids[$type]; } @@ -141,7 +132,7 @@ protected function getUniqueId($type) /** * Generic setup method which will truncate tables of a resource and disables keys for that table temporarily. */ - protected function prepareTables() + protected function prepareTables(): array { $sql = [ 'SET autocommit = 0;', @@ -164,7 +155,7 @@ protected function prepareTables() * * @return string[] */ - protected function enableKeys() + protected function enableKeys(): array { $sql = []; @@ -180,7 +171,7 @@ protected function enableKeys() /** * @param int $number */ - protected function createProgressBar($number) + protected function createProgressBar($number): void { $this->progressBar = $this->ioService->createProgressBar($number); $this->progressBar->start(); @@ -190,7 +181,7 @@ protected function createProgressBar($number) /** * @param int $step */ - protected function advanceProgressBar($step = 1) + protected function advanceProgressBar($step = 1): void { if (!$this->progressBar) { return; @@ -199,7 +190,7 @@ protected function advanceProgressBar($step = 1) $this->progressBar->advance($step); } - protected function finishProgressBar() + protected function finishProgressBar(): void { if (!$this->progressBar) { return; diff --git a/src/Extensions/Shopware/DataGenerator/Resources/Categories.php b/src/Extensions/Shopware/DataGenerator/Resources/Categories.php index 276c69ca..c1dec5fd 100644 --- a/src/Extensions/Shopware/DataGenerator/Resources/Categories.php +++ b/src/Extensions/Shopware/DataGenerator/Resources/Categories.php @@ -18,6 +18,7 @@ class Categories extends BaseResource * @var */ public $categoriesFlat = []; + /** * @var array */ @@ -50,7 +51,7 @@ public function getUniqueId($type) return 1; } - $this->ids[$type] += 1; + ++$this->ids[$type]; return $this->ids[$type]; } @@ -113,12 +114,10 @@ public function create(WriterInterface $writer) * @param int|null $parentCategory * @param int $depth * @param array|null $leftNeighbour - * - * @return array */ - private function buildNestedTree($number, $parentCategory = null, $depth = 0, $leftNeighbour = null) + private function buildNestedTree($number, $parentCategory = null, $depth = 0, $leftNeighbour = null): array { - $categoriesOnThisLevel = ($depth === 0) ? 6 : rand(2, 10); + $categoriesOnThisLevel = ($depth === 0) ? 6 : random_int(2, 10); $categoriesPerChild = round($number / $categoriesOnThisLevel); // Due to round and random calculation of subcategories @@ -196,12 +195,8 @@ private function buildNestedTree($number, $parentCategory = null, $depth = 0, $l /** * Builds path for the given category. - * - * @param $id - * - * @return array */ - private function buildPath($id) + private function buildPath($id): array { if (!$id) { return []; diff --git a/src/Extensions/Shopware/DataGenerator/Resources/Customers.php b/src/Extensions/Shopware/DataGenerator/Resources/Customers.php index a8b7e748..babefadc 100644 --- a/src/Extensions/Shopware/DataGenerator/Resources/Customers.php +++ b/src/Extensions/Shopware/DataGenerator/Resources/Customers.php @@ -27,18 +27,6 @@ class Customers extends BaseResource 's_user_shippingaddress_attributes', ]; - /** - * Stores the used ids for SQL inserts - * - * @var array - */ - protected $ids = []; - - /** - * @var LoadDataInfile - */ - private $loadDataInfile; - /** * {@inheritdoc} */ @@ -46,7 +34,7 @@ public function create(WriterInterface $writer) { $this->ids['customerNumber'] = 20002; $number = $this->config->getNumberCustomers(); - $this->loadDataInfile = new LoadDataInfile(); + $loadDataInfile = new LoadDataInfile(); $importCustomers = $this->writerManager->createWriter('customers', 'csv'); $importCustomersAttributes = $this->writerManager->createWriter('customers_attributes', 'csv'); @@ -72,61 +60,61 @@ public function create(WriterInterface $writer) $birthday = ''; - if (rand(1, 4) !== 4) { + if (random_int(1, 4) !== 4) { $birthday = $faker->dateTimeThisCentury->format('Y-m-d'); } $importCustomers->write( "{$id},{$customerNumber},a256a310bc1e5db755fd392c524028a8,{$faker->email},1,0,,5,2013-01-11,2015-01-01 00:00:00,,0,,0,{$group},0,1,1,,\N,,0,\N,{$id},{$id},{$sex},{$faker->firstName},{$faker->lastName}, {$birthday}" ); - $importCustomersAttributes->write("{$id}"); - $importCustomersBillingAttributes->write("{$id}"); - $importCustomersBillingAttributes->write("{$id}"); + $importCustomersAttributes->write((string) ($id)); + $importCustomersBillingAttributes->write((string) ($id)); + $importCustomersBillingAttributes->write((string) ($id)); - $customerAttributeValues[] = "{$id}"; + $customerAttributeValues[] = (string) ($id); $importCustomersBilling->write( - "{$id}, {$id}, , , {$sex}, {$this->generator->getRandomFirstName()}, {$this->generator->getRandomLastName()}, {$this->generator->getRandomWord()} " . rand( + "{$id}, {$id}, , , {$sex}, {$this->generator->getRandomFirstName()}, {$this->generator->getRandomLastName()}, {$this->generator->getRandomWord()} " . random_int( 1, 500 - ) . "' , " . rand(42000, 50000) . ", {$this->generator->getRandomCity()}, " . rand( + ) . "' , " . random_int(42000, 50000) . ", {$this->generator->getRandomCity()}, " . random_int( 9999, 99999 ) . ', 2, 0, ' ); $importCustomersShipping->write( - "{$id}, {$id}, , , {$sex}, {$this->generator->getRandomFirstName()}, {$this->generator->getRandomLastName()}, {$this->generator->getRandomWord()} " . rand( + "{$id}, {$id}, , , {$sex}, {$this->generator->getRandomFirstName()}, {$this->generator->getRandomLastName()}, {$this->generator->getRandomWord()} " . random_int( 1, 500 - ) . "' , " . rand(42000, 50000) . ", {$this->generator->getRandomCity()}, 2, 0" + ) . "' , " . random_int(42000, 50000) . ", {$this->generator->getRandomCity()}, 2, 0" ); - $zip = rand(42000, 50000); + $zip = random_int(42000, 50000); $importCustomersAddresses->write( "{$id}, {$id}, company, department, mr, {$this->generator->getRandomFirstName()}, {$this->generator->getRandomLastName()}, {$this->generator->getRandomWord()}, {$zip}, {$this->generator->getRandomCity()}, 2, 0, ustid, phone,,," ); } - $writer->write($this->loadDataInfile->get('s_user', $importCustomers->getFileName())); + $writer->write($loadDataInfile->get('s_user', $importCustomers->getFileName())); $writer->write( - $this->loadDataInfile->get('s_user_attributes', $importCustomersAttributes->getFileName()) + $loadDataInfile->get('s_user_attributes', $importCustomersAttributes->getFileName()) ); $writer->write( - $this->loadDataInfile->get('s_user_addresses', $importCustomersAddresses->getFileName()) + $loadDataInfile->get('s_user_addresses', $importCustomersAddresses->getFileName()) ); $writer->write( - $this->loadDataInfile->get('s_user_billingaddress', $importCustomersBilling->getFileName()) + $loadDataInfile->get('s_user_billingaddress', $importCustomersBilling->getFileName()) ); $writer->write( - $this->loadDataInfile->get('s_user_shippingaddress', $importCustomersShipping->getFileName()) + $loadDataInfile->get('s_user_shippingaddress', $importCustomersShipping->getFileName()) ); $writer->write( - $this->loadDataInfile->get( + $loadDataInfile->get( 's_user_billingaddress_attributes', $importCustomersBillingAttributes->getFileName() ) ); $writer->write( - $this->loadDataInfile->get( + $loadDataInfile->get( 's_user_shippingaddress_attributes', $importCustomersShippingAttributes->getFileName() ) diff --git a/src/Extensions/Shopware/DataGenerator/Resources/Newsletter.php b/src/Extensions/Shopware/DataGenerator/Resources/Newsletter.php index 8646c6a5..2ba7f4b3 100644 --- a/src/Extensions/Shopware/DataGenerator/Resources/Newsletter.php +++ b/src/Extensions/Shopware/DataGenerator/Resources/Newsletter.php @@ -58,11 +58,10 @@ public function create(WriterInterface $writer) ); // Groups assigned to the newsletter - $groups = [ + $groups = serialize([ ['EK' => 0, 'H' => 0], [1 => 0], - ]; - $groups = serialize($groups); + ]); // The actual newsletter $writer->write( diff --git a/src/Extensions/Shopware/DataGenerator/Resources/Orders.php b/src/Extensions/Shopware/DataGenerator/Resources/Orders.php index 5003477c..60c0f4f9 100644 --- a/src/Extensions/Shopware/DataGenerator/Resources/Orders.php +++ b/src/Extensions/Shopware/DataGenerator/Resources/Orders.php @@ -29,6 +29,7 @@ class Orders extends BaseResource * Number of article details available */ protected $numberDetails; + private static $devices = [ 'desktop', 'mobile', @@ -40,10 +41,7 @@ class Orders extends BaseResource */ private $articleResource; - /** - * @param Articles $articleResource - */ - public function setArticleResource(Articles $articleResource) + public function setArticleResource(Articles $articleResource): void { $this->articleResource = $articleResource; } @@ -87,10 +85,10 @@ public function create(WriterInterface $writer) $orderNumbers[] = $orderNumber; - $currentCustomer = mt_rand(1, $totalNumberCustomers); + $currentCustomer = random_int(1, $totalNumberCustomers); $currentCustomerNumber = 20002 + $currentCustomer; // Create a large order for the first order - $numArticles = $id === 1 ? 100 : mt_rand(1, 4); + $numArticles = $id === 1 ? 100 : random_int(1, 4); $totalPrice = $numArticles * 47.90; $totalPricePreTax = $totalPrice / 1.19; @@ -99,11 +97,11 @@ public function create(WriterInterface $writer) $valueData['customerShippingValues'][] = "( {$currentCustomer}, {$id}, '', '', 'mr', '{$this->quote($faker->firstName)}', '{$this->quote($faker->lastName)}', '{$this->quote($faker->streetAddress)}', '{$this->quote($faker->postcode)}', '{$this->quote($faker->city)}', 2, 0)"; $valueData['customerBillingAttributeValues'][] = "({$id}, {$id})"; - $cleared = mt_rand(9, 21); - $state = mt_rand(0, 8); - $payment = mt_rand(2, 6); - $device = self::$devices[mt_rand(0, count(self::$devices) - 1)]; - $date = $faker->dateTimeBetween('-2years', 'now'); + $cleared = random_int(9, 21); + $state = random_int(0, 8); + $payment = random_int(2, 6); + $device = self::$devices[random_int(0, \count(self::$devices) - 1)]; + $date = $faker->dateTimeBetween('-2years'); $dateFormatted = $date->format('Y-m-d'); @@ -118,7 +116,7 @@ public function create(WriterInterface $writer) for ($detailCounter = 1; $detailCounter <= $numArticles; ++$detailCounter) { $detailId = $this->getUniqueId('orderDetail'); - $articleId = $articleDetails[mt_rand(1, $this->articleResource->getIds('article'))]; + $articleId = $articleDetails[random_int(1, $this->articleResource->getIds('article'))]; $valueData['orderDetailValues'][] = "({$detailId}, {$id}, '{$orderNumber}', '{$articleId}', 'sw-not-real', 47.90, 1, '{$this->generator->getSentence(3)}', 1, 0, 0)"; } } @@ -133,8 +131,8 @@ public function create(WriterInterface $writer) $date = $dt->format('Y-m-d'); $ordersOnDate = isset($orderDates[$date]) ? $orderDates[$date] : 10; - $pageImpressions = $ordersOnDate * mt_rand(200, 1500); - $uniqueVisits = $ordersOnDate * mt_rand(1, 50); + $pageImpressions = $ordersOnDate * random_int(200, 1500); + $uniqueVisits = $ordersOnDate * random_int(1, 50); $valueData['visitors'][] = "(1, \"{$date}\", {$pageImpressions}, {$uniqueVisits}, \"desktop\")"; } @@ -148,19 +146,17 @@ public function create(WriterInterface $writer) /** * Constructs the actual inserts from the passed arrays * - * @param $valueData - * * @return string[] */ - private function createSQL($valueData) + private function createSQL($valueData): array { $sql = []; $sql[] = ' INSERT INTO `s_order` (`id`,`ordernumber`, `userID`, `invoice_amount`, `invoice_amount_net`, `invoice_shipping`, `invoice_shipping_net`, `ordertime`, `status`, `cleared`, `paymentID`, `transactionID`, `comment`, `customercomment`, `internalcomment`, `net`, `taxfree`, `partnerID`, `temporaryID`, `referer`, `cleareddate`, `trackingcode`, `language`, `dispatchID`, `currency`, `currencyFactor`, `subshopID`, `remote_addr`, `deviceType`) VALUES ' . implode( - ",\n ", - $valueData['orderValues'] - ) . ';'; + ",\n ", + $valueData['orderValues'] + ) . ';'; $sql[] = ' INSERT INTO `s_order_details` (`id`, `orderID`, `ordernumber`, `articleID`, `articleordernumber`, `price`, `quantity`, `name`, `status`, `shipped`, `shippedgroup`) VALUES @@ -168,41 +164,36 @@ private function createSQL($valueData) $sql[] = ' INSERT INTO `s_order_billingaddress` (`userID`, `orderID`, `company`, `department`, `salutation`, `customernumber`, `firstname`, `lastname`, `street`, `zipcode`, `city`, `phone`, `countryID`, `stateID`) VALUES ' . implode( - ' , ', - $valueData['customerBillingValues'] - ) . ';'; + ' , ', + $valueData['customerBillingValues'] + ) . ';'; $sql[] = ' INSERT INTO `s_order_shippingaddress` (`userID`, `orderID`, `company`, `department`, `salutation`, `firstname`, `lastname`, `street`, `zipcode`, `city`, `countryID`, `stateID`) VALUES ' . implode( - ' , ', - $valueData['customerShippingValues'] - ) . ';'; + ' , ', + $valueData['customerShippingValues'] + ) . ';'; $sql[] = ' INSERT INTO `s_order_shippingaddress_attributes` (`id`, `shippingID`) VALUES ' . implode( - ', ', - $valueData['customerBillingAttributeValues'] - ) . ';'; + ', ', + $valueData['customerBillingAttributeValues'] + ) . ';'; $sql[] = ' INSERT INTO `s_order_billingaddress_attributes` (`id`, `billingID`) VALUES ' . implode( - ', ', - $valueData['customerBillingAttributeValues'] - ) . ';'; + ', ', + $valueData['customerBillingAttributeValues'] + ) . ';'; $sql[] = ' INSERT INTO `s_statistics_visitors` (`shopID`, `datum`, `pageimpressions`, `uniquevisits`, `deviceType`) VALUES ' . implode( - ', ', - $valueData['visitors'] - ) . ';'; + ', ', + $valueData['visitors'] + ) . ';'; return $sql; } - /** - * @param $string - * - * @return string - */ - private function quote($string) + private function quote($string): string { return str_replace('\'', "\'", $string); } diff --git a/src/Extensions/Shopware/DataGenerator/Resources/Vouchers.php b/src/Extensions/Shopware/DataGenerator/Resources/Vouchers.php index 3262dd19..d5227e1c 100644 --- a/src/Extensions/Shopware/DataGenerator/Resources/Vouchers.php +++ b/src/Extensions/Shopware/DataGenerator/Resources/Vouchers.php @@ -28,18 +28,13 @@ class Vouchers extends BaseResource 's_emarketing_voucher_codes', ]; - /** - * @var LoadDataInfile - */ - private $loadDataInfile; - /** * {@inheritdoc} */ public function create(WriterInterface $writer) { $number = $this->config->getNumberVouchers(); - $this->loadDataInfile = new LoadDataInfile(); + $loadDataInfile = new LoadDataInfile(); $voucherCsv = $this->writerManager->createWriter('vouchers', 'csv'); $voucherCodeCsv = $this->writerManager->createWriter('voucher_code', 'csv'); @@ -60,12 +55,12 @@ public function create(WriterInterface $writer) if ($isIndividual) { $code = ''; } - $value = mt_rand(5, 100); + $value = random_int(5, 100); $voucherCsv->write( "{$id},Voucher #{$id},{$code},{$value},101,\N,\N,VOUCHER{$id},{$isIndividual},{$isPercental},{$numOrder},\N,auto" ); - $voucherAttributeCsv->write("{$id}"); + $voucherAttributeCsv->write((string) ($id)); if ($isIndividual) { for ($i = 0; $i < $this->numberOfIndividualVoucherCodes; ++$i) { @@ -75,10 +70,10 @@ public function create(WriterInterface $writer) } } - $writer->write($this->loadDataInfile->get('s_emarketing_vouchers', $voucherCsv->getFileName())); + $writer->write($loadDataInfile->get('s_emarketing_vouchers', $voucherCsv->getFileName())); $writer->write( - $this->loadDataInfile->get('s_emarketing_vouchers_attributes', $voucherAttributeCsv->getFileName()) + $loadDataInfile->get('s_emarketing_vouchers_attributes', $voucherAttributeCsv->getFileName()) ); - $writer->write($this->loadDataInfile->get('s_emarketing_voucher_codes', $voucherCodeCsv->getFileName())); + $writer->write($loadDataInfile->get('s_emarketing_voucher_codes', $voucherCodeCsv->getFileName())); } } diff --git a/src/Extensions/Shopware/DataGenerator/Services/LoadDataInfile.php b/src/Extensions/Shopware/DataGenerator/Services/LoadDataInfile.php index 4c089b5d..4c9e85a4 100644 --- a/src/Extensions/Shopware/DataGenerator/Services/LoadDataInfile.php +++ b/src/Extensions/Shopware/DataGenerator/Services/LoadDataInfile.php @@ -10,8 +10,6 @@ /** * Knows everything about our tables to create proper LOAD DATA INFILE queries - * - * Class LoadDataInfile */ class LoadDataInfile { @@ -202,13 +200,8 @@ class LoadDataInfile /** * Returns a loadDataInfile query for the selected table / file - * - * @param $tableName - * @param $file - * - * @return string */ - public function get($tableName, $file) + public function get($tableName, $file): string { if (!$columns = $this->mappings[$tableName]) { throw new \RuntimeException("No definition for $tableName"); @@ -217,7 +210,7 @@ public function get($tableName, $file) $columns = implode( ', ', array_map( - function ($column) { + static function ($column) { return "`$column`"; }, $columns diff --git a/src/Extensions/Shopware/DataGenerator/Struct/Config.php b/src/Extensions/Shopware/DataGenerator/Struct/Config.php index 66fadf10..dd43d93c 100644 --- a/src/Extensions/Shopware/DataGenerator/Struct/Config.php +++ b/src/Extensions/Shopware/DataGenerator/Struct/Config.php @@ -90,18 +90,12 @@ class Config */ protected $chunkSize; - /** - * @param $numberArticles - */ - public function setNumberArticles($numberArticles) + public function setNumberArticles($numberArticles): void { $this->numberArticles = $numberArticles; } - /** - * @return int - */ - public function getNumberArticles() + public function getNumberArticles(): int { return $this->numberArticles; } @@ -109,7 +103,7 @@ public function getNumberArticles() /** * @param int $numberCategories */ - public function setNumberCategories($numberCategories) + public function setNumberCategories($numberCategories): void { $this->numberCategories = $numberCategories; } @@ -117,79 +111,52 @@ public function setNumberCategories($numberCategories) /** * @param int $categoriesPerArticle */ - public function setNumberCategoriesPerArticle($categoriesPerArticle) + public function setNumberCategoriesPerArticle($categoriesPerArticle): void { $this->categoriesPerArticle = max(1, $categoriesPerArticle); } - /** - * @return int - */ - public function getCategoriesPerArticle() + public function getCategoriesPerArticle(): int { return $this->categoriesPerArticle; } - /** - * @return int - */ - public function getNumberCategories() + public function getNumberCategories(): int { return $this->numberCategories; } - /** - * @param $numberCustomers - */ - public function setNumberCustomers($numberCustomers) + public function setNumberCustomers($numberCustomers): void { $this->numberCustomers = $numberCustomers; } - /** - * @return int - */ - public function getNumberCustomers() + public function getNumberCustomers(): int { return $this->numberCustomers; } - /** - * @param $numberOrders - */ - public function setNumberOrders($numberOrders) + public function setNumberOrders($numberOrders): void { $this->numberOrders = $numberOrders; } - /** - * @return int - */ - public function getNumberOrders() + public function getNumberOrders(): int { return $this->numberOrders; } - /** - * @param $numberNewsletter - */ - public function setNumberNewsletter($numberNewsletter) + public function setNumberNewsletter($numberNewsletter): void { $this->numberNewsletter = $numberNewsletter; } - /** - * @return int - */ - public function getNumberNewsletter() + public function getNumberNewsletter(): int { return $this->numberNewsletter; } - /** - * @param $outputName - */ - public function setOutputName($outputName) + public function setOutputName($outputName): void { $this->outputName = $outputName; } @@ -197,7 +164,7 @@ public function setOutputName($outputName) /** * @param int $maxVariants */ - public function setMaxVariants($maxVariants) + public function setMaxVariants($maxVariants): void { $this->maxVariants = $maxVariants; } @@ -205,23 +172,17 @@ public function setMaxVariants($maxVariants) /** * @param int $minVariants */ - public function setMinVariants($minVariants) + public function setMinVariants($minVariants): void { $this->minVariants = $minVariants; } - /** - * @return int - */ - public function getMaxVariants() + public function getMaxVariants(): int { return $this->maxVariants; } - /** - * @return int - */ - public function getMinVariants() + public function getMinVariants(): int { return $this->minVariants; } @@ -229,28 +190,25 @@ public function getMinVariants() /** * @param string|array $thumbnailSizes */ - public function setThumbnailSizes($thumbnailSizes) + public function setThumbnailSizes($thumbnailSizes): void { if (empty($thumbnailSizes)) { $this->thumbnailSizes = null; return; } - if (is_string($thumbnailSizes)) { + if (\is_string($thumbnailSizes)) { $thumbnailSizes = explode(',', $thumbnailSizes); } $this->thumbnailSizes = $thumbnailSizes; } - public function getThumbnailSizes() + public function getThumbnailSizes(): array { return $this->thumbnailSizes; } - /** - * @return int - */ - public function getNumberVouchers() + public function getNumberVouchers(): int { return $this->numberVouchers; } @@ -258,15 +216,12 @@ public function getNumberVouchers() /** * @param int $numberVouchers */ - public function setNumberVouchers($numberVouchers) + public function setNumberVouchers($numberVouchers): void { $this->numberVouchers = $numberVouchers; } - /** - * @return int - */ - public function getArticleFilterGroups() + public function getArticleFilterGroups(): int { return $this->articleFilterGroups; } @@ -274,15 +229,12 @@ public function getArticleFilterGroups() /** * @param int $articleFilterGroups */ - public function setArticleFilterGroups($articleFilterGroups) + public function setArticleFilterGroups($articleFilterGroups): void { $this->articleFilterGroups = $articleFilterGroups; } - /** - * @return int - */ - public function getArticleFilterOptions() + public function getArticleFilterOptions(): int { return $this->articleFilterOptions; } @@ -290,15 +242,12 @@ public function getArticleFilterOptions() /** * @param int $articleFilterOptions */ - public function setArticleFilterOptions($articleFilterOptions) + public function setArticleFilterOptions($articleFilterOptions): void { $this->articleFilterOptions = $articleFilterOptions; } - /** - * @return int - */ - public function getArticleFilterValues() + public function getArticleFilterValues(): int { return $this->articleFilterValues; } @@ -306,48 +255,36 @@ public function getArticleFilterValues() /** * @param int $articleFilterValues */ - public function setArticleFilterValues($articleFilterValues) + public function setArticleFilterValues($articleFilterValues): void { $this->articleFilterValues = $articleFilterValues; } - /** - * @param $imageDir - */ - public function setImageDir($imageDir) + public function setImageDir($imageDir): void { - $dir = $imageDir . '/' . 'thumbnail'; + $dir = $imageDir . '/thumbnail'; if (!is_dir($dir) && !mkdir($dir, 0777, true) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); } $this->imageDir = $imageDir; } - /** - * @return string - */ - public function getImageDir() + public function getImageDir(): string { return $this->imageDir; } - /** - * @param $createImages - */ - public function setCreateImages($createImages) + public function setCreateImages($createImages): void { $this->createImages = (bool) $createImages; } - /** - * @return bool - */ - public function getCreateImages() + public function getCreateImages(): bool { return $this->createImages; } - public function createOutputDir() + public function createOutputDir(): void { $outputDir = getcwd() . '/output'; if (!is_dir($outputDir) && !mkdir($outputDir) && !is_dir($outputDir)) { @@ -358,15 +295,12 @@ public function createOutputDir() /** * @param int $chunkSize */ - public function setChunkSize($chunkSize) + public function setChunkSize($chunkSize): void { $this->chunkSize = $chunkSize; } - /** - * @return int - */ - public function getChunkSize() + public function getChunkSize(): int { return $this->chunkSize; } @@ -374,23 +308,17 @@ public function getChunkSize() /** * @param int $seed */ - public function setSeed($seed) + public function setSeed($seed): void { $this->seed = $seed; } - /** - * @return string - */ - public function getOutputName() + public function getOutputName(): string { return $this->outputName; } - /** - * @return mixed - */ - public function getSeed() + public function getSeed(): int { return $this->seed; } @@ -398,15 +326,12 @@ public function getSeed() /** * @param string $generatorLocale */ - public function setGeneratorLocale($generatorLocale) + public function setGeneratorLocale($generatorLocale): void { $this->generatorLocale = $generatorLocale; } - /** - * @return string - */ - public function getGeneratorLocale() + public function getGeneratorLocale(): string { return $this->generatorLocale; } diff --git a/src/Extensions/Shopware/DataGenerator/Writer/BufferedFileWriter.php b/src/Extensions/Shopware/DataGenerator/Writer/BufferedFileWriter.php index b18f3a84..e4cd5898 100644 --- a/src/Extensions/Shopware/DataGenerator/Writer/BufferedFileWriter.php +++ b/src/Extensions/Shopware/DataGenerator/Writer/BufferedFileWriter.php @@ -10,8 +10,6 @@ /** * Buffered file writer which will only write to disc every X writes - * - * Class BufferedFileWriter */ class BufferedFileWriter implements WriterInterface { @@ -42,21 +40,20 @@ class BufferedFileWriter implements WriterInterface /** * @param string $file - * @param $maxBufferSize */ public function __construct($file, $maxBufferSize = 50) { $this->fileName = $file; - $this->fileHandle = fopen($file, 'w'); + $this->fileHandle = fopen($file, 'wb'); $this->maxBufferSize = $maxBufferSize; } - public function setWriteBuffer($writeBuffer) + public function setWriteBuffer($writeBuffer): void { $this->maxBufferSize = $writeBuffer; } - public function getFileName() + public function getFileName(): string { return $this->fileName; } @@ -66,12 +63,12 @@ public function getFileName() */ public function write($content) { - if (!is_array($content)) { + if (!\is_array($content)) { $this->buffer[] = $content; - $this->bufferCounter += 1; + ++$this->bufferCounter; } else { $this->buffer = array_merge($this->buffer, $content); - $this->bufferCounter += count($content); + $this->bufferCounter += \count($content); } if ($this->bufferCounter >= $this->maxBufferSize) { $this->flush(); @@ -87,7 +84,7 @@ public function flush() return; } - fputs($this->fileHandle, implode("\n", $this->buffer) . "\n"); + fwrite($this->fileHandle, implode("\n", $this->buffer) . "\n"); $this->buffer = []; $this->bufferCounter = 0; } @@ -95,7 +92,7 @@ public function flush() /** * {@inheritdoc} */ - public function getPriority() + public function getPriority(): int { return 10; } diff --git a/src/Extensions/Shopware/DataGenerator/Writer/DatabaseWriter.php b/src/Extensions/Shopware/DataGenerator/Writer/DatabaseWriter.php index 0c25f16b..569d3363 100644 --- a/src/Extensions/Shopware/DataGenerator/Writer/DatabaseWriter.php +++ b/src/Extensions/Shopware/DataGenerator/Writer/DatabaseWriter.php @@ -10,9 +10,6 @@ use PDO; -/** - * Class ShopwareWriter. - */ class DatabaseWriter implements WriterInterface { /** @@ -25,10 +22,9 @@ class DatabaseWriter implements WriterInterface */ private $data = []; - public function __construct($config, $resourceName) + public function __construct($config) { $this->config = $config; - $this->resourceName = $resourceName; } /** @@ -36,7 +32,7 @@ public function __construct($config, $resourceName) */ public function write($content) { - if (!is_array($content)) { + if (!\is_array($content)) { $this->data[] = $content; } else { $this->data = array_merge($this->data, $content); @@ -67,26 +63,21 @@ public function flush() /** * {@inheritdoc} */ - public function getPriority() + public function getPriority(): int { return -10; } - /** - * @param $config - * - * @return PDO - */ - private function connectToDatabase($config) + private function connectToDatabase($config): PDO { - $connection = new PDO( - 'mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'], $config['username'], $config['password'], + return new PDO( + 'mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'], + $config['username'], + $config['password'], [ PDO::MYSQL_ATTR_LOCAL_INFILE => true, // if this still does not work, php5-mysqnd might work PDO::ERRMODE_EXCEPTION => 1, ] ); - - return $connection; } } diff --git a/src/Extensions/Shopware/DataGenerator/Writer/WriterInterface.php b/src/Extensions/Shopware/DataGenerator/Writer/WriterInterface.php index 94d51f9b..b2b22dfc 100644 --- a/src/Extensions/Shopware/DataGenerator/Writer/WriterInterface.php +++ b/src/Extensions/Shopware/DataGenerator/Writer/WriterInterface.php @@ -10,8 +10,6 @@ /** * Generic write interface to abstract file operations - * - * Interface WriterInterface */ interface WriterInterface { @@ -30,8 +28,6 @@ public function write($content); /** * Priority in which the writer must be flushed. Higher priority writers are flushed first - * - * @return int */ - public function getPriority(); + public function getPriority(): int; } diff --git a/src/Extensions/Shopware/DataGenerator/Writer/WriterManager.php b/src/Extensions/Shopware/DataGenerator/Writer/WriterManager.php index c695f7b6..7ba1d4aa 100644 --- a/src/Extensions/Shopware/DataGenerator/Writer/WriterManager.php +++ b/src/Extensions/Shopware/DataGenerator/Writer/WriterManager.php @@ -11,9 +11,6 @@ use Shopware\DataGenerator\Struct\Config; use ShopwareCli\Services\IoService; -/** - * Class WriterManager - */ class WriterManager { /** @@ -46,10 +43,6 @@ class WriterManager */ private $ioService; - /** - * @param Config $config - * @param IoService $ioService - */ public function __construct( Config $config, IoService $ioService @@ -62,26 +55,25 @@ public function __construct( * @param string $resourceKey * @param string $type * @param null $writerType - * - * @return WriterInterface */ - public function createWriter($resourceKey, $type = null, $writerType = null) + public function createWriter($resourceKey, $type = null, $writerType = null): WriterInterface { $writerType = $writerType ?: $this->defaultWriterType; switch ($writerType) { case 'database': - if ($type == 'sql') { - $writer = new DatabaseWriter($this->writerConfig[$writerType], $resourceKey); + if ($type === 'sql') { + $writer = new DatabaseWriter($this->writerConfig[$writerType]); break; } + // no break default: $resourcePath = getcwd() . '/output/' . $this->config->getOutputName() . $resourceKey; if ($type) { $resourcePath .= '.' . $type; } - if ($type == 'sql') { + if ($type === 'sql') { $this->displayImportMessage = true; } $writer = new BufferedFileWriter($resourcePath); @@ -95,12 +87,12 @@ public function createWriter($resourceKey, $type = null, $writerType = null) /** * Flushes all known writers at once */ - public function flushAll() + public function flushAll(): void { $this->ioService->writeln('Flushing data...'); - $compare = function ($a, $b) { - if ($a->getPriority() == $b->getPriority()) { + $compare = static function (WriterInterface $a, WriterInterface $b) { + if ($a->getPriority() === $b->getPriority()) { return 0; } @@ -114,7 +106,7 @@ public function flushAll() $writer->flush(); } - if ($this->displayImportMessage == true) { + if ($this->displayImportMessage) { $this->ioService->writeln('Done. Please import SQLs using something like this:'); $this->ioService->writeln('mysql --local-infile -uroot -proot DATABASE < FILE.sql'); } @@ -123,24 +115,17 @@ public function flushAll() /** * Clears all writers */ - public function clear() + public function clear(): void { $this->writers = []; } - /** - * @param $defaultWriterType - */ - public function setDefaultWriterType($defaultWriterType) + public function setDefaultWriterType($defaultWriterType): void { $this->defaultWriterType = $defaultWriterType; } - /** - * @param $writerType - * @param $value - */ - public function setConfig($writerType, $value) + public function setConfig($writerType, $value): void { $this->writerConfig[$writerType] = $value; } diff --git a/src/Extensions/Shopware/Install/Bootstrap.php b/src/Extensions/Shopware/Install/Bootstrap.php index 07e19203..03cc5f25 100644 --- a/src/Extensions/Shopware/Install/Bootstrap.php +++ b/src/Extensions/Shopware/Install/Bootstrap.php @@ -11,6 +11,16 @@ use Shopware\Install\Command\ShopwareClearCacheCommand; use Shopware\Install\Command\ShopwareInstallReleaseCommand; use Shopware\Install\Command\ShopwareInstallVcsCommand; +use Shopware\Install\Services\Checkout; +use Shopware\Install\Services\ConfigWriter; +use Shopware\Install\Services\Database; +use Shopware\Install\Services\Demodata; +use Shopware\Install\Services\Install\Release; +use Shopware\Install\Services\Install\Vcs; +use Shopware\Install\Services\Owner; +use Shopware\Install\Services\PostInstall; +use Shopware\Install\Services\ReleaseDownloader; +use Shopware\Install\Services\VcsGenerator; use ShopwareCli\Application\ConsoleAwareExtension; use ShopwareCli\Application\ContainerAwareExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -18,8 +28,6 @@ /** * This plugin will install/setup shopware in a development version - * - * Class Bootstrap */ class Bootstrap implements ContainerAwareExtension, ConsoleAwareExtension { @@ -43,48 +51,44 @@ public function getConsoleCommands() ]; } - /** - * @param ContainerBuilder $container - */ private function populateContainer(ContainerBuilder $container) { - $container->register('shopware_checkout_service', 'Shopware\Install\Services\Checkout') + $container->register('shopware_checkout_service', Checkout::class) ->addArgument(new Reference('git_util')) ->addArgument(new Reference('io_service')); - $container->register('post_install', 'Shopware\Install\Services\PostInstall') + $container->register('post_install', PostInstall::class) ->addArgument(new Reference('process_executor')) ->addArgument(new Reference('shopware-install.owner')) ->addArgument(new Reference('config')) ->addArgument(new Reference('shopware_info')); - $container->register('shopware_release_download_service', 'Shopware\Install\Services\ReleaseDownloader') + $container->register('shopware_release_download_service', ReleaseDownloader::class) ->addArgument(new Reference('process_executor')) ->addArgument(new Reference('io_service')) ->addArgument(new Reference('file_downloader')) ->addArgument(new Reference('openssl_verifier')) ->addArgument($container->get('path_provider')->getCachePath()); - $container->register('shopware-install.vcs_generator', 'Shopware\Install\Services\VcsGenerator') + $container->register('shopware-install.vcs_generator', VcsGenerator::class) ->addArgument(new Reference('io_service')); - $container->register('shopware-install.config_writer', 'Shopware\Install\Services\ConfigWriter') + $container->register('shopware-install.config_writer', ConfigWriter::class) ->addArgument(new Reference('io_service')); - $container->register('shopware-install.owner', 'Shopware\Install\Services\Owner'); + $container->register('shopware-install.owner', Owner::class); - $container->register('shopware-install.database', 'Shopware\Install\Services\Database') - ->addArgument(new Reference('utilities')) + $container->register('shopware-install.database', Database::class) ->addArgument(new Reference('io_service')) ->addArgument(new Reference('process_executor')); - $container->register('shopware-install.demodata', 'Shopware\Install\Services\Demodata') + $container->register('shopware-install.demodata', Demodata::class) ->addArgument(new Reference('path_provider')) ->addArgument(new Reference('io_service')) ->addArgument(new Reference('shopware_info')) ->addArgument(new Reference('process_executor')); - $container->register('shopware_vcs_install_service', 'Shopware\Install\Services\Install\Vcs') + $container->register('shopware_vcs_install_service', Vcs::class) ->addArgument(new Reference('shopware_checkout_service')) ->addArgument(new Reference('config')) ->addArgument(new Reference('shopware-install.vcs_generator')) @@ -94,13 +98,12 @@ private function populateContainer(ContainerBuilder $container) ->addArgument(new Reference('io_service')) ->addArgument(new Reference('post_install')); - $container->register('shopware_release_install_service', 'Shopware\Install\Services\Install\Release') + $container->register('shopware_release_install_service', Release::class) ->addArgument(new Reference('shopware_release_download_service')) ->addArgument(new Reference('config')) ->addArgument(new Reference('shopware-install.vcs_generator')) ->addArgument(new Reference('shopware-install.config_writer')) ->addArgument(new Reference('shopware-install.database')) - ->addArgument(new Reference('shopware-install.demodata')) ->addArgument(new Reference('io_service')) ->addArgument(new Reference('post_install')) ->addArgument(new Reference('process_executor')); diff --git a/src/Extensions/Shopware/Install/Command/ShopwareClearCacheCommand.php b/src/Extensions/Shopware/Install/Command/ShopwareClearCacheCommand.php index 8790903e..dbbda547 100644 --- a/src/Extensions/Shopware/Install/Command/ShopwareClearCacheCommand.php +++ b/src/Extensions/Shopware/Install/Command/ShopwareClearCacheCommand.php @@ -21,10 +21,8 @@ class ShopwareClearCacheCommand extends BaseCommand * @param string $path * * @throws \RuntimeException - * - * @return string */ - public function validateShopwareDirectory($path) + public function validateShopwareDirectory($path): string { if (!$this->container->get('utilities')->isShopwareInstallation($path)) { throw new \RuntimeException("'$path' is not a valid shopware path"); @@ -61,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $path = './' . $path; } - /** @var $shopwareInfo ShopwareInfo */ + /** @var ShopwareInfo $shopwareInfo */ $shopwareInfo = $this->container->get('shopware_info'); /** @var ProcessExecutor $processExecutor */ @@ -69,12 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $processExecutor->execute($shopwareInfo->getCacheDir($path) . '/clear_cache.sh'); } - /** - * @param InputInterface $input - * - * @return string - */ - private function checkPath(InputInterface $input) + private function checkPath(InputInterface $input): string { $shopwarePath = $input->getOption('installDir'); diff --git a/src/Extensions/Shopware/Install/Command/ShopwareInstallReleaseCommand.php b/src/Extensions/Shopware/Install/Command/ShopwareInstallReleaseCommand.php index e42ad5fc..db0cf5d7 100644 --- a/src/Extensions/Shopware/Install/Command/ShopwareInstallReleaseCommand.php +++ b/src/Extensions/Shopware/Install/Command/ShopwareInstallReleaseCommand.php @@ -8,6 +8,7 @@ namespace Shopware\Install\Command; +use Shopware\Install\Services\Install\Release; use Shopware\Install\Struct\InstallationRequest; use ShopwareCli\Command\BaseCommand; use ShopwareCli\Config; @@ -18,15 +19,11 @@ class ShopwareInstallReleaseCommand extends BaseCommand { - /** - * @param InputInterface $input - * @param OutputInterface $output - */ public function interact(InputInterface $input, OutputInterface $output) { $this->validateInput($input); - /** @var $ioService IoService */ + /** @var IoService $ioService */ $ioService = $this->container->get('io_service'); $this->askGenericOptions($input, $ioService); @@ -53,10 +50,8 @@ public function interact(InputInterface $input, OutputInterface $output) * @param string $input * * @throws \RuntimeException - * - * @return string */ - public function genericValidator($input) + public function genericValidator($input): string { if (empty($input)) { throw new \RuntimeException('Field may not be empty'); @@ -69,10 +64,8 @@ public function genericValidator($input) * @param string $path * * @throws \RuntimeException - * - * @return string */ - public function validateInstallDir($path) + public function validateInstallDir($path): string { if (is_dir($path)) { throw new \RuntimeException("Path '{$path}'' is not empty"); @@ -81,10 +74,7 @@ public function validateInstallDir($path) return $path; } - /** - * @return Config - */ - protected function getConfig() + protected function getConfig(): Config { return $this->container->get('config'); } @@ -139,25 +129,23 @@ protected function execute(InputInterface $input, OutputInterface $output) 'skipAdminCreation' => $input->getOption('skip-admin-creation'), ]); - /** @var \Shopware\Install\Services\Install\Release $installService */ + /** @var Release $installService */ $installService = $this->container->get('shopware_release_install_service'); $installService->installShopware($request); } /** - * @param InputInterface $input - * * @throws \RuntimeException */ - protected function validateInput(InputInterface $input) + protected function validateInput(InputInterface $input): void { $language = $input->getOption('shop-locale'); - if (!in_array($language, ['en_GB', 'de_DE'])) { + if (!\in_array($language, ['en_GB', 'de_DE'])) { throw new \RuntimeException("Invalid locale: '$language'"); } } - private function addInstallerOptions() + private function addInstallerOptions(): void { $this ->addOption('release', 'r', InputOption::VALUE_REQUIRED, 'Release version. Default: Latest') @@ -166,7 +154,7 @@ private function addInstallerOptions() ->addOption('skip-download', null, InputOption::VALUE_NONE, 'Skip release downloading'); } - private function addDbOptions() + private function addDbOptions(): void { $this ->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', 'localhost') @@ -179,7 +167,7 @@ private function addDbOptions() ; } - private function addShopOptions() + private function addShopOptions(): void { $this ->addOption('shop-locale', null, InputOption::VALUE_REQUIRED, 'Shop locale', 'de_DE') @@ -191,7 +179,7 @@ private function addShopOptions() ; } - private function addAdminOptions() + private function addAdminOptions(): void { $this ->addOption('skip-admin-creation', null, InputOption::VALUE_NONE, 'If provided, no admin user will be created.') @@ -205,11 +193,8 @@ private function addAdminOptions() /** * Make sure, that some required fields are available - * - * @param InputInterface $input - * @param IoService $ioService */ - private function askGenericOptions(InputInterface $input, IoService $ioService) + private function askGenericOptions(InputInterface $input, IoService $ioService): void { $required = [ 'admin-username' => 'backend user name', @@ -227,7 +212,7 @@ private function askGenericOptions(InputInterface $input, IoService $ioService) } // else: check if the option is configured via config - if (isset($config['ShopConfig']) && isset($config['ShopConfig'][$field])) { + if (isset($config['ShopConfig'], $config['ShopConfig'][$field])) { $input->setOption($field, $config['ShopConfig'][$field]); continue; } @@ -249,13 +234,7 @@ private function askGenericOptions(InputInterface $input, IoService $ioService) } } - /** - * @param InputInterface $input - * @param IoService $ioService - * - * @return string - */ - private function askRelease(InputInterface $input, IoService $ioService) + private function askRelease(InputInterface $input, IoService $ioService): string { $release = $input->getOption('release'); if (!$release) { @@ -270,13 +249,9 @@ private function askRelease(InputInterface $input, IoService $ioService) } /** - * @param InputInterface $input - * @param IoService $ioService - * @param string $suggestion - * - * @return string + * @param string $suggestion */ - private function askInstallationDirectory(InputInterface $input, IoService $ioService, $suggestion) + private function askInstallationDirectory(InputInterface $input, IoService $ioService, $suggestion): string { $installDir = $input->getOption('install-dir'); if (!$installDir) { @@ -293,11 +268,9 @@ private function askInstallationDirectory(InputInterface $input, IoService $ioSe } /** - * @param InputInterface $input - * @param IoService $ioService - * @param string $suggestion + * @param string $suggestion */ - private function askDatabaseName(InputInterface $input, IoService $ioService, $suggestion) + private function askDatabaseName(InputInterface $input, IoService $ioService, $suggestion): void { $databaseName = $input->getOption('db-name'); if (!$databaseName) { @@ -307,11 +280,9 @@ private function askDatabaseName(InputInterface $input, IoService $ioService, $s } /** - * @param InputInterface $input - * @param IoService $ioService - * @param string $suggestion + * @param string $suggestion */ - private function askBasePath(InputInterface $input, IoService $ioService, $suggestion) + private function askBasePath(InputInterface $input, IoService $ioService, $suggestion): void { $basePath = $input->getOption('shop-path'); if (!$basePath) { @@ -321,11 +292,7 @@ private function askBasePath(InputInterface $input, IoService $ioService, $sugge } } - /** - * @param InputInterface $input - * @param IoService $ioService - */ - private function askDatabaseUser(InputInterface $input, IoService $ioService) + private function askDatabaseUser(InputInterface $input, IoService $ioService): void { $databaseUser = $input->getOption('db-user'); if (!$databaseUser) { @@ -334,11 +301,7 @@ private function askDatabaseUser(InputInterface $input, IoService $ioService) } } - /** - * @param InputInterface $input - * @param IoService $ioService - */ - private function askDatabasePassword(InputInterface $input, IoService $ioService) + private function askDatabasePassword(InputInterface $input, IoService $ioService): void { $databasePassword = $input->getOption('db-password'); if (!$databasePassword) { diff --git a/src/Extensions/Shopware/Install/Command/ShopwareInstallVcsCommand.php b/src/Extensions/Shopware/Install/Command/ShopwareInstallVcsCommand.php index 98936d2b..c9d04458 100644 --- a/src/Extensions/Shopware/Install/Command/ShopwareInstallVcsCommand.php +++ b/src/Extensions/Shopware/Install/Command/ShopwareInstallVcsCommand.php @@ -8,6 +8,7 @@ namespace Shopware\Install\Command; +use Shopware\Install\Services\Install\Vcs; use ShopwareCli\Command\BaseCommand; use ShopwareCli\Services\IoService; use Symfony\Component\Console\Input\InputInterface; @@ -16,15 +17,11 @@ class ShopwareInstallVcsCommand extends BaseCommand { - const MAIN_BRANCH = '5.6'; + private const MAIN_BRANCH = '5.6'; - /** - * @param InputInterface $input - * @param OutputInterface $output - */ public function interact(InputInterface $input, OutputInterface $output) { - /** @var $ioService IoService */ + /** @var IoService $ioService */ $ioService = $this->container->get('io_service'); $branch = $this->askBranch($input, $ioService); @@ -43,10 +40,8 @@ public function interact(InputInterface $input, OutputInterface $output) * @param string $path * * @throws \RuntimeException - * - * @return string */ - public function validateInstallDir($path) + public function validateInstallDir($path): string { if (is_dir($path)) { throw new \RuntimeException("Path '{$path}'' is not empty"); @@ -100,7 +95,7 @@ protected function configure() 'If set, the demo data will not be installed' ) ->setHelp( -<<%command.name% sets up shopware EOF ); @@ -111,7 +106,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - /** @var \Shopware\Install\Services\Install\Vcs $installService */ + /** @var Vcs $installService */ $installService = $this->container->get('shopware_vcs_install_service'); $installService->installShopware( @@ -128,10 +123,8 @@ protected function execute(InputInterface $input, OutputInterface $output) * Try to guess a proper name (swTICKETNUMBER) from the branch name * * @param string $branch - * - * @return string */ - private function suggestNameFromBranch($branch) + private function suggestNameFromBranch($branch): string { $result = []; $pattern = '#sw-(?P.+?)/(?P.+?)/.*#i'; @@ -145,13 +138,9 @@ private function suggestNameFromBranch($branch) } /** - * @param InputInterface $input - * @param IoService $ioService - * @param string $suggestion - * - * @return string + * @param string $suggestion */ - private function askInstallationDir(InputInterface $input, IoService $ioService, $suggestion) + private function askInstallationDir(InputInterface $input, IoService $ioService, $suggestion): string { $installDir = $input->getOption('installDir'); if (!$installDir) { @@ -168,11 +157,9 @@ private function askInstallationDir(InputInterface $input, IoService $ioService, } /** - * @param InputInterface $input - * @param IoService $ioService - * @param string $suggestion + * @param string $suggestion */ - private function askDatabaseName(InputInterface $input, IoService $ioService, $suggestion) + private function askDatabaseName(InputInterface $input, IoService $ioService, $suggestion): void { $databaseName = $input->getOption('databaseName'); if (!$databaseName) { @@ -182,11 +169,9 @@ private function askDatabaseName(InputInterface $input, IoService $ioService, $s } /** - * @param InputInterface $input - * @param IoService $ioService - * @param string $suggestion + * @param string $suggestion */ - private function askBasePath(InputInterface $input, IoService $ioService, $suggestion) + private function askBasePath(InputInterface $input, IoService $ioService, $suggestion): void { $basePath = $input->getOption('basePath'); if (!$basePath) { @@ -195,13 +180,7 @@ private function askBasePath(InputInterface $input, IoService $ioService, $sugge } } - /** - * @param InputInterface $input - * @param IoService $ioService - * - * @return string - */ - private function askBranch(InputInterface $input, IoService $ioService) + private function askBranch(InputInterface $input, IoService $ioService): string { $branch = $input->getOption('branch'); if (!$branch) { diff --git a/src/Extensions/Shopware/Install/Services/Checkout.php b/src/Extensions/Shopware/Install/Services/Checkout.php index 424b05f8..563b6cc4 100644 --- a/src/Extensions/Shopware/Install/Services/Checkout.php +++ b/src/Extensions/Shopware/Install/Services/Checkout.php @@ -13,8 +13,6 @@ /** * The checkout service will checkout a given repo with a given branch to a given destination - * - * Class Checkout */ class Checkout { @@ -28,10 +26,6 @@ class Checkout */ private $gitUtil; - /** - * @param GitUtil $gitUtil - * @param IoService $ioService - */ public function __construct(GitUtil $gitUtil, IoService $ioService) { $this->ioService = $ioService; @@ -43,7 +37,7 @@ public function __construct(GitUtil $gitUtil, IoService $ioService) * @param string $branch * @param string $destination */ - public function checkout($repo, $branch, $destination) + public function checkout($repo, $branch, $destination): void { $this->ioService->writeln("Checkout out $repo to $destination"); diff --git a/src/Extensions/Shopware/Install/Services/ConfigWriter.php b/src/Extensions/Shopware/Install/Services/ConfigWriter.php index 17c9e3a1..5997f586 100644 --- a/src/Extensions/Shopware/Install/Services/ConfigWriter.php +++ b/src/Extensions/Shopware/Install/Services/ConfigWriter.php @@ -12,8 +12,6 @@ /** * The config writer is responsible for writing build.properties and config.php configuration files - * - * Class ConfigWriter */ class ConfigWriter { @@ -41,8 +39,9 @@ class ConfigWriter db.port = %s EOF; + /** - * @var \ShopwareCli\Services\IoService + * @var IoService */ private $ioService; @@ -51,7 +50,7 @@ public function __construct(IoService $ioService) $this->ioService = $ioService; } - public function writeConfigPhp($installDir, $user, $password, $name, $host, $port = 3306) + public function writeConfigPhp($installDir, $user, $password, $name, $host, $port = 3306): void { $this->ioService->writeln('Writing config.php'); @@ -60,7 +59,7 @@ public function writeConfigPhp($installDir, $user, $password, $name, $host, $por file_put_contents($installDir . '/config.php', $config); } - public function writeBuildProperties($installDir, $shopHost, $shopPath, $dbUser, $dbPassword, $dbName, $dbHost, $port = 3306) + public function writeBuildProperties($installDir, $shopHost, $shopPath, $dbUser, $dbPassword, $dbName, $dbHost, $port = 3306): void { $this->ioService->writeln('Writing build.properties'); diff --git a/src/Extensions/Shopware/Install/Services/Database.php b/src/Extensions/Shopware/Install/Services/Database.php index 1d41c9f7..1b193e5f 100644 --- a/src/Extensions/Shopware/Install/Services/Database.php +++ b/src/Extensions/Shopware/Install/Services/Database.php @@ -10,27 +10,19 @@ use ShopwareCli\Services\IoService; use ShopwareCli\Services\ProcessExecutor; -use ShopwareCli\Utilities; /** * Sets up the database by creating the database itself and running the build scripts to populate the database - * - * Class Database */ class Database { - /** - * @var Utilities - */ - private $utilities; - /** * @var \PDO */ private $connection; /** - * @var \ShopwareCli\Services\IoService + * @var IoService */ private $ioService; @@ -39,38 +31,32 @@ class Database */ private $processExecutor; - /** - * @param Utilities $utilities - * @param IoService $ioService - * @param ProcessExecutor $processExecutor - */ - public function __construct(Utilities $utilities, IoService $ioService, ProcessExecutor $processExecutor) + public function __construct(IoService $ioService, ProcessExecutor $processExecutor) { - $this->utilities = $utilities; $this->ioService = $ioService; $this->processExecutor = $processExecutor; } - public function setup($user, $password, $name, $host, $port = 3306) + public function setup($user, $password, $name, $host, $port = 3306): void { $this->ioService->writeln("Creating database $name"); - $this->createConnection($host, $user, $password, $port)->query("CREATE DATABASE IF NOT EXISTS `{$name}`;"); - $this->getConnection()->query("use `{$name}`;"); + $this->createConnection($host, $user, $password, $port)->exec("CREATE DATABASE IF NOT EXISTS `{$name}`;"); + $this->getConnection()->exec("use `{$name}`;"); } /** * Will install the deltas to setup a shop from a release file. * - * todo: The way the sql deltas are splitted should be improved + * todo: The way the sql deltas are split should be improved * todo: Support the "en" delta * * @param string $installDir */ - public function importReleaseInstallDeltas($installDir) + public function importReleaseInstallDeltas($installDir): void { $this->getConnection()->exec( -<<<'EOF' + <<<'EOF' SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; SET FOREIGN_KEY_CHECKS = 0; @@ -90,7 +76,7 @@ public function importReleaseInstallDeltas($installDir) $this->importBaseDelta($installDir); $this->getConnection()->exec( -<<<'EOF' + <<<'EOF' SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; SET @locale_de_DE = (SELECT id FROM s_core_locales WHERE locale = "de_DE"); @@ -101,10 +87,7 @@ public function importReleaseInstallDeltas($installDir) $this->importSnippetDeltas($installDir); } - /** - * @param $installDir - */ - public function runBuildScripts($installDir) + public function runBuildScripts($installDir): void { $buildXml = $installDir . '/build/build.xml'; if (!file_exists($buildXml)) { @@ -131,10 +114,8 @@ public function runBuildScripts($installDir) * @param string $password * * @throws \RuntimeException - * - * @return bool */ - public function createAdmin($user, $name, $mail, $language, $password) + public function createAdmin($user, $name, $mail, $language, $password): bool { $this->ioService->writeln("Creating admin user $user"); @@ -142,8 +123,7 @@ public function createAdmin($user, $name, $mail, $language, $password) $fetchLanguageId->execute([$language]); $fetchLanguageId = $fetchLanguageId->fetchColumn(); - $authTableVersion = $this->getConnection()->prepare('SELECT COUNT(*) as count FROM s_schema_version WHERE version = 411'); - $authTableVersion->execute(); + $authTableVersion = $this->getConnection()->query('SELECT COUNT(*) as count FROM s_schema_version WHERE version = 411'); $authTableVersion = $authTableVersion->fetchColumn(); if (!$fetchLanguageId) { @@ -151,7 +131,7 @@ public function createAdmin($user, $name, $mail, $language, $password) } // Drop previous inserted admins - $this->getConnection()->query('DELETE FROM s_core_auth'); + $this->getConnection()->exec('DELETE FROM s_core_auth'); // Insert new admin if ($authTableVersion) { @@ -182,7 +162,7 @@ public function createAdmin($user, $name, $mail, $language, $password) return true; } - private function createConnection($host, $username, $password, $port = 3306) + private function createConnection($host, $username, $password, $port = 3306): \PDO { $this->connection = new \PDO("mysql:host={$host};charset=utf8;port={$port}", $username, $password); $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); @@ -190,7 +170,7 @@ private function createConnection($host, $username, $password, $port = 3306) return $this->connection; } - private function getConnection() + private function getConnection(): \PDO { if (!$this->connection) { throw new \RuntimeException('Connection was not created'); @@ -203,10 +183,8 @@ private function getConnection() * Salt password for SW backend user * * @param string $password - * - * @return string */ - private function saltPassword($password) + private function saltPassword($password): string { return md5('A9ASD:_AD!_=%a8nx0asssblPlasS$' . md5($password)); } @@ -216,7 +194,7 @@ private function saltPassword($password) * * @throws \RuntimeException */ - private function importBaseDelta($installDir) + private function importBaseDelta($installDir): void { $this->ioService->writeln('Importing main delta'); @@ -231,9 +209,9 @@ private function importBaseDelta($installDir) $path = file_exists($path42) ? $path42 : $pathLatest; - $deltas = explode(";\n", file_get_contents($path)); - foreach ($deltas as $delta) { - $this->getConnection()->exec($delta); + $connection = $this->getConnection(); + foreach (explode(";\n", file_get_contents($path)) as $delta) { + $connection->exec($delta); } } @@ -242,7 +220,7 @@ private function importBaseDelta($installDir) * * @throws \RuntimeException */ - private function importSnippetDeltas($installDir) + private function importSnippetDeltas($installDir): void { $this->ioService->writeln('Importing snippet delta'); @@ -255,19 +233,19 @@ private function importSnippetDeltas($installDir) return; } - $deltas = explode(";\n", file_get_contents($snippetsFilePath)); - foreach ($deltas as $delta) { - $this->getConnection()->exec($delta); + $connection = $this->getConnection(); + foreach (explode(";\n", file_get_contents($snippetsFilePath)) as $delta) { + $connection->exec($delta); } } - private function getInstallDataFolder($installDir) + private function getInstallDataFolder($installDir): string { $path42 = "{$installDir}/install/assets/sql"; $pathLatest = "{$installDir}/recovery/install/data/sql"; if (!file_exists($path42) && !file_exists($pathLatest)) { - return; + throw new \RuntimeException('install path not found'); } return file_exists($path42) ? $path42 : $pathLatest; diff --git a/src/Extensions/Shopware/Install/Services/Demodata.php b/src/Extensions/Shopware/Install/Services/Demodata.php index 7b6e40d7..05aa4bda 100644 --- a/src/Extensions/Shopware/Install/Services/Demodata.php +++ b/src/Extensions/Shopware/Install/Services/Demodata.php @@ -15,13 +15,11 @@ /** * Handles demo data and licenses - * - * Class Demodata */ class Demodata { /** - * @var \ShopwareCli\Services\PathProvider\PathProvider + * @var PathProvider */ private $pathProvider; @@ -31,9 +29,10 @@ class Demodata private $demoUrl = 'http://releases.s3.shopware.com/test_images_since_5.1.zip'; /** - * @var \ShopwareCli\Services\IoService + * @var IoService */ private $ioService; + /** * @var ShopwareInfo */ @@ -44,12 +43,6 @@ class Demodata */ private $processExecutor; - /** - * @param PathProvider $pathProvider - * @param IoService $ioService - * @param ShopwareInfo $shopwareInfo - * @param ProcessExecutor $processExecutor - */ public function __construct(PathProvider $pathProvider, IoService $ioService, ShopwareInfo $shopwareInfo, ProcessExecutor $processExecutor) { $this->pathProvider = $pathProvider; @@ -61,7 +54,7 @@ public function __construct(PathProvider $pathProvider, IoService $ioService, Sh /** * @param string $installDir */ - public function setup($installDir) + public function setup($installDir): void { $assetDir = $this->pathProvider->getAssetsPath(); if (!is_dir($assetDir) && !mkdir($assetDir) && !is_dir($assetDir)) { diff --git a/src/Extensions/Shopware/Install/Services/Install/Release.php b/src/Extensions/Shopware/Install/Services/Install/Release.php index 8b7ba660..642cc240 100644 --- a/src/Extensions/Shopware/Install/Services/Install/Release.php +++ b/src/Extensions/Shopware/Install/Services/Install/Release.php @@ -21,8 +21,6 @@ /** * This install service will run all steps needed to setup shopware in the correct order - * - * Class Release */ class Release { @@ -57,16 +55,12 @@ class Release private $releaseDownloader; /** - * @var \Shopware\Install\Services\Demodata - */ - private $demodata; - - /** - * @var \ShopwareCli\Services\IoService + * @var IoService */ private $ioService; + /** - * @var \Shopware\Install\Services\PostInstall + * @var PostInstall */ private $postInstall; @@ -75,24 +69,12 @@ class Release */ private $processExecutor; - /** - * @param ReleaseDownloader $releaseDownloader - * @param Config $config - * @param VcsGenerator $vcsGenerator - * @param ConfigWriter $configWriter - * @param Database $database - * @param Demodata $demodata - * @param IoService $ioService - * @param PostInstall $postInstall - * @param ProcessExecutor $processExecutor - */ public function __construct( ReleaseDownloader $releaseDownloader, Config $config, VcsGenerator $vcsGenerator, ConfigWriter $configWriter, Database $database, - Demodata $demodata, IoService $ioService, PostInstall $postInstall, ProcessExecutor $processExecutor @@ -102,16 +84,12 @@ public function __construct( $this->vcsGenerator = $vcsGenerator; $this->configWriter = $configWriter; $this->database = $database; - $this->demodata = $demodata; $this->ioService = $ioService; $this->postInstall = $postInstall; $this->processExecutor = $processExecutor; } - /** - * @param InstallationRequest $request - */ - public function installShopware(InstallationRequest $request) + public function installShopware(InstallationRequest $request): void { if (!$request->getSkipDownload()) { $this->releaseDownloader->downloadRelease($request->getRelease(), $request->getInstallDir()); @@ -141,7 +119,7 @@ public function installShopware(InstallationRequest $request) $this->ioService->writeln('Install completed'); } - private function createDatabase(InstallationRequest $request) + private function createDatabase(InstallationRequest $request): void { $this->database->setup( $request->getDbUser() ?: $this->config['DatabaseConfig']['user'], @@ -152,14 +130,12 @@ private function createDatabase(InstallationRequest $request) ); } - private function generateVcsMapping($installDir) + private function generateVcsMapping($installDir): void { - $this->vcsGenerator->createVcsMapping($installDir, array_map(function ($repo) { - return $repo['destination']; - }, $this->config['ShopwareInstallRepos'])); + $this->vcsGenerator->createVcsMapping($installDir, array_column($this->config['ShopwareInstallRepos'], 'destination')); } - private function runInstaller(InstallationRequest $request) + private function runInstaller(InstallationRequest $request): void { $delegateOptions = [ 'dbHost', 'dbPort', 'dbSocket', 'dbUser', 'dbPassword', 'dbName', @@ -169,7 +145,7 @@ private function runInstaller(InstallationRequest $request) $arguments = []; foreach ($request->all() as $key => $value) { - if (!in_array($key, $delegateOptions) || strlen($value) === 0) { + if (!\in_array($key, $delegateOptions, true) || $value === '') { continue; } @@ -185,17 +161,15 @@ private function runInstaller(InstallationRequest $request) $arguments[] = '--skip-admin-creation'; } - $arguments = join(' ', $arguments); + $arguments = implode(' ', $arguments); $this->processExecutor->execute("php {$request->getAbsoluteInstallDir()}/recovery/install/index.php {$arguments}"); } /** * Write shopware's config.php - * - * @param InstallationRequest $request */ - private function createShopwareConfig(InstallationRequest $request) + private function createShopwareConfig(InstallationRequest $request): void { $this->configWriter->writeConfigPhp( $request->getAbsoluteInstallDir(), @@ -207,15 +181,10 @@ private function createShopwareConfig(InstallationRequest $request) ); } - private function setupDatabase(InstallationRequest $request) + private function setupDatabase(InstallationRequest $request): void { - $this->database->setup( - $request->getDbUser() ?: $this->config['DatabaseConfig']['user'], - $request->getDbPassword() ?: $this->config['DatabaseConfig']['pass'], - $request->getDbName(), - $request->getDbHost() ?: $this->config['DatabaseConfig']['host'], - $request->getDbPort() ?: $this->config['DatabaseConfig']['port'] ?: 3306 - ); + $this->createDatabase($request); + $this->database->importReleaseInstallDeltas($request->getAbsoluteInstallDir()); if ($request->getSkipAdminCreation() !== true) { @@ -234,7 +203,7 @@ private function setupDatabase(InstallationRequest $request) * * @param string $installDir */ - private function lockInstaller($installDir) + private function lockInstaller($installDir): void { if (file_exists($installDir . '/recovery/install/data')) { touch($installDir . '/recovery/install/data/install.lock'); diff --git a/src/Extensions/Shopware/Install/Services/Install/Vcs.php b/src/Extensions/Shopware/Install/Services/Install/Vcs.php index e4527053..cd7f6c24 100644 --- a/src/Extensions/Shopware/Install/Services/Install/Vcs.php +++ b/src/Extensions/Shopware/Install/Services/Install/Vcs.php @@ -19,8 +19,6 @@ /** * This install service will run all steps needed to setup shopware in the correct order - * - * Class Vcs */ class Vcs { @@ -41,10 +39,12 @@ class Vcs /** @var Demodata */ protected $demoData; + /** - * @var \ShopwareCli\Services\IoService + * @var IoService */ private $ioService; + /** * @var PostInstall */ @@ -73,14 +73,11 @@ public function __construct( /** * Runs the steps needed to setup shopware * - * @param $branch * @param string $installDir - * @param $basePath - * @param $database - * @param null $httpUser - * @param bool $noDemoData + * @param null $httpUser + * @param bool $noDemoData */ - public function installShopware($branch, $installDir, $basePath, $database, $httpUser = null, $noDemoData = false) + public function installShopware($branch, $installDir, $basePath, $database, $httpUser = null, $noDemoData = false): void { $this->checkoutRepos($branch, $installDir, $httpUser); @@ -104,7 +101,7 @@ public function installShopware($branch, $installDir, $basePath, $database, $htt $this->ioService->writeln('Install completed'); } - private function getDestinationPath($installDir, $destination) + private function getDestinationPath($installDir, $destination): string { return $installDir . $destination; } @@ -120,7 +117,7 @@ private function checkCoreConfig() { $core = $this->config['ShopwareInstallRepos']['core']; if (!$core['destination'] || !$core['ssh'] || !$core['http']) { - throw new \RuntimeException('You need to have a repo "core" defined in the config.yaml of this plugin'); + throw new \RuntimeException('You need to have a repo "core" defined in the config.yaml of this plugin'); } return $core; @@ -128,13 +125,8 @@ private function checkCoreConfig() /** * Checkout a given branch from a given repo - * - * @param $branch - * @param $installDir - * @param $httpUser - * @param $repo */ - private function checkoutRepo($branch, $installDir, $httpUser, $repo) + private function checkoutRepo($branch, $installDir, $httpUser, $repo): void { $type = $httpUser ? 'http' : 'ssh'; @@ -144,11 +136,9 @@ private function checkoutRepo($branch, $installDir, $httpUser, $repo) /** * Checkout all user defined repositories (except: core) * - * @param $branch * @param string $installDir - * @param $httpUser */ - private function checkoutRepos($branch, $installDir, $httpUser) + private function checkoutRepos($branch, $installDir, $httpUser): void { $core = $this->checkCoreConfig(); @@ -167,21 +157,17 @@ private function checkoutRepos($branch, $installDir, $httpUser) * * @param string $installDir */ - private function generateVcsMapping($installDir) + private function generateVcsMapping($installDir): void { - $this->vcsGenerator->createVcsMapping($installDir, array_map(function ($repo) { - return $repo['destination']; - }, $this->config['ShopwareInstallRepos'])); + $this->vcsGenerator->createVcsMapping($installDir, array_column($this->config['ShopwareInstallRepos'], 'destination')); } /** * Write the build properties file * * @param string $installDir - * @param $basePath - * @param $database */ - private function writeBuildProperties($installDir, $basePath, $database) + private function writeBuildProperties($installDir, $basePath, $database): void { $this->configWriter->writeBuildProperties( $installDir, @@ -199,9 +185,8 @@ private function writeBuildProperties($installDir, $basePath, $database) * Run the database setup tool * * @param string $installDir - * @param $database */ - private function setupDatabase($installDir, $database) + private function setupDatabase($installDir, $database): void { $this->database->setup( $this->config['DatabaseConfig']['user'], diff --git a/src/Extensions/Shopware/Install/Services/Owner.php b/src/Extensions/Shopware/Install/Services/Owner.php index cedcb51f..8fc7aaf2 100644 --- a/src/Extensions/Shopware/Install/Services/Owner.php +++ b/src/Extensions/Shopware/Install/Services/Owner.php @@ -10,19 +10,15 @@ /** * The owner services changes the owning user and group of directories and files - * - * Class Owner */ class Owner { /** * Set the user for a given directory or file * - * @param $path - * @param $user * @param bool $recursive */ - public function setUser($path, $user, $recursive) + public function setUser($path, $user, $recursive): void { chown($path, $user); @@ -38,11 +34,9 @@ public function setUser($path, $user, $recursive) /** * Set the group for a given directory or file * - * @param $path - * @param $group * @param bool $recursive */ - public function setGroup($path, $group, $recursive) + public function setGroup($path, $group, $recursive): void { chgrp($path, $group); @@ -57,15 +51,9 @@ public function setGroup($path, $group, $recursive) /** * Returns a flat iterator for a given directory - * - * @param $path - * - * @return \RecursiveIteratorIterator */ - private function getIterator($path) + private function getIterator($path): \RecursiveIteratorIterator { - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST); - - return $iterator; + return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST); } } diff --git a/src/Extensions/Shopware/Install/Services/PostInstall.php b/src/Extensions/Shopware/Install/Services/PostInstall.php index 63178e64..dff0b307 100644 --- a/src/Extensions/Shopware/Install/Services/PostInstall.php +++ b/src/Extensions/Shopware/Install/Services/PostInstall.php @@ -15,17 +15,20 @@ class PostInstall { /** - * @var \ShopwareCli\Services\ProcessExecutor + * @var ProcessExecutor */ private $processExecutor; + /** * @var Owner */ private $owner; + /** - * @var \ShopwareCli\Config + * @var Config */ private $config; + /** * @var ShopwareInfo */ @@ -39,10 +42,10 @@ public function __construct(ProcessExecutor $processExecutor, Owner $owner, Conf $this->shopwareInfo = $shopwareInfo; } - public function fixShopHost($database) + public function fixShopHost($database): void { $connection = $this->getConnection(); - $connection->query("USE `{$database}`"); + $connection->exec("USE `{$database}`"); $connection->exec('UPDATE s_core_shops SET host = NULL WHERE host = ""'); } @@ -52,7 +55,7 @@ public function fixShopHost($database) * * @param string $directory */ - public function fixPermissions($directory) + public function fixPermissions($directory): void { $command = sprintf('chmod 0777 -R "%s"', $this->shopwareInfo->getLogDir($directory)); $this->processExecutor->execute($command, null, true); @@ -77,10 +80,8 @@ public function fixPermissions($directory) /** * Set up default theme settings - * - * @param $directory */ - public function setupTheme($directory) + public function setupTheme($directory): void { if (!file_exists($directory . '/themes')) { return; @@ -96,18 +97,16 @@ public function setupTheme($directory) /** * Import custom deltas * - * @param $database - * * @throws \RuntimeException */ - public function importCustomDeltas($database) + public function importCustomDeltas($database): void { if (!isset($this->config['CustomDeltas'])) { return; } $connection = $this->getConnection(); - $connection->query("USE `{$database}`"); + $connection->exec("USE `{$database}`"); foreach ($this->config['CustomDeltas'] as $file) { if (!file_exists($file)) { @@ -122,7 +121,7 @@ public function importCustomDeltas($database) * * @param string $path */ - public function runCustomScripts($path) + public function runCustomScripts($path): void { if (!isset($this->config['CustomScripts'])) { return; @@ -135,34 +134,28 @@ public function runCustomScripts($path) /** * set the user for the shopware directory - * - * @param $directory */ - private function setUser($directory) + private function setUser($directory): void { - if (isset($this->config['ChangeOwner'], $this->config['ChangeOwner']['user'])) { + if (isset($this->config['ChangeOwner']['user'])) { $this->owner->setUser($directory, $this->config['ChangeOwner']['user'], true); } } /** * set the group for the shopware directory - * - * @param $directory */ - private function setGroup($directory) + private function setGroup($directory): void { - if (isset($this->config['ChangeOwner'], $this->config['ChangeOwner']['group'])) { + if (isset($this->config['ChangeOwner']['group'])) { $this->owner->setGroup($directory, $this->config['ChangeOwner']['group'], true); } } /** * Get a PDO connection - * - * @return \PDO */ - private function getConnection() + private function getConnection(): \PDO { $username = $this->config['DatabaseConfig']['user']; $password = $this->config['DatabaseConfig']['pass']; diff --git a/src/Extensions/Shopware/Install/Services/ReleaseDownloader.php b/src/Extensions/Shopware/Install/Services/ReleaseDownloader.php index f69d2753..7d1f0c7e 100644 --- a/src/Extensions/Shopware/Install/Services/ReleaseDownloader.php +++ b/src/Extensions/Shopware/Install/Services/ReleaseDownloader.php @@ -16,13 +16,13 @@ class ReleaseDownloader { - const DOWNLOAD_URL_LATEST = 'http://install.s3.shopware.com/'; - const DOWNLOAD_UPDATE_API = 'http://update-api.shopware.com/v1/releases/install'; + private const DOWNLOAD_UPDATE_API = 'http://update-api.shopware.com/v1/releases/install'; /** * @var string */ private $cachePath; + /** * @var IoService */ @@ -37,17 +37,14 @@ class ReleaseDownloader * @var FileDownloader */ private $downloader; + /** * @var OpenSSLVerifier */ private $openSSLVerifier; /** - * @param ProcessExecutor $processExecutor - * @param IoService $ioService - * @param FileDownloader $downloader - * @param OpenSSLVerifier $openSSLVerifier - * @param string $cachePath + * @param string $cachePath */ public function __construct( ProcessExecutor $processExecutor, @@ -69,7 +66,7 @@ public function __construct( * @param string $release * @param string $installDir */ - public function downloadRelease($release, $installDir) + public function downloadRelease($release, $installDir): void { $this->ioService->writeln('Downloading release'); $zipLocation = $this->downloadFromUpdateApi($release); @@ -86,21 +83,17 @@ public function downloadRelease($release, $installDir) * New releases can be downloaded via the update api and provide a sha1 hash * * @param string $release - * - * @return string */ - private function downloadFromUpdateApi($release) + private function downloadFromUpdateApi($release): string { $indexedReleases = $this->getIndexedReleasesList(); - if (array_key_exists($release, $indexedReleases)) { + if (\array_key_exists($release, $indexedReleases)) { $content = $indexedReleases[$release]; + } elseif ($release === 'latest') { + $content = array_shift($indexedReleases); } else { - if ($release == 'latest') { - $content = array_shift($indexedReleases); - } else { - throw new \RuntimeException(sprintf('Could not find release %s', $release)); - } + throw new \RuntimeException(sprintf('Could not find release %s', $release)); } $version = $content['version']; @@ -127,20 +120,16 @@ private function downloadFromUpdateApi($release) /** * Loads a list of the latest releases from the update API * Returns them indexed by the Shopware version (e.g: 5.1.0) - * - * @return array */ - private function getIndexedReleasesList() + private function getIndexedReleasesList(): array { - $client = new Client(); - - $response = $client->get(self::DOWNLOAD_UPDATE_API); + $response = (new Client())->get(self::DOWNLOAD_UPDATE_API); $signature = $response->getHeader('X-Shopware-Signature'); - if ($this->openSSLVerifier->isSystemSupported()) { - if (!$this->openSSLVerifier->isValid($response->getBody(), $signature[0])) { - throw new \RuntimeException('API signature verification failed'); - } + if ($this->openSSLVerifier->isSystemSupported() + && !$this->openSSLVerifier->isValid($response->getBody(), $signature[0]) + ) { + throw new \RuntimeException('API signature verification failed'); } $releases = json_decode($response->getBody(), true); @@ -158,22 +147,16 @@ private function getIndexedReleasesList() /** * Return a generic cache file name for a given release - * - * @param $release - * - * @return string */ - private function getCacheFilePath($release) + private function getCacheFilePath($release): string { return $this->cachePath . "/{$release}.zip"; } /** * Return a temp dir name - * - * @return string */ - private function getTempFile() + private function getTempFile(): string { return sys_get_temp_dir() . '/' . uniqid('release_download', true); } diff --git a/src/Extensions/Shopware/Install/Services/VcsGenerator.php b/src/Extensions/Shopware/Install/Services/VcsGenerator.php index 3244ebef..c2d756f3 100644 --- a/src/Extensions/Shopware/Install/Services/VcsGenerator.php +++ b/src/Extensions/Shopware/Install/Services/VcsGenerator.php @@ -12,8 +12,6 @@ /** * creates the phpstorm vcs mapping file - * - * Class VcsGenerator */ class VcsGenerator { @@ -27,8 +25,9 @@ class VcsGenerator EOF; protected $templateVcsMappingDirectory = ''; + /** - * @var \ShopwareCli\Services\IoService + * @var IoService */ private $ioService; @@ -37,7 +36,7 @@ public function __construct(IoService $ioService) $this->ioService = $ioService; } - public function createVcsMapping($installDir, $paths) + public function createVcsMapping($installDir, $paths): void { $this->ioService->writeln('Generating VCS mapping'); diff --git a/src/Extensions/Shopware/Install/Struct/InstallationRequest.php b/src/Extensions/Shopware/Install/Struct/InstallationRequest.php index 4769b98d..7f5f8aa3 100644 --- a/src/Extensions/Shopware/Install/Struct/InstallationRequest.php +++ b/src/Extensions/Shopware/Install/Struct/InstallationRequest.php @@ -81,209 +81,127 @@ class InstallationRequest extends Struct /** @var string */ private $skipAdminCreation; - /** - * @param array $values - */ - public function __construct(array $values = []) - { - foreach ($values as $name => $value) { - $this->$name = $value; - } - } - public function all() { return get_object_vars($this); } - /** - * @return string - */ - public function getRelease() + public function getRelease(): string { return $this->release; } - /** - * @return string - */ - public function getInstallDir() + public function getInstallDir(): string { return $this->installDir; } - /** - * @return string - */ - public function getOnlyUnpack() + public function getOnlyUnpack(): string { return $this->onlyUnpack; } - /** - * @return string - */ - public function getSkipDownload() + public function getSkipDownload(): string { return $this->skipDownload; } - /** - * @return string - */ - public function getAbsoluteInstallDir() + public function getAbsoluteInstallDir(): string { return realpath($this->installDir); } - /** - * @return string - */ - public function getDbHost() + public function getDbHost(): string { return $this->dbHost; } - /** - * @return string - */ - public function getDbPort() + public function getDbPort(): string { return $this->dbPort; } - /** - * @return string - */ - public function getDbSocket() + public function getDbSocket(): string { return $this->dbSocket; } - /** - * @return string - */ - public function getDbUser() + public function getDbUser(): string { return $this->dbUser; } - /** - * @return string - */ - public function getDbPassword() + public function getDbPassword(): string { return $this->dbPassword; } - /** - * @return string - */ - public function getDbName() + public function getDbName(): string { return $this->dbName; } - /** - * @return string - */ - public function getShopLocale() + public function getShopLocale(): string { return $this->shopLocale; } - /** - * @return string - */ - public function getShopHost() + public function getShopHost(): string { return $this->shopHost; } - /** - * @return string - */ - public function getShopPath() + public function getShopPath(): string { return $this->shopPath; } - /** - * @return string - */ - public function getShopName() + public function getShopName(): string { return $this->shopName; } - /** - * @return string - */ - public function getShopEmail() + public function getShopEmail(): string { return $this->shopEmail; } - /** - * @return string - */ - public function getShopCurrency() + public function getShopCurrency(): string { return $this->shopCurrency; } - /** - * @return string - */ - public function getAdminUsername() + public function getAdminUsername(): string { return $this->adminUsername; } - /** - * @return string - */ - public function getAdminPassword() + public function getAdminPassword(): string { return $this->adminPassword; } - /** - * @return string - */ - public function getAdminEmail() + public function getAdminEmail(): string { return $this->adminEmail; } - /** - * @return string - */ - public function getAdminLocale() + public function getAdminLocale(): string { return $this->adminLocale; } - /** - * @return string - */ - public function getAdminName() + public function getAdminName(): string { return $this->adminName; } - /** - * @return string - */ - public function getNoSkipImport() + public function getNoSkipImport(): string { return $this->noSkipImport; } - /** - * @return string - */ - public function getSkipAdminCreation() + public function getSkipAdminCreation(): string { return $this->skipAdminCreation; } diff --git a/src/Extensions/Shopware/Plugin/Bootstrap.php b/src/Extensions/Shopware/Plugin/Bootstrap.php index 4becc2b8..88a82177 100644 --- a/src/Extensions/Shopware/Plugin/Bootstrap.php +++ b/src/Extensions/Shopware/Plugin/Bootstrap.php @@ -11,6 +11,16 @@ use Shopware\Plugin\Command\InstallCommand; use Shopware\Plugin\Command\ZipCommand; use Shopware\Plugin\Command\ZipLocalCommand; +use Shopware\Plugin\Services\BootstrapInfo; +use Shopware\Plugin\Services\Checkout; +use Shopware\Plugin\Services\ConsoleInteraction\PluginColumnRenderer; +use Shopware\Plugin\Services\ConsoleInteraction\PluginInputVerificator; +use Shopware\Plugin\Services\ConsoleInteraction\PluginOperationManager; +use Shopware\Plugin\Services\Install; +use Shopware\Plugin\Services\PluginProvider; +use Shopware\Plugin\Services\Repositories\DefaultRepositoryFactory; +use Shopware\Plugin\Services\RepositoryManager; +use Shopware\Plugin\Services\Zip; use ShopwareCli\Application\ConsoleAwareExtension; use ShopwareCli\Application\ContainerAwareExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -18,8 +28,6 @@ /** * This plugin will install/setup shopware in a development version - * - * Class Bootstrap */ class Bootstrap implements ContainerAwareExtension, ConsoleAwareExtension { @@ -48,44 +56,44 @@ public function getConsoleCommands() */ private function populateContainer($container) { - $container->register('plugin_column_renderer', 'Shopware\Plugin\Services\ConsoleInteraction\PluginColumnRenderer') + $container->register('plugin_column_renderer', PluginColumnRenderer::class) ->addArgument(new Reference('io_service')) ->addArgument(new Reference('config')); - $container->register('plugin_selector', 'Shopware\Plugin\Services\ConsoleInteraction\PluginInputVerificator') + $container->register('plugin_selector', PluginInputVerificator::class) ->addArgument(new Reference('io_service')) ->addArgument(new Reference('plugin_column_renderer')); - $container->register('plugin_operation_manager', 'Shopware\Plugin\Services\ConsoleInteraction\PluginOperationManager') + $container->register('plugin_operation_manager', PluginOperationManager::class) ->addArgument(new Reference('plugin_provider')) ->addArgument(new Reference('plugin_selector')) ->addArgument(new Reference('io_service')); - $container->register('bootstrap_info', 'Shopware\Plugin\Services\BootstrapInfo'); + $container->register('bootstrap_info', BootstrapInfo::class); - $container->register('install_service', 'Shopware\Plugin\Services\Install') + $container->register('install_service', Install::class) ->addArgument(new Reference('checkout_service')) ->addArgument(new Reference('io_service')) ->addArgument(new Reference('process_executor')); - $container->register('zip_service', 'Shopware\Plugin\Services\Zip') + $container->register('zip_service', Zip::class) ->addArgument(new Reference('checkout_service')) ->addArgument(new Reference('utilities')) ->addArgument(new Reference('process_executor')); - $container->register('checkout_service', 'Shopware\Plugin\Services\Checkout') + $container->register('checkout_service', Checkout::class) ->addArgument(new Reference('utilities')) ->addArgument(new Reference('git_util')) ->addArgument(new Reference('io_service')); - $container->register('default_repository_factory', 'Shopware\Plugin\Services\Repositories\DefaultRepositoryFactory') + $container->register('default_repository_factory', DefaultRepositoryFactory::class) ->addArgument(new Reference('service_container')); - $container->register('repository_manager', 'Shopware\Plugin\Services\RepositoryManager') + $container->register('repository_manager', RepositoryManager::class) ->addArgument(new Reference('extension_manager')) ->addArgument(new Reference('default_repository_factory')); - $container->register('plugin_provider', 'Shopware\Plugin\Services\PluginProvider') + $container->register('plugin_provider', PluginProvider::class) ->addArgument(new Reference('config')); } } diff --git a/src/Extensions/Shopware/Plugin/Command/InstallCommand.php b/src/Extensions/Shopware/Plugin/Command/InstallCommand.php index ec791875..f95d7c3f 100644 --- a/src/Extensions/Shopware/Plugin/Command/InstallCommand.php +++ b/src/Extensions/Shopware/Plugin/Command/InstallCommand.php @@ -11,7 +11,6 @@ use Shopware\Plugin\Services\ConsoleInteraction\PluginColumnRenderer; use Shopware\Plugin\Services\ConsoleInteraction\PluginOperationManager; use Shopware\Plugin\Services\Install; -use Shopware\Plugin\Struct\Plugin; use ShopwareCli\Command\BaseCommand; use ShopwareCli\Services\GitUtil; use ShopwareCli\Services\IoService; @@ -24,8 +23,6 @@ /** * Install a plugin - * - * Class InstallCommand */ class InstallCommand extends BaseCommand { @@ -35,10 +32,9 @@ class InstallCommand extends BaseCommand private $shopwarePath; /** - * @param $plugin - * @param $params + * @param mixed $params */ - public function doInstall($plugin, &$params) + public function doInstall($plugin, &$params): void { if ($params['checkout']) { $this->checkout($plugin, $params); @@ -135,20 +131,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $interactionManager->operationLoop([$this, 'doInstall'], $params); } - /** - * @return string - */ - private function getShopwarePath() + private function getShopwarePath(): string { $this->getUtilities()->changeDir($this->shopwarePath); return $this->shopwarePath; } - /** - * @return bool - */ - private function askActivatePluginQuestion() + private function askActivatePluginQuestion(): bool { $question = new ConfirmationQuestion( 'Activate plugins after checkout? [Y/n] ', @@ -159,10 +149,9 @@ private function askActivatePluginQuestion() } /** - * @param $plugin - * @param $params + * @param mixed $params */ - private function install($plugin, &$params) + private function install($plugin, &$params): void { if (!isset($params['activate'])) { $params['activate'] = $this->askActivatePluginQuestion(); @@ -180,10 +169,10 @@ private function install($plugin, &$params) } /** - * @param $plugin Plugin - * @param $params + * @param mixed $plugin Plugin + * @param mixed $params */ - private function checkout($plugin, &$params) + private function checkout($plugin, &$params): void { $url = $params['useHttp'] ? $plugin->cloneUrlHttp : $plugin->cloneUrlSsh; @@ -204,18 +193,12 @@ private function checkout($plugin, &$params) ); } - /** - * @return IoService - */ - private function getIOService() + private function getIOService(): IoService { return $this->container->get('io_service'); } - /** - * @return Utilities - */ - private function getUtilities() + private function getUtilities(): Utilities { return $this->container->get('utilities'); } diff --git a/src/Extensions/Shopware/Plugin/Command/ZipCommand.php b/src/Extensions/Shopware/Plugin/Command/ZipCommand.php index 7860d9fe..7fbd8e0c 100644 --- a/src/Extensions/Shopware/Plugin/Command/ZipCommand.php +++ b/src/Extensions/Shopware/Plugin/Command/ZipCommand.php @@ -16,12 +16,11 @@ /** * Zip a plugin - * - * Class ZipCommand */ class ZipCommand extends BaseCommand { protected $utilities; + protected $zipDir; public function doZip($plugin, $params) diff --git a/src/Extensions/Shopware/Plugin/Command/ZipLocalCommand.php b/src/Extensions/Shopware/Plugin/Command/ZipLocalCommand.php index 65137b19..5f281cd6 100644 --- a/src/Extensions/Shopware/Plugin/Command/ZipLocalCommand.php +++ b/src/Extensions/Shopware/Plugin/Command/ZipLocalCommand.php @@ -16,18 +16,17 @@ /** * Zip a plugin - * - * Class ZipCommand */ class ZipLocalCommand extends BaseCommand { protected $utilities; + protected $zipDir; /** * @param string $dir */ - public function validatePluginDir($dir) + public function validatePluginDir($dir): void { $fileName = basename($dir); @@ -39,7 +38,7 @@ public function validatePluginDir($dir) /** * @param string $pluginDirectory */ - public function doZip($pluginDirectory) + public function doZip($pluginDirectory): void { if (file_exists($pluginDirectory . '/Bootstrap.php')) { /** @var PluginBootstrap $info */ diff --git a/src/Extensions/Shopware/Plugin/Services/BootstrapInfo.php b/src/Extensions/Shopware/Plugin/Services/BootstrapInfo.php index 40268bcb..b1536692 100644 --- a/src/Extensions/Shopware/Plugin/Services/BootstrapInfo.php +++ b/src/Extensions/Shopware/Plugin/Services/BootstrapInfo.php @@ -12,23 +12,17 @@ /** * Extract info from a shopware plugin bootstrap - * - * Class BootstrapInfo */ class BootstrapInfo { /** * Analyze a bootstrap file and return a PluginBootstrap struct - * - * @param $bootstrapFile - * - * @return PluginBootstrap */ - public function analyze($bootstrapFile) + public function analyze($bootstrapFile): PluginBootstrap { $content = file_get_contents($bootstrapFile); - list($namespace, $name) = $this->analyzeClass($content); + [$namespace, $name] = $this->analyzeClass($content); $info = new PluginBootstrap(); $info->module = $namespace; @@ -46,7 +40,7 @@ public function analyze($bootstrapFile) * * @return string[] */ - private function analyzeClass($content) + private function analyzeClass($content): array { $pattern = '#.*Shopware_Plugins_(?P[a-zA-Z0-9]+)_(?P[a-zA-Z0-9]+)_Bootstrap.*#'; $matches = []; diff --git a/src/Extensions/Shopware/Plugin/Services/Checkout.php b/src/Extensions/Shopware/Plugin/Services/Checkout.php index 01401506..cabceee3 100644 --- a/src/Extensions/Shopware/Plugin/Services/Checkout.php +++ b/src/Extensions/Shopware/Plugin/Services/Checkout.php @@ -15,13 +15,11 @@ /** * Checkouts a given plugin - * - * Class Checkout */ class Checkout { /** - * @var \ShopwareCli\Utilities + * @var Utilities */ protected $utilities; @@ -31,15 +29,10 @@ class Checkout private $ioService; /** - * @var \ShopwareCli\Services\GitUtil + * @var GitUtil */ private $gitUtil; - /** - * @param Utilities $utilities - * @param GitUtil $gitUtil - * @param IoService $ioService - */ public function __construct(Utilities $utilities, GitUtil $gitUtil, IoService $ioService) { $this->utilities = $utilities; @@ -48,12 +41,11 @@ public function __construct(Utilities $utilities, GitUtil $gitUtil, IoService $i } /** - * @param Plugin $plugin * @param string $path * @param string $branch * @param bool $useHttp */ - public function checkout(Plugin $plugin, $path, $branch = null, $useHttp = false) + public function checkout(Plugin $plugin, $path, $branch = null, $useHttp = false): void { if ($useHttp) { $cloneUrl = $plugin->cloneUrlHttp; @@ -84,7 +76,7 @@ public function checkout(Plugin $plugin, $path, $branch = null, $useHttp = false * @param string $absPath * @param string $pluginName */ - private function updatePlugin($branch, $absPath, $pluginName) + private function updatePlugin($branch, $absPath, $pluginName): void { $this->ioService->writeln('Plugin is already installed'); $this->utilities->changeDir($absPath); @@ -122,7 +114,7 @@ private function updatePlugin($branch, $absPath, $pluginName) * @param string $absPath * @param string $pluginName */ - private function installPlugin($branch, $cloneUrl, $absPath, $pluginName) + private function installPlugin($branch, $cloneUrl, $absPath, $pluginName): void { $this->gitUtil->run("clone --progress $cloneUrl $absPath"); if ($branch) { diff --git a/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginColumnRenderer.php b/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginColumnRenderer.php index c50ed583..9e8980bf 100644 --- a/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginColumnRenderer.php +++ b/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginColumnRenderer.php @@ -15,8 +15,6 @@ /** * Will render a given list of plugins in a two or three column layout, add numbers and a simple legend - * - * Class PluginColumnRenderer */ class PluginColumnRenderer { @@ -35,10 +33,6 @@ class PluginColumnRenderer */ private $ioService; - /** - * @param IoService $ioService - * @param Config $config - */ public function __construct(IoService $ioService, Config $config) { $this->config = $config; @@ -92,12 +86,10 @@ private function createDisplayPlugins($plugins): array /** * @param DisplayPlugin[] $plugins * @param int $columns - * - * @return array */ private function createPluginColumns($plugins, $columns): array { - $length = count($plugins); + $length = \count($plugins); $pluginColumns = []; $pluginsPerColumn = ceil($length / $columns); @@ -106,7 +98,7 @@ private function createPluginColumns($plugins, $columns): array $sliceOffset = $pluginsPerColumn * $i; $sliceLength = $pluginsPerColumn * ($i + 1); - $pluginColumns[$i] = array_slice($plugins, $sliceOffset, $sliceLength); + $pluginColumns[$i] = \array_slice($plugins, $sliceOffset, $sliceLength); } return $pluginColumns; @@ -117,8 +109,8 @@ private function createPluginColumns($plugins, $columns): array */ private function printColumns($pluginColumns): void { - $columnCount = count($pluginColumns); - $rowCount = count($pluginColumns[0]) - 1; + $columnCount = \count($pluginColumns); + $rowCount = \count($pluginColumns[0]) - 1; foreach (range(0, $rowCount) as $row) { $currentRow = []; @@ -187,10 +179,7 @@ private function printLegend($plugins): void /** * Modifies the baseMask for a plugin by setting the repository colors * - * @param DisplayPlugin $plugin - * @param string $baseMask - * - * @return string + * @param string $baseMask */ private function getMaskForPlugin(DisplayPlugin $plugin, $baseMask): string { @@ -205,11 +194,6 @@ private function getMaskForPlugin(DisplayPlugin $plugin, $baseMask): string return $baseMask; } - /** - * @param DisplayPlugin $plugin - * - * @return string - */ private function formatPlugin(DisplayPlugin $plugin): string { return $this->formatModuleName($plugin) . '/' . $plugin->name; diff --git a/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginInputVerificator.php b/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginInputVerificator.php index bdc870b0..608425f3 100644 --- a/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginInputVerificator.php +++ b/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginInputVerificator.php @@ -16,8 +16,6 @@ /** * Will trigger the PluginColumnRenderer until an valid answer was made. Will then return the corresponding plugin/answer - * - * Class PluginInputVerificator */ class PluginInputVerificator { @@ -41,10 +39,6 @@ class PluginInputVerificator */ private $ioService; - /** - * @param IoService $ioService - * @param PluginColumnRenderer $outputRenderer - */ public function __construct(IoService $ioService, PluginColumnRenderer $outputRenderer) { $this->outputRenderer = $outputRenderer; @@ -58,7 +52,7 @@ public function __construct(IoService $ioService, PluginColumnRenderer $outputRe * @param Plugin[] $plugins * @param string[] $allowedAnswers * - * @return string + * @return string|Plugin */ public function selectPlugin($plugins, array $allowedAnswers = ['all']) { @@ -67,24 +61,24 @@ public function selectPlugin($plugins, array $allowedAnswers = ['all']) $this->outputRenderer->show($plugins); $question = new Question( - $this->formatQuestion(count($plugins), $allowedAnswers) + $this->formatQuestion(\count($plugins), $allowedAnswers) ); $response = $this->ioService->ask($question); - if (in_array($response, $allowedAnswers, true)) { + if (\in_array($response, $allowedAnswers, true)) { return $response; } if ($range = $this->getPluginRange($response)) { return array_filter( array_map( - function ($number) use ($plugins) { + static function ($number) use ($plugins) { return isset($plugins[$number - 1]) ? $plugins[$number - 1] : null; }, $range ), - function ($plugin) { + static function ($plugin) { return $plugin; } ); @@ -104,10 +98,8 @@ function ($plugin) { * * @param int $count * @param string[] $allowedAnswers - * - * @return string */ - private function formatQuestion($count, $allowedAnswers) + private function formatQuestion($count, $allowedAnswers): string { $template = "\nWhich plugin(s) do you want to install? Type 1-{$count} %s "; @@ -115,12 +107,12 @@ private function formatQuestion($count, $allowedAnswers) return sprintf($template, ''); } - if (count($allowedAnswers) === 1) { + if (\count($allowedAnswers) === 1) { return sprintf($template, sprintf('or "%s"', $allowedAnswers[0])); } $allowedAnswers = array_map( - function ($option) { + static function ($option) { return sprintf('"%s"', $option); }, $allowedAnswers @@ -145,7 +137,7 @@ private function getPluginRange($userInput) preg_match($pattern, $userInput, $matches); - if (empty($matches) || !isset($matches['from']) || !isset($matches['to'])) { + if (!isset($matches['from'], $matches['to']) || empty($matches)) { return false; } diff --git a/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginOperationManager.php b/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginOperationManager.php index e7b8de41..e3c7de6a 100644 --- a/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginOperationManager.php +++ b/src/Extensions/Shopware/Plugin/Services/ConsoleInteraction/PluginOperationManager.php @@ -20,8 +20,6 @@ * selects 'all' or 'exit' (operationLoop). * * Works via callback you can pass in order to get notified about the selected plugins - * - * Class PluginOperationManager */ class PluginOperationManager { @@ -45,11 +43,6 @@ class PluginOperationManager */ private $ioService; - /** - * @param PluginProvider $pluginProvider - * @param PluginInputVerificator $pluginSelector - * @param IoService $ioService - */ public function __construct( PluginProvider $pluginProvider, PluginInputVerificator $pluginSelector, @@ -68,15 +61,15 @@ public function __construct( * @param callable $callback * @param array $params */ - public function searchAndOperate($names, $callback, $params) + public function searchAndOperate($names, $callback, $params): void { foreach ($names as $name) { $plugins = $this->pluginProvider->getPluginByName($name); - $count = count($plugins); + $count = \count($plugins); if ($count === 0) { $plugins = $this->pluginProvider->getPluginsByRepositoryName($name); - $count = count($plugins); + $count = \count($plugins); } if ($count === 0) { $this->ioService->writeln("\nCould not find a plugin named '{$name}'"); @@ -92,7 +85,7 @@ public function searchAndOperate($names, $callback, $params) return; } - $response = $this->pluginSelector->selectPlugin($plugins, ['all']); + $response = $this->pluginSelector->selectPlugin($plugins); $plugins = $this->getPluginsFromResponse($response, $plugins); foreach ($plugins as $plugin) { @@ -107,7 +100,7 @@ public function searchAndOperate($names, $callback, $params) * @param callable $callback * @param array $params */ - public function operationLoop($callback, $params) + public function operationLoop($callback, $params): void { $plugins = $this->pluginProvider->getPlugins(); while (true) { @@ -119,8 +112,7 @@ public function operationLoop($callback, $params) $this->ioService->cls(); - $responsePlugins = $this->getPluginsFromResponse($response, $plugins); - foreach ($responsePlugins as $plugin) { + foreach ($this->getPluginsFromResponse($response, $plugins) as $plugin) { $this->executeMethodCallback($plugin, $callback, $params); } $this->ioService->ask("\nDone, hit enter to continue."); @@ -133,31 +125,30 @@ public function operationLoop($callback, $params) * @param callable $callback * @param array $params */ - private function executeMethodCallback($subject, $callback, $params) + private function executeMethodCallback($subject, $callback, $params): void { - call_user_func_array($callback, [$subject, &$params]); + \call_user_func_array($callback, [$subject, &$params]); } /** * Prepares a response and returns an array of plugin objects * - * @param $response * @param Plugin[] $plugins - * - * @return array */ - private function getPluginsFromResponse($response, $plugins) + private function getPluginsFromResponse($response, $plugins): array { if ($response instanceof Plugin) { return [$response]; } - if (is_array($response)) { + if (\is_array($response)) { return $response; } if ($response === 'all') { return $plugins; } + + return []; } } diff --git a/src/Extensions/Shopware/Plugin/Services/Install.php b/src/Extensions/Shopware/Plugin/Services/Install.php index 867a1099..d56228b1 100644 --- a/src/Extensions/Shopware/Plugin/Services/Install.php +++ b/src/Extensions/Shopware/Plugin/Services/Install.php @@ -32,11 +32,6 @@ class Install */ private $processExecutor; - /** - * @param Checkout $checkout - * @param IoService $ioService - * @param ProcessExecutor $processExecutor - */ public function __construct(Checkout $checkout, IoService $ioService, ProcessExecutor $processExecutor) { $this->checkout = $checkout; @@ -45,7 +40,6 @@ public function __construct(Checkout $checkout, IoService $ioService, ProcessExe } /** - * @param Plugin $plugin * @param string $shopwarePath * @param bool $inputActivate * @param string $branch @@ -78,10 +72,9 @@ public function install(Plugin $plugin, $shopwarePath, $inputActivate = false, $ } /** - * @param Plugin $plugin * @param string $shopwarePath */ - private function addPluginVcsMapping(Plugin $plugin, $shopwarePath) + private function addPluginVcsMapping(Plugin $plugin, $shopwarePath): void { $vcsMappingFile = $shopwarePath . '/.idea/vcs.xml'; $pluginDestPath = $plugin->module . '/' . $plugin->name; @@ -115,12 +108,8 @@ private function addPluginVcsMapping(Plugin $plugin, $shopwarePath) /** * Normalize directory strings to make them comparable - * - * @param $string - * - * @return string */ - private function normalize($string) + private function normalize($string): string { return strtolower(str_replace(['/', '\\'], '-', $string)); } @@ -128,7 +117,7 @@ private function normalize($string) /** * @param string $pluginPath */ - private function installGitHook($pluginPath) + private function installGitHook($pluginPath): void { $installShFile = $pluginPath . '/.githooks/install_hooks.sh'; diff --git a/src/Extensions/Shopware/Plugin/Services/PluginFactory.php b/src/Extensions/Shopware/Plugin/Services/PluginFactory.php index 12f63f32..c31c0795 100644 --- a/src/Extensions/Shopware/Plugin/Services/PluginFactory.php +++ b/src/Extensions/Shopware/Plugin/Services/PluginFactory.php @@ -12,8 +12,6 @@ /** * Create a plugin struct from the passed data - * - * Class PluginFactory */ class PluginFactory { @@ -24,11 +22,8 @@ class PluginFactory * @param string $sshUrl * @param string $httpUrl * @param string $repoName - * @param $repoType - * - * @return Plugin */ - public static function getPlugin($name, $sshUrl, $httpUrl, $repoName, $repoType = null) + public static function getPlugin($name, $sshUrl, $httpUrl, $repoName, $repoType = null): Plugin { $plugin = new Plugin(); @@ -45,9 +40,8 @@ public static function getPlugin($name, $sshUrl, $httpUrl, $repoName, $repoType /** * @param string $name - * @param Plugin $plugin */ - private static function setPluginModuleFromName($name, Plugin $plugin) + private static function setPluginModuleFromName($name, Plugin $plugin): void { if (stripos($name, 'frontend') === 0) { $plugin->module = 'Frontend'; diff --git a/src/Extensions/Shopware/Plugin/Services/PluginProvider.php b/src/Extensions/Shopware/Plugin/Services/PluginProvider.php index 3299802c..f45c0166 100644 --- a/src/Extensions/Shopware/Plugin/Services/PluginProvider.php +++ b/src/Extensions/Shopware/Plugin/Services/PluginProvider.php @@ -13,9 +13,6 @@ use Shopware\Plugin\Struct\Plugin; use ShopwareCli\Config; -/** - * Class PluginProvider - */ class PluginProvider { /** @@ -28,24 +25,12 @@ class PluginProvider */ protected $sortBy; - /** - * @var \ShopwareCli\Config - */ - private $config; - - /** - * @param Config $config - */ public function __construct(Config $config) { - $this->config = $config; $this->sortBy = $config['general']['sortBy']; } - /** - * @param $repositories - */ - public function setRepositories($repositories) + public function setRepositories($repositories): void { $this->repositories = $repositories; } @@ -53,8 +38,8 @@ public function setRepositories($repositories) /** * Query all plugin repositories for plugins named like $name * - * @param string $name string Name to search for - * @param $exact boolean Whether to search for exact match or not + * @param string $name string Name to search for + * @param mixed $exact boolean Whether to search for exact match or not * * @return Plugin[] */ @@ -75,7 +60,7 @@ public function getPluginByName($name, $exact = false) * * @return Plugin[] */ - public function getPluginsByRepositoryName($name) + public function getPluginsByRepositoryName($name): array { $result = []; foreach ($this->repositories as $repo) { @@ -92,7 +77,7 @@ public function getPluginsByRepositoryName($name) * * @return Plugin[] */ - public function getPlugins() + public function getPlugins(): array { $result = []; foreach ($this->repositories as $repo) { @@ -105,25 +90,23 @@ public function getPlugins() /** * Sort a given array of plugins by the configured properties * - * @param $plugins - * * @return Plugin[] */ - protected function sortPlugins($plugins) + protected function sortPlugins($plugins): array { switch ($this->sortBy) { case 'repository': - usort($plugins, function ($a, $b) { + usort($plugins, static function ($a, $b) { return $a->repository . $a->name > $b->repository . $b->name; }); break; case 'module': - usort($plugins, function ($a, $b) { + usort($plugins, static function ($a, $b) { return $a->module . $a->name > $b->module . $b->name; }); break; default: - usort($plugins, function ($a, $b) { + usort($plugins, static function ($a, $b) { return $a->name > $b->name; }); break; diff --git a/src/Extensions/Shopware/Plugin/Services/Repositories/BaseRepository.php b/src/Extensions/Shopware/Plugin/Services/Repositories/BaseRepository.php index b6934b00..b014d715 100644 --- a/src/Extensions/Shopware/Plugin/Services/Repositories/BaseRepository.php +++ b/src/Extensions/Shopware/Plugin/Services/Repositories/BaseRepository.php @@ -14,8 +14,6 @@ /** * Base repository class providing a constructor for injection and a convenient access to the PluginFactory - * - * Class BaseRepository */ abstract class BaseRepository implements RepositoryInterface { @@ -34,6 +32,7 @@ abstract class BaseRepository implements RepositoryInterface */ protected $useHttp ; + /** * @var RestInterface */ @@ -45,8 +44,6 @@ abstract class BaseRepository implements RepositoryInterface protected $color; /** - * @param $repository - * @param $name * @param RestInterface $restService * @param null $color */ @@ -62,22 +59,17 @@ public function __construct($repository, $name, RestInterface $restService = nul * @param string $sshUrl * @param string $httpUrl * @param string $name - * - * @return Plugin */ - public function createPlugin($sshUrl, $httpUrl, $name) + public function createPlugin($sshUrl, $httpUrl, $name): Plugin { - $type = array_slice(explode('\\', get_class($this)), -1); + $type = \array_slice(explode('\\', \get_class($this)), -1); $type = $type[0]; $name = str_replace(' ', '', $name); return PluginFactory::getPlugin($name, $sshUrl, $httpUrl, $this->name, $type); } - /** - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } @@ -88,13 +80,10 @@ public function getName() * @param string $searched * @param string $actual * @param bool $exact - * - * @return bool */ - protected function doesMatch($actual, $searched, $exact = false) + protected function doesMatch($actual, $searched, $exact = false): bool { - return - !$exact && stripos($actual, $searched) !== false + return !$exact && stripos($actual, $searched) !== false || $exact && $searched == $actual ; } diff --git a/src/Extensions/Shopware/Plugin/Services/Repositories/DefaultRepositoryFactory.php b/src/Extensions/Shopware/Plugin/Services/Repositories/DefaultRepositoryFactory.php index 13b83dbf..6b906fd8 100644 --- a/src/Extensions/Shopware/Plugin/Services/Repositories/DefaultRepositoryFactory.php +++ b/src/Extensions/Shopware/Plugin/Services/Repositories/DefaultRepositoryFactory.php @@ -9,13 +9,12 @@ namespace Shopware\Plugin\Services\Repositories; use ShopwareCli\Config; +use ShopwareCli\Services\Rest\RestInterface; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerAwareInterface; /** * Step through the config file, lookup needed repositories and create them - * - * Class DefaultRepositoryFactory */ class DefaultRepositoryFactory { @@ -29,13 +28,10 @@ class DefaultRepositoryFactory private $defaultRepositories = []; /** - * @var \Symfony\Component\DependencyInjection\Container + * @var Container */ private $container; - /** - * @param Container $container - */ public function __construct(Container $container) { $this->container = $container; @@ -44,7 +40,7 @@ public function __construct(Container $container) /** * @return RepositoryInterface[] */ - public function getDefaultRepositories() + public function getDefaultRepositories(): array { if (!$this->defaultRepositories) { $this->setupRepositories(); @@ -56,13 +52,13 @@ public function getDefaultRepositories() /** * Iterate all repositories in the config and set them up */ - private function setupRepositories() + private function setupRepositories(): void { /** @var Config $config */ $config = $this->container->get('config'); foreach ($config->getRepositories() as $type => $data) { - if (!in_array($type, $this->supportedRepositories)) { + if (!\in_array($type, $this->supportedRepositories, true)) { continue; } @@ -72,11 +68,8 @@ private function setupRepositories() /** * Setup all sub-repositories - * - * @param $type - * @param $data */ - private function createSubRepositories($type, $data) + private function createSubRepositories($type, $data): void { $baseUrl = isset($data['config']['endpoint']) ? $data['config']['endpoint'] : null; $username = isset($data['config']['username']) ? $data['config']['username'] : null; @@ -95,17 +88,14 @@ private function createSubRepositories($type, $data) } } - /** - * @param $name - * @param $type - * @param $repoConfig - * @param $restClient - * - * @return BaseRepository - */ - private function createRepository($name, $type, $repoConfig, $restClient) - { + private function createRepository( + string $name, + string $type, + array $repoConfig, + ?RestInterface $restClient + ): BaseRepository { $className = 'Shopware\\Plugin\\Services\\Repositories\\Standard\\' . $type; + /** @var BaseRepository $repo */ $repo = new $className( isset($repoConfig['url']) ? $repoConfig['url'] : '', $name, diff --git a/src/Extensions/Shopware/Plugin/Services/Repositories/RepositoryInterface.php b/src/Extensions/Shopware/Plugin/Services/Repositories/RepositoryInterface.php index 600f5090..d1aa7274 100644 --- a/src/Extensions/Shopware/Plugin/Services/Repositories/RepositoryInterface.php +++ b/src/Extensions/Shopware/Plugin/Services/Repositories/RepositoryInterface.php @@ -12,8 +12,6 @@ /** * Interface for repository classes - * - * Class RepositoryInterface */ interface RepositoryInterface { diff --git a/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/GitHub.php b/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/GitHub.php index e6b5be9e..01028f6c 100644 --- a/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/GitHub.php +++ b/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/GitHub.php @@ -10,9 +10,6 @@ use Shopware\Plugin\Services\Repositories\BaseRepository; -/** - * Class GitHub - */ class GitHub extends BaseRepository { /** diff --git a/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/GitLab.php b/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/GitLab.php index 39aef81b..dff6e011 100644 --- a/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/GitLab.php +++ b/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/GitLab.php @@ -10,9 +10,6 @@ use Shopware\Plugin\Services\Repositories\BaseRepository; -/** - * Class GitLab - */ class GitLab extends BaseRepository { /** diff --git a/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/SimpleList.php b/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/SimpleList.php index 00e8c277..1175be18 100644 --- a/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/SimpleList.php +++ b/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/SimpleList.php @@ -15,8 +15,6 @@ /** * The simple list provides a "virtual repository" from multiple git repos which also might come from different * servers (e.g. local, github, bitbucket, stash…) - * - * Class SimpleList */ class SimpleList extends BaseRepository implements ContainerAwareInterface { diff --git a/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/Stash.php b/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/Stash.php index 6bbc93fc..127c79ff 100644 --- a/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/Stash.php +++ b/src/Extensions/Shopware/Plugin/Services/Repositories/Standard/Stash.php @@ -10,9 +10,6 @@ use Shopware\Plugin\Services\Repositories\BaseRepository; -/** - * Class Stash - */ class Stash extends BaseRepository { /** diff --git a/src/Extensions/Shopware/Plugin/Services/RepositoryManager.php b/src/Extensions/Shopware/Plugin/Services/RepositoryManager.php index 6aeabd16..fa47d7aa 100644 --- a/src/Extensions/Shopware/Plugin/Services/RepositoryManager.php +++ b/src/Extensions/Shopware/Plugin/Services/RepositoryManager.php @@ -14,15 +14,14 @@ /** * Collect default and plugin repositories - * - * Class RepositoryManager */ class RepositoryManager { /** - * @var \Shopware\Plugin\Services\Repositories\DefaultRepositoryFactory + * @var DefaultRepositoryFactory */ private $defaultRepositoryFactory; + /** * @var ExtensionManager */ @@ -36,10 +35,8 @@ public function __construct(ExtensionManager $extensionManager, DefaultRepositor /** * Return default and plugin repositories - * - * @return array */ - public function getRepositories() + public function getRepositories(): array { $defaultRepositories = $this->defaultRepositoryFactory->getDefaultRepositories(); $pluginRepositories = $this->collectPluginRepositories(); @@ -49,10 +46,8 @@ public function getRepositories() /** * Iterate all plugins and collect plugin repositories - * - * @return array */ - private function collectPluginRepositories() + private function collectPluginRepositories(): array { $repositories = []; diff --git a/src/Extensions/Shopware/Plugin/Services/Zip.php b/src/Extensions/Shopware/Plugin/Services/Zip.php index 6f979fb4..35cd0e36 100644 --- a/src/Extensions/Shopware/Plugin/Services/Zip.php +++ b/src/Extensions/Shopware/Plugin/Services/Zip.php @@ -23,7 +23,7 @@ class Zip protected $checkout; /** - * @var \ShopwareCli\Utilities + * @var Utilities */ protected $utilities; @@ -32,11 +32,6 @@ class Zip */ private $processExecutor; - /** - * @param Checkout $checkout - * @param Utilities $utilities - * @param ProcessExecutor $processExecutor - */ public function __construct(Checkout $checkout, Utilities $utilities, ProcessExecutor $processExecutor) { $this->checkout = $checkout; @@ -45,15 +40,12 @@ public function __construct(Checkout $checkout, Utilities $utilities, ProcessExe } /** - * @param Plugin $plugin * @param string $path * @param string $zipTo * @param string $branch * @param bool $useHttp - * - * @return string */ - public function zip(Plugin $plugin, $path, $zipTo, $branch, $useHttp = false) + public function zip(Plugin $plugin, $path, $zipTo, $branch, $useHttp = false): string { $this->checkout->checkout($plugin, $path, $branch, $useHttp); @@ -92,9 +84,8 @@ public function zip(Plugin $plugin, $path, $zipTo, $branch, $useHttp = false) /** * @param string $directory - * @param $outputFile */ - public function zipDir($directory, $outputFile) + public function zipDir($directory, $outputFile): void { $this->processExecutor->execute("zip -r $outputFile $directory -x *.git*"); } diff --git a/src/Extensions/Shopware/Plugin/Struct/DisplayPlugin.php b/src/Extensions/Shopware/Plugin/Struct/DisplayPlugin.php index f0ad6b61..34c364a0 100644 --- a/src/Extensions/Shopware/Plugin/Struct/DisplayPlugin.php +++ b/src/Extensions/Shopware/Plugin/Struct/DisplayPlugin.php @@ -12,24 +12,25 @@ /** * Shopware plugin struct - * - * Class Plugin */ class DisplayPlugin extends Struct { public $index; + public $repoType; + public $name; + public $module; + public $repository; /** - * @param Plugin $plugin - * @param int $index + * @param int $index * * @return static */ - public static function createFromPluginAndIndex(Plugin $plugin, $index) + public static function createFromPluginAndIndex(Plugin $plugin, $index): DisplayPlugin { return new static([ 'index' => $index, diff --git a/src/Extensions/Shopware/Plugin/Struct/Plugin.php b/src/Extensions/Shopware/Plugin/Struct/Plugin.php index 36c459b0..200cd6b9 100644 --- a/src/Extensions/Shopware/Plugin/Struct/Plugin.php +++ b/src/Extensions/Shopware/Plugin/Struct/Plugin.php @@ -12,8 +12,6 @@ /** * Shopware plugin struct - * - * Class Plugin */ class Plugin extends Struct { diff --git a/src/Extensions/Shopware/Plugin/Struct/PluginBootstrap.php b/src/Extensions/Shopware/Plugin/Struct/PluginBootstrap.php index 31a5c9eb..d1ff6a3f 100644 --- a/src/Extensions/Shopware/Plugin/Struct/PluginBootstrap.php +++ b/src/Extensions/Shopware/Plugin/Struct/PluginBootstrap.php @@ -12,11 +12,10 @@ /** * Shopware plugin bootstrap struct - * - * Class PluginBootstrap */ class PluginBootstrap extends Struct { public $name; + public $module; } diff --git a/src/Extensions/Shopware/PluginCreator/Bootstrap.php b/src/Extensions/Shopware/PluginCreator/Bootstrap.php index c044bc8d..f85330cf 100644 --- a/src/Extensions/Shopware/PluginCreator/Bootstrap.php +++ b/src/Extensions/Shopware/PluginCreator/Bootstrap.php @@ -24,8 +24,6 @@ public function setContainer(ContainerBuilder $container) /** * Return an array with instances of your console commands here - * - * @return mixed */ public function getConsoleCommands() { diff --git a/src/Extensions/Shopware/PluginCreator/Command/CreatePluginCommand.php b/src/Extensions/Shopware/PluginCreator/Command/CreatePluginCommand.php index 60922cf0..be0cdc17 100644 --- a/src/Extensions/Shopware/PluginCreator/Command/CreatePluginCommand.php +++ b/src/Extensions/Shopware/PluginCreator/Command/CreatePluginCommand.php @@ -12,6 +12,7 @@ use Shopware\PluginCreator\Struct\Configuration; use ShopwareCli\Command\BaseCommand; use ShopwareCli\Config; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -20,15 +21,15 @@ class CreatePluginCommand extends BaseCommand { - const LEGACY_OPTION = 'legacy'; + private const LEGACY_OPTION = 'legacy'; public function interact(InputInterface $input, OutputInterface $output) { - /** @var \Symfony\Component\Console\Helper\QuestionHelper $helper */ + /** @var QuestionHelper $helper */ $helper = $this->getHelperSet()->get('question'); $name = $input->getArgument('name'); - $modelName = implode('', array_slice($this->upperToArray($name), 1)); + $modelName = implode('', \array_slice($this->upperToArray($name), 1)); if ($input->getOption(self::LEGACY_OPTION)) { $defaultModel = sprintf('Shopware\CustomModels\%s\%s', $name, $modelName); @@ -58,10 +59,8 @@ public function interact(InputInterface $input, OutputInterface $output) /** * Make sure, that our booleans are actual booleans - * - * @param InputInterface $input */ - public function normalizeBooleanFields(InputInterface $input) + public function normalizeBooleanFields(InputInterface $input): void { $inputOptions = [ 'haveBackend', @@ -90,12 +89,8 @@ public function normalizeBooleanFields(InputInterface $input) /** * Split "SwagTestPlugin" into array("Swag", "Test", "Plugin") - * - * @param $input - * - * @return array */ - public function upperToArray($input) + public function upperToArray($input): array { return preg_split('/(?=[A-Z])/', $input, -1, PREG_SPLIT_NO_EMPTY); } @@ -103,15 +98,13 @@ public function upperToArray($input) /** * Make sure the namespace is one of core, backend, frontend * - * @param $input - * * @throws \InvalidArgumentException * * @return $input */ public function validateNamespace($input) { - if (!in_array(strtolower($input), ['frontend', 'core', 'backend'])) { + if (!\in_array(strtolower($input), ['frontend', 'core', 'backend'])) { throw new \InvalidArgumentException('Namespace mus be one of FRONTEND, BACKEND or CORE'); } @@ -119,13 +112,13 @@ public function validateNamespace($input) } /** - * Check the entered model (check might be somewhat more sufisticated) + * Check the entered model (check might be somewhat more sophisticated) * * @throws \InvalidArgumentException */ - public function validateModel() + public function validateModel(): callable { - return function ($input) { + return static function ($input) { if (empty($input)) { throw new \InvalidArgumentException('You need to enter a model name like »Shopware\Models\Article\Article«'); } @@ -134,10 +127,7 @@ public function validateModel() }; } - /** - * @return Config - */ - protected function getConfig() + protected function getConfig(): Config { return $this->container->get('config'); } @@ -227,7 +217,8 @@ protected function configure() 'File with your desired license header', '' ) - ->setHelp(<<setHelp( + <<%command.name% creates a new plugin. EOF ); @@ -253,28 +244,22 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** - * Check the plugin name - it needs to constist of two parts at least - the first one is the dev prefix - * - * @param $name + * Check the plugin name - it needs to consist of two parts at least - the first one is the dev prefix * * @throws \InvalidArgumentException */ protected function validateName($name) { $parts = $this->upperToArray($name); - if (count($parts) <= 1) { + if (\count($parts) <= 1) { throw new \InvalidArgumentException('Name must be in CamelCase and have at least two components. Don\'t forget you developer-prefix'); } } /** * Populate a configuration object by the input interface - * - * @param InputInterface $input - * - * @return Configuration */ - protected function getConfigurationObject(InputInterface $input) + protected function getConfigurationObject(InputInterface $input): Configuration { $configuration = new Configuration(); $configuration->name = $input->getArgument('name'); @@ -302,7 +287,7 @@ protected function getConfigurationObject(InputInterface $input) return $configuration; } - private function prepareLicenseHeader($license) + private function prepareLicenseHeader($license): string { $license = str_replace("\n", "\n * ", trim($license)); diff --git a/src/Extensions/Shopware/PluginCreator/Services/Generator.php b/src/Extensions/Shopware/PluginCreator/Services/Generator.php index b492a1f5..30b915f6 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/Generator.php +++ b/src/Extensions/Shopware/PluginCreator/Services/Generator.php @@ -15,7 +15,7 @@ class Generator { - const TEMPLATE_DIRECTORY = 'template'; + private const TEMPLATE_DIRECTORY = 'template'; /** * @var Configuration @@ -47,14 +47,6 @@ class Generator */ private $outputDirectoryProvider; - /** - * @param IoAdapter $ioAdapter - * @param Configuration $configuration - * @param NameGenerator $nameGenerator - * @param Template $template - * @param FileProviderLoaderInterface $fileProviderLoader - * @param OutputDirectoryProviderInterface $outputDirectoryProvider - */ public function __construct( IoAdapter $ioAdapter, Configuration $configuration, @@ -74,7 +66,7 @@ public function __construct( /** * Creates the actual plugin from template files */ - public function run() + public function run(): void { $this->configureTemplate(); @@ -89,16 +81,14 @@ public function run() /** * Creates files from an array of template files - * - * @param $files */ - private function createFilesFromTemplate($files) + private function createFilesFromTemplate($files): void { foreach ($files as $from => $to) { $fileContent = $this->template->fetch($from); $path = $this->outputDirectoryProvider->getPath(); - $this->ioAdapter->createDirectory(dirname($path . $to)); + $this->ioAdapter->createDirectory(\dirname($path . $to)); $this->ioAdapter->createFile($path . $to, $fileContent); } @@ -107,17 +97,17 @@ private function createFilesFromTemplate($files) /** * setup the template */ - private function configureTemplate() + private function configureTemplate(): void { $this->template->assign('configuration', $this->configuration); $this->template->assign('names', $this->nameGenerator); - $this->template->setTemplatePath(dirname(__DIR__) . '/' . self::TEMPLATE_DIRECTORY); + $this->template->setTemplatePath(\dirname(__DIR__) . '/' . self::TEMPLATE_DIRECTORY); } /** * Will step through all known template files, render and copy them to the configured destination */ - private function processTemplateFiles() + private function processTemplateFiles(): void { foreach ($this->fileProviderLoader->load() as $provider) { $this->createFilesFromTemplate( diff --git a/src/Extensions/Shopware/PluginCreator/Services/GeneratorFactory.php b/src/Extensions/Shopware/PluginCreator/Services/GeneratorFactory.php index 821120ff..147ff65d 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/GeneratorFactory.php +++ b/src/Extensions/Shopware/PluginCreator/Services/GeneratorFactory.php @@ -15,17 +15,9 @@ use Shopware\PluginCreator\Services\WorkingDirectoryProvider\RootDetector\ShopwareRootDetector; use Shopware\PluginCreator\Struct\Configuration; -/** - * Class GeneratorFactory - */ class GeneratorFactory { - /** - * @param Configuration $configuration - * - * @return Generator - */ - public function create(Configuration $configuration) + public function create(Configuration $configuration): Generator { $legacyOptionFileProvider = new LegacyOptionFileProviderLoader($configuration->isLegacyPlugin); $outputDirectoryProvider = $this->getOutputDirectoryProvider($configuration); @@ -41,8 +33,6 @@ public function create(Configuration $configuration) } /** - * @param Configuration $configuration - * * @return CurrentOutputDirectoryProvider|LegacyOutputDirectoryProvider */ private function getOutputDirectoryProvider(Configuration $configuration) diff --git a/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/Dummy.php b/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/Dummy.php index 361a1904..bec40c05 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/Dummy.php +++ b/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/Dummy.php @@ -10,16 +10,12 @@ /** * Dummy IoAdapter will collect all files in memory - * - * Class Dummy */ class Dummy implements IoAdapter { protected $files = []; /** - * @param $path - * * @return bool */ public function exists($path) @@ -37,10 +33,7 @@ public function createFile($file, $content) $this->files[$file] = $content; } - /** - * @return array - */ - public function getFiles() + public function getFiles(): array { return $this->files; } diff --git a/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/HardDrive.php b/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/HardDrive.php index 6aa9a271..6aa1cabf 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/HardDrive.php +++ b/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/HardDrive.php @@ -10,14 +10,10 @@ /** * HardDrive IoAdapter actually performs IO on the hdd - * - * Class HardDrive */ class HardDrive implements IoAdapter { /** - * @param $path - * * @return bool */ public function exists($path) diff --git a/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/IoAdapter.php b/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/IoAdapter.php index cbaa4873..90fc56b6 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/IoAdapter.php +++ b/src/Extensions/Shopware/PluginCreator/Services/IoAdapter/IoAdapter.php @@ -10,30 +10,15 @@ /** * IoAdapter is a generic interface for some file operations needed in the plugin - * - * Interface IoAdapter */ interface IoAdapter { /** - * @param $path - * * @return bool */ public function exists($path); - /** - * @param $dir - * - * @return mixed - */ public function createDirectory($dir); - /** - * @param $file - * @param $content - * - * @return mixed - */ public function createFile($file, $content); } diff --git a/src/Extensions/Shopware/PluginCreator/Services/NameGenerator.php b/src/Extensions/Shopware/PluginCreator/Services/NameGenerator.php index 2090954f..afdd64e7 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/NameGenerator.php +++ b/src/Extensions/Shopware/PluginCreator/Services/NameGenerator.php @@ -12,28 +12,32 @@ /** * The name generator generates useful names for controller, variables and views depending on the configuration object - * - * Class NameGenerator */ class NameGenerator { // e.g. swag public $developerPrefix; + // e.g. swag-promotion public $dash_js; + // e.g. swag_promotion public $under_score_js; + // e.g. promotion_test public $under_score_model; + // e.g. PromotionTest public $camelCaseModel; + // e.g.promotion public $backendModelAlias; + // e.g. SwagTestWidget public $backendWidgetController; /** - * @var \Shopware\PluginCreator\Struct\Configuration + * @var Configuration */ private $configuration; @@ -47,7 +51,7 @@ public function __construct(Configuration $configuration) /** * Generate all needed names */ - public function generateNames() + public function generateNames(): void { $parts = $this->upperToArray($this->configuration->name); @@ -70,7 +74,7 @@ public function generateNames() public function getModelName() { if (!$this->configuration->backendModel) { - return implode('', array_slice($this->upperToArray($this->configuration->name), 1)); + return implode('', \array_slice($this->upperToArray($this->configuration->name), 1)); } $parts = explode('\\', $this->configuration->backendModel); @@ -80,10 +84,8 @@ public function getModelName() /** * Determine the alias for the backend model - * - * @return string */ - public function getBackendModelAlias() + public function getBackendModelAlias(): string { if (!$this->configuration->backendModel) { return 'alias'; @@ -96,12 +98,8 @@ public function getBackendModelAlias() /** * Splits a given string by upper case characters - * - * @param $input - * - * @return array */ - public function upperToArray($input) + public function upperToArray($input): array { return preg_split('/(?=[A-Z])/', $input, -1, PREG_SPLIT_NO_EMPTY); } diff --git a/src/Extensions/Shopware/PluginCreator/Services/Template.php b/src/Extensions/Shopware/PluginCreator/Services/Template.php index e40c4189..e0df8348 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/Template.php +++ b/src/Extensions/Shopware/PluginCreator/Services/Template.php @@ -23,7 +23,7 @@ class Template * * @param string $path */ - public function setTemplatePath($path) + public function setTemplatePath($path): void { $this->_path = rtrim($path, '/') . '/'; } @@ -32,36 +32,29 @@ public function setTemplatePath($path) * Assign a variable to the template. * * @param string $name - * @param $value */ - public function assign($name, $value) + public function assign($name, $value): void { $this->_templateVars[$name] = $value; } /** * Render the given template and return the result - * - * @param $_template - * - * @return string */ - public function fetch($_template) + public function fetch($_template): string { return $this->doRender($_template, true); } /** * Render the given template and return the result - * - * @param $_template */ - public function display($_template) + public function display($_template): void { $this->doRender($_template); } - public function errorReporter($severity, $message, $filename, $lineno) + public function errorReporter($severity, $message, $filename, $lineno): void { ob_clean(); throw new \ErrorException($message . ': ' . $filename . ', line ' . $lineno, 0, $severity, $filename, $lineno); @@ -73,12 +66,11 @@ public function errorReporter($severity, $message, $filename, $lineno) * While rendering the template, any notice / warning will result in an exception, mainly to avoid the generation * of plugins with notices inside. So be strict here and switch back to default error reporting mode after that * - * @param $_template * @param bool $return * * @return string */ - private function doRender($_template, $return = false) + private function doRender($_template, $return = false): ?string { // Extract the template vars into the current scope. if ($this->_templateVars) { diff --git a/src/Extensions/Shopware/PluginCreator/Services/TemplateFileProvider/FileProviderInterface.php b/src/Extensions/Shopware/PluginCreator/Services/TemplateFileProvider/FileProviderInterface.php index 58ba4e72..09241328 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/TemplateFileProvider/FileProviderInterface.php +++ b/src/Extensions/Shopware/PluginCreator/Services/TemplateFileProvider/FileProviderInterface.php @@ -21,17 +21,14 @@ interface FileProviderInterface /** * Directory which holds the file structure for the current plugin system. */ - const CURRENT_DIR = 'current/'; + public const CURRENT_DIR = 'current/'; /** * Directory which holds the legacy file structure. */ - const LEGACY_DIR = 'legacy/'; + public const LEGACY_DIR = 'legacy/'; /** - * @param Configuration $configuration - * @param NameGenerator $nameGenerator - * * @return array Return an array of files (key = source, value = target). Return empty * array for NOOP */ diff --git a/src/Extensions/Shopware/PluginCreator/Services/TemplateFileProvider/LegacyOptionFileProviderLoader.php b/src/Extensions/Shopware/PluginCreator/Services/TemplateFileProvider/LegacyOptionFileProviderLoader.php index 9ce6dcaf..d0eef8df 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/TemplateFileProvider/LegacyOptionFileProviderLoader.php +++ b/src/Extensions/Shopware/PluginCreator/Services/TemplateFileProvider/LegacyOptionFileProviderLoader.php @@ -22,8 +22,8 @@ class LegacyOptionFileProviderLoader implements FileProviderLoaderInterface */ public function __construct($isLegacy) { - if (!is_bool($isLegacy)) { - throw new \Exception('Boolean expected, got ' . gettype($isLegacy)); + if (!\is_bool($isLegacy)) { + throw new \Exception('Boolean expected, got ' . \gettype($isLegacy)); } $this->isLegacy = $isLegacy; @@ -46,7 +46,7 @@ public function load() /** * @return FileProviderInterface[] */ - private function getLegacyProvider() + private function getLegacyProvider(): array { return [ new Legacy\ApiFileProvider(), @@ -66,7 +66,7 @@ private function getLegacyProvider() /** * @return FileProviderInterface[] */ - private function getCurrentProvider() + private function getCurrentProvider(): array { return [ new Current\ApiFileProvider(), diff --git a/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/CurrentOutputDirectoryProvider.php b/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/CurrentOutputDirectoryProvider.php index a0208bcd..32833f3c 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/CurrentOutputDirectoryProvider.php +++ b/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/CurrentOutputDirectoryProvider.php @@ -12,7 +12,7 @@ class CurrentOutputDirectoryProvider implements OutputDirectoryProviderInterface { - const CURRENT_PLUGIN_DIR = 'custom/plugins'; + private const CURRENT_PLUGIN_DIR = 'custom/plugins'; /** * @var RootDetectorInterface @@ -25,8 +25,7 @@ class CurrentOutputDirectoryProvider implements OutputDirectoryProviderInterface private $name; /** - * @param RootDetectorInterface $rootDetector - * @param string $name + * @param string $name */ public function __construct(RootDetectorInterface $rootDetector, $name) { @@ -46,10 +45,7 @@ public function getPath() return $this->getCwd() . '/' . $this->name . '/'; } - /** - * @return string - */ - private function getCwd() + private function getCwd(): string { return getcwd(); } diff --git a/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/LegacyOutputDirectoryProvider.php b/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/LegacyOutputDirectoryProvider.php index 430e5417..b36d4c1b 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/LegacyOutputDirectoryProvider.php +++ b/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/LegacyOutputDirectoryProvider.php @@ -12,11 +12,10 @@ class LegacyOutputDirectoryProvider implements OutputDirectoryProviderInterface { - const LEGACY_PLUGIN_DIR = 'engine/Shopware/Plugins/Local'; - - const FRONTEND_NAMESPACE = 'Frontend'; - const BACKEND_NAMESPACE = 'Backend'; - const CORE_NAMESPACE = 'Core'; + public const FRONTEND_NAMESPACE = 'Frontend'; + private const LEGACY_PLUGIN_DIR = 'engine/Shopware/Plugins/Local'; + private const BACKEND_NAMESPACE = 'Backend'; + private const CORE_NAMESPACE = 'Core'; /** * @var string @@ -34,15 +33,14 @@ class LegacyOutputDirectoryProvider implements OutputDirectoryProviderInterface private $name; /** - * @param RootDetectorInterface $rootDetector - * @param string $name - * @param string $namespace + * @param string $name + * @param string $namespace * * @throws \Exception */ public function __construct(RootDetectorInterface $rootDetector, $name, $namespace) { - if (!$this->isValidNamespace($namespace) && strlen($namespace)) { + if (!$this->isValidNamespace($namespace) && $namespace !== '') { throw new \Exception( sprintf('Invalid namespace given: %s', $namespace) ); @@ -67,18 +65,13 @@ public function getPath() /** * @param string $namespace - * - * @return bool */ - private function isValidNamespace($namespace) + private function isValidNamespace($namespace): bool { - return self::FRONTEND_NAMESPACE == $namespace || self::BACKEND_NAMESPACE == $namespace || self::CORE_NAMESPACE == $namespace; + return \in_array($namespace, [self::FRONTEND_NAMESPACE, self::BACKEND_NAMESPACE, self::CORE_NAMESPACE], true); } - /** - * @return string - */ - private function getCwd() + private function getCwd(): string { return getcwd(); } diff --git a/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/RootDetector/ShopwareRootDetector.php b/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/RootDetector/ShopwareRootDetector.php index 2c8fb179..b5888287 100644 --- a/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/RootDetector/ShopwareRootDetector.php +++ b/src/Extensions/Shopware/PluginCreator/Services/WorkingDirectoryProvider/RootDetector/ShopwareRootDetector.php @@ -10,10 +10,7 @@ class ShopwareRootDetector implements RootDetectorInterface { - /** - * @return array - */ - public static function getDirectories() + public static function getDirectories(): array { return [ '/engine', @@ -24,10 +21,7 @@ public static function getDirectories() ]; } - /** - * @return array - */ - public static function getFiles() + public static function getFiles(): array { return [ '/shopware.php', @@ -41,19 +35,13 @@ public static function getFiles() */ public function isRoot($path) { - if ($this->validateDirectories($path) && $this->validateFiles($path)) { - return true; - } - - return false; + return $this->validateDirectories($path) && $this->validateFiles($path); } /** * @param string $path - * - * @return bool */ - private function validateDirectories($path) + private function validateDirectories($path): bool { foreach (self::getDirectories() as $directory) { if (!is_dir($path . $directory)) { @@ -66,10 +54,8 @@ private function validateDirectories($path) /** * @param string $path - * - * @return bool */ - private function validateFiles($path) + private function validateFiles($path): bool { foreach (self::getFiles() as $file) { if (!file_exists($path . $file)) { diff --git a/src/Extensions/Shopware/PluginCreator/Struct/Configuration.php b/src/Extensions/Shopware/PluginCreator/Struct/Configuration.php index 8893b379..b7bcf9ca 100644 --- a/src/Extensions/Shopware/PluginCreator/Struct/Configuration.php +++ b/src/Extensions/Shopware/PluginCreator/Struct/Configuration.php @@ -12,8 +12,6 @@ /** * The config struct stores all info needed to create the plugin - * - * Class Configuration */ class Configuration extends Struct { @@ -24,28 +22,37 @@ class Configuration extends Struct // Name of the plugin: SwagMyPlugin public $name; + // Namespace of the plugin: frontend / core / backend public $namespace; // frontend controller needed? public $hasFrontend; + // backend application needed? public $hasBackend; + // widgets needed? public $hasWidget; + // api needed? public $hasApi; + // models needed? public $hasModels; + // commands needed ? public $hasCommands; + // dbal facet / condition needed? public $hasFilter; // model for the backend ($hasBackend) public $backendModel; + // license header public $licenseHeader; + public $licenseHeaderPlain; // is legacy-plugin ? diff --git a/src/Extensions/Shopware/RunCli/Command/RunCliCommand.php b/src/Extensions/Shopware/RunCli/Command/RunCliCommand.php index fdadbb19..ac27283c 100644 --- a/src/Extensions/Shopware/RunCli/Command/RunCliCommand.php +++ b/src/Extensions/Shopware/RunCli/Command/RunCliCommand.php @@ -25,7 +25,7 @@ public function execute(InputInterface $input, OutputInterface $output) $shopwarePath = $input->getOption('shopwarePath'); $arguments = implode(' ', $input->getArgument('sw-command')); - /** @var $ioService IoService */ + /** @var IoService $ioService */ $ioService = $this->container->get('io_service'); $shopwarePath = $this->getValidShopwarePath($shopwarePath, $ioService); @@ -33,12 +33,9 @@ public function execute(InputInterface $input, OutputInterface $output) } /** - * @param string $shopwarePath - * @param IoService $ioService - * - * @return string + * @param string $shopwarePath */ - public function getValidShopwarePath($shopwarePath, IoService $ioService) + public function getValidShopwarePath($shopwarePath, IoService $ioService): string { if (!$shopwarePath) { $shopwarePath = realpath(getcwd()); @@ -48,7 +45,7 @@ public function getValidShopwarePath($shopwarePath, IoService $ioService) if ($this->container->get('utilities')->isShopwareInstallation($shopwarePath)) { return $shopwarePath; } - } while (($shopwarePath = dirname($shopwarePath)) && $shopwarePath != '/'); + } while (($shopwarePath = \dirname($shopwarePath)) && $shopwarePath != '/'); return $ioService->askAndValidate( 'Path to your Shopware installation: ', @@ -77,7 +74,7 @@ protected function configure() 'arguments for your shopare command' ) ->setHelp( -<<%command.name% command allows you to trigger shopware cli commands from any subdirectory. EOF ); diff --git a/src/Services/FileDownloader.php b/src/Services/FileDownloader.php index 8574ff61..c38e2627 100644 --- a/src/Services/FileDownloader.php +++ b/src/Services/FileDownloader.php @@ -8,9 +8,6 @@ namespace ShopwareCli\Services; -/** - * Class FileDownloader - */ interface FileDownloader { /** diff --git a/src/Services/GitIdentityEnvironment.php b/src/Services/GitIdentityEnvironment.php index 684e6f18..46459973 100644 --- a/src/Services/GitIdentityEnvironment.php +++ b/src/Services/GitIdentityEnvironment.php @@ -11,27 +11,27 @@ use ShopwareCli\Config; use ShopwareCli\Services\PathProvider\PathProvider; -/** - * Class GitIdentityEnvironment - */ class GitIdentityEnvironment { - protected $wrapperFileName = 'ssh-as.sh'; - protected $keyFileName = 'ssh.key'; + private $wrapperFileName = 'ssh-as.sh'; + + private $keyFileName = 'ssh.key'; - protected $sshAliasTemplate = <<<'EOF' + private $sshAliasTemplate = <<<'EOF' #!/bin/bash set -e set -u ssh -i $SSH_KEYFILE $@ EOF; + /** * @var PathProvider */ private $pathProvider; + /** - * @var \ShopwareCli\Config + * @var Config */ private $config; @@ -44,10 +44,8 @@ public function __construct(PathProvider $pathProvider, Config $config) /** * Will return an array of SSH_KEYFILE and GIT_SSH if a custom ssh key is configured * Else null will be returned - * - * @return array|null */ - public function getGitEnv() + public function getGitEnv(): ?array { if (!$this->getCustomKey()) { return null; @@ -64,10 +62,8 @@ public function getGitEnv() * custom key is configured * * @throws \RuntimeException - * - * @return null|string */ - private function getCustomKey() + private function getCustomKey(): ?string { if (isset($this->config['sshKey'])) { $keyPath = $this->config['sshKey']; @@ -97,10 +93,8 @@ private function getCustomKey() /** * @param string $dir * @param string $sshKeyFile - * - * @return bool */ - private function writeSshKey($dir, $sshKeyFile) + private function writeSshKey($dir, $sshKeyFile): bool { if (!is_dir($dir) && !mkdir($dir, 0700, true) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); @@ -117,10 +111,8 @@ private function writeSshKey($dir, $sshKeyFile) * Return path of the git wrapper file. If it doesn't exist, it will be created * * @throws \RuntimeException - * - * @return string */ - private function getGitWrapper() + private function getGitWrapper(): string { $dir = $this->pathProvider->getRuntimeDir() . '/sw-cli-tools/'; @@ -137,10 +129,8 @@ private function getGitWrapper() * Create git wrapper file * * @param string $dir - * - * @return bool */ - private function writeGitSshWrapper($dir) + private function writeGitSshWrapper($dir): bool { if (!is_dir($dir) && !mkdir($dir, 0700, true) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); diff --git a/src/Services/GitUtil.php b/src/Services/GitUtil.php index 7dcacbe8..c57ae4e7 100644 --- a/src/Services/GitUtil.php +++ b/src/Services/GitUtil.php @@ -25,15 +25,14 @@ class GitUtil * @var OutputInterface */ private $output; + /** * @var GitIdentityEnvironment */ private $gitEnv; /** - * @param OutputInterface $output - * @param GitIdentityEnvironment $gitEnv - * @param int $timeout + * @param int $timeout */ public function __construct(OutputInterface $output, GitIdentityEnvironment $gitEnv, $timeout) { @@ -45,10 +44,8 @@ public function __construct(OutputInterface $output, GitIdentityEnvironment $git /** * @param string $commandline * @param int|null $timeout - * - * @return string */ - public function run($commandline, $timeout = null) + public function run($commandline, $timeout = null): string { $commandline = 'git ' . $commandline; @@ -56,7 +53,7 @@ public function run($commandline, $timeout = null) $process->setTimeout($timeout ?: $this->timeout); $output = $this->output; // tmp var needed for php < 5.4 - $process->run(function ($type, $buffer) use ($output) { + $process->run(static function ($type, $buffer) use ($output) { $output->write($buffer); }); @@ -66,4 +63,9 @@ public function run($commandline, $timeout = null) return $process->getOutput(); } + + public function getTimeout(): int + { + return $this->timeout; + } } diff --git a/src/Services/IoService.php b/src/Services/IoService.php index 6c82df8c..a62327fe 100644 --- a/src/Services/IoService.php +++ b/src/Services/IoService.php @@ -16,9 +16,6 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; -/** - * Class IoService - */ class IoService { /** @@ -36,11 +33,6 @@ class IoService */ private $questionHelper; - /** - * @param InputInterface $input - * @param OutputInterface $output - * @param QuestionHelper $questionHelper - */ public function __construct( InputInterface $input, OutputInterface $output, @@ -53,50 +45,40 @@ public function __construct( /** * Returns true if the input is interactive - * - * @return bool */ - public function isInteractive() + public function isInteractive(): bool { return $this->input->isInteractive(); } /** * Returns true if output is quiet - * - * @return bool */ - public function isQuiet() + public function isQuiet(): bool { return $this->output->getVerbosity() === OutputInterface::VERBOSITY_QUIET; } /** * Return true if output is verbose (or more verbose) - * - * @return bool */ - public function isVerbose() + public function isVerbose(): bool { return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE; } /** * Return true if output is ver verbose (or debug) - * - * @return bool */ - public function isVeryVerbose() + public function isVeryVerbose(): bool { return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE; } /** * Return true if output is debug - * - * @return bool */ - public function isDebug() + public function isDebug(): bool { return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG; } @@ -106,17 +88,15 @@ public function isDebug() * * @param string $message */ - public function write($message) + public function write($message): void { $this->output->write($message); } /** * Write a message to STDOUT with trailing newline - * - * @param $message */ - public function writeln($message) + public function writeln($message): void { $this->output->write($message, true); } @@ -126,10 +106,8 @@ public function writeln($message) * * @param string|Question $question * @param null $default - * - * @return string */ - public function ask($question, $default = null, $hidden = false) + public function ask($question, $default = null, $hidden = false): string { $question = $question instanceof Question ? $question : new Question($question, $default); @@ -146,10 +124,8 @@ public function ask($question, $default = null, $hidden = false) * * @param array|null $headers * @param array|null $results - * - * @return Table */ - public function createTable($headers = null, $results = null) + public function createTable($headers = null, $results = null): Table { $tableObject = new Table($this->output); @@ -169,10 +145,8 @@ public function createTable($headers = null, $results = null) * * @param string|Question $question * @param null $default - * - * @return string */ - public function askConfirmation($question, $default = null) + public function askConfirmation($question, $default = null): string { $question = $question instanceof ConfirmationQuestion ? $question @@ -187,11 +161,9 @@ public function askConfirmation($question, $default = null) * @param string|Question $question * @param bool|callable $validator * @param bool|int $attempts - * @param null|string $default - * - * @return string + * @param string|null $default */ - public function askAndValidate($question, $validator = false, $attempts = false, $default = null, $hidden = false) + public function askAndValidate($question, $validator = false, $attempts = false, $default = null, $hidden = false): string { $question = $question instanceof Question ? $question : new Question($question, $default); @@ -213,10 +185,8 @@ public function askAndValidate($question, $validator = false, $attempts = false, /** * @param int $max Maximum steps (0 if unknown) - * - * @return ProgressBar */ - public function createProgressBar($max = 0) + public function createProgressBar($max = 0): ProgressBar { return new ProgressBar($this->output, $max); } @@ -224,14 +194,14 @@ public function createProgressBar($max = 0) /** * Clears the screen in the terminal */ - public function cls() + public function cls(): void { if (!$this->input->isInteractive()) { return; } // http://en.wikipedia.org/wiki/ANSI_escape_code - $this->output->write(chr(27) . '[2J'); // ED – Erase Display - $this->output->write(chr(27) . '[1;1H'); // CUP – Set Cursor Position to upper left + $this->output->write(\chr(27) . '[2J'); // ED – Erase Display + $this->output->write(\chr(27) . '[1;1H'); // CUP – Set Cursor Position to upper left } } diff --git a/src/Services/OpenSSLVerifier.php b/src/Services/OpenSSLVerifier.php index 710e8380..a00f27a5 100644 --- a/src/Services/OpenSSLVerifier.php +++ b/src/Services/OpenSSLVerifier.php @@ -27,12 +27,9 @@ public function __construct($publicKey) $this->publicKey = $publicKey; } - /** - * @return bool - */ - public function isSystemSupported() + public function isSystemSupported(): bool { - return function_exists('openssl_verify'); + return \function_exists('openssl_verify'); } /** @@ -40,14 +37,12 @@ public function isSystemSupported() * @param string $signature * * @throws \RuntimeException - * - * @return bool */ - public function isValid($message, $signature) + public function isValid($message, $signature): bool { $publicKey = trim(file_get_contents($this->publicKey)); - if (false === $pubkeyid = openssl_pkey_get_public($publicKey)) { + if ($pubkeyid = openssl_pkey_get_public($publicKey) === false) { while ($errors[] = openssl_error_string()); throw new \RuntimeException(sprintf("Error during public key read: \n%s", implode("\n", $errors))); } @@ -55,16 +50,19 @@ public function isValid($message, $signature) $signature = base64_decode($signature); // state whether signature is okay or not - $ok = openssl_verify($message, $signature, $pubkeyid); + $ok = (int) openssl_verify($message, $signature, $pubkeyid); // free the key from memory openssl_free_key($pubkeyid); - if ($ok == 1) { + if ($ok === 1) { return true; - } elseif ($ok == 0) { + } + + if ($ok === 0) { return false; } + while ($errors[] = openssl_error_string()); throw new \RuntimeException(sprintf("Error during private key read: \n%s", implode("\n", $errors))); } diff --git a/src/Services/PathProvider/DirectoryGateway/CliToolGateway.php b/src/Services/PathProvider/DirectoryGateway/CliToolGateway.php index fa4f8edf..0088bba7 100644 --- a/src/Services/PathProvider/DirectoryGateway/CliToolGateway.php +++ b/src/Services/PathProvider/DirectoryGateway/CliToolGateway.php @@ -63,9 +63,6 @@ public function getConfigDir() return $this->getBasePath(); } - /** - * @return mixed - */ public function getRuntimeDir() { throw new \RuntimeException('not implemented'); diff --git a/src/Services/PathProvider/DirectoryGateway/XdgGateway.php b/src/Services/PathProvider/DirectoryGateway/XdgGateway.php index d4ecbb7a..5b956dfe 100644 --- a/src/Services/PathProvider/DirectoryGateway/XdgGateway.php +++ b/src/Services/PathProvider/DirectoryGateway/XdgGateway.php @@ -17,9 +17,6 @@ class XdgGateway implements DirectoryGatewayInterface */ private $xdg; - /** - * @param Xdg $xdg - */ public function __construct(Xdg $xdg) { $this->xdg = $xdg; diff --git a/src/Services/PathProvider/PathProvider.php b/src/Services/PathProvider/PathProvider.php index ccb88a6e..46e785f2 100644 --- a/src/Services/PathProvider/PathProvider.php +++ b/src/Services/PathProvider/PathProvider.php @@ -22,35 +22,32 @@ public function __construct(DirectoryGatewayInterface $directoryGateway) $this->directoryGateway = $directoryGateway; } - /** - * @return string - */ - public function getCliToolPath() + public function getCliToolPath(): string { - return dirname(dirname(dirname(__DIR__))); + return \dirname(__DIR__, 3); } - public function getCachePath() + public function getCachePath(): string { return $this->directoryGateway->getCacheDir(); } - public function getAssetsPath() + public function getAssetsPath(): string { return $this->directoryGateway->getAssetsDir(); } - public function getExtensionPath() + public function getExtensionPath(): string { return $this->directoryGateway->getExtensionDir(); } - public function getConfigPath() + public function getConfigPath(): string { return $this->directoryGateway->getConfigDir(); } - public function getRuntimeDir() + public function getRuntimeDir(): string { // temporary fix: selinux seems to interfere with executables in /run/user on some systems return '/tmp'; diff --git a/src/Services/ProcessExecutor.php b/src/Services/ProcessExecutor.php index 5b5c226f..d63ca2de 100644 --- a/src/Services/ProcessExecutor.php +++ b/src/Services/ProcessExecutor.php @@ -27,8 +27,7 @@ class ProcessExecutor private $output; /** - * @param OutputInterface $output - * @param int $timeout + * @param int $timeout */ public function __construct(OutputInterface $output, $timeout) { @@ -41,16 +40,14 @@ public function __construct(OutputInterface $output, $timeout) * @param string $cwd * @param bool $allowFailure * @param int|null $timeout - * - * @return int|null */ - public function execute($commandline, $cwd = null, $allowFailure = false, $timeout = null) + public function execute($commandline, $cwd = null, $allowFailure = false, $timeout = null): ?int { $process = new Process($commandline, $cwd); $process->setTimeout($timeout ?: $this->timeout); $output = $this->output; // tmp var needed for php < 5.4 - $process->run(function ($type, $buffer) use ($output) { + $process->run(static function ($type, $buffer) use ($output) { $output->write($buffer); }); @@ -60,4 +57,9 @@ public function execute($commandline, $cwd = null, $allowFailure = false, $timeo return $process->getExitCode(); } + + public function getTimeout(): int + { + return $this->timeout; + } } diff --git a/src/Services/Rest/CacheDecorator.php b/src/Services/Rest/CacheDecorator.php index aa1e25f9..21e5a46a 100644 --- a/src/Services/Rest/CacheDecorator.php +++ b/src/Services/Rest/CacheDecorator.php @@ -12,8 +12,6 @@ /** * Decorated a RestInterface in order to implement a simple cache layer for GET requests - * - * Class CacheDecorator */ class CacheDecorator implements RestInterface { @@ -23,7 +21,7 @@ class CacheDecorator implements RestInterface protected $decorate; /** - * @var \ShopwareCli\Cache\CacheInterface + * @var CacheInterface */ protected $cacheProvider; @@ -32,12 +30,7 @@ class CacheDecorator implements RestInterface */ protected $cacheTime; - /** - * @param RestInterface $restService - * @param CacheInterface $cacheProvider - * @param int $cacheTime - */ - public function __construct(RestInterface $restService, CacheInterface $cacheProvider, $cacheTime = 1) + public function __construct(RestInterface $restService, CacheInterface $cacheProvider, int $cacheTime = 1) { $this->decorate = $restService; $this->cacheProvider = $cacheProvider; @@ -89,13 +82,13 @@ public function delete($url, $parameters = [], $headers = []) */ public function callCached($call, $key, $url, $parameters = [], $headers = []) { - /* @var $response ResponseInterface */ - if (!$this->cacheProvider || $this->cacheTime == 0) { - $response = call_user_func([$this->decorate, $call], $url, $parameters, $headers); + /* @var ResponseInterface $response */ + if (!$this->cacheProvider || $this->cacheTime === 0) { + $response = \call_user_func([$this->decorate, $call], $url, $parameters, $headers); } else { $response = $this->cacheProvider->read($key); if ($response === false) { - $response = call_user_func([$this->decorate, $call], $url, $parameters, $headers); + $response = \call_user_func([$this->decorate, $call], $url, $parameters, $headers); if ($response === false) { return false; } diff --git a/src/Services/Rest/Curl/Response.php b/src/Services/Rest/Curl/Response.php index bb75ce45..53ccf9a1 100644 --- a/src/Services/Rest/Curl/Response.php +++ b/src/Services/Rest/Curl/Response.php @@ -14,8 +14,6 @@ * Response object wrapping a response body of a curl request. * Does provide a simple interface to access error messages and status codes * as well as the decoded result object - * - * Class Response */ class Response implements ResponseInterface { @@ -35,9 +33,9 @@ class Response implements ResponseInterface protected $code; /** - * @var null|string + * @var string|null */ - protected $errorMessage = null; + protected $errorMessage; /** * @var bool @@ -45,7 +43,6 @@ class Response implements ResponseInterface protected $success = false; /** - * @param $body * @param resource $curlHandle */ public function __construct($body, $curlHandle) @@ -60,7 +57,8 @@ public function __construct($body, $curlHandle) $this->code = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); - if (null === $decodedResult = json_decode($this->rawBody, true)) { + $decodedResult = json_decode($this->rawBody, true); + if ($decodedResult === null) { $jsonError = json_last_error_msg(); $rawErrorBody = print_r($body, true); diff --git a/src/Services/Rest/Curl/RestClient.php b/src/Services/Rest/Curl/RestClient.php index bf5b526e..77a3e4a0 100644 --- a/src/Services/Rest/Curl/RestClient.php +++ b/src/Services/Rest/Curl/RestClient.php @@ -12,17 +12,15 @@ /** * RestClient based on CURL - * - * Class RestClient */ class RestClient implements RestInterface { - const METHOD_GET = 'GET'; - const METHOD_PUT = 'PUT'; - const METHOD_POST = 'POST'; - const METHOD_DELETE = 'DELETE'; + private const METHOD_GET = 'GET'; + private const METHOD_PUT = 'PUT'; + private const METHOD_POST = 'POST'; + private const METHOD_DELETE = 'DELETE'; - const USER_AGENT = 'sw-cli-tools/1.0'; + private const USER_AGENT = 'sw-cli-tools/1.0'; /** * @var array @@ -55,7 +53,7 @@ class RestClient implements RestInterface public function __construct($apiUrl, $username = '', $apiKey = '', $curlOptions = []) { if (!filter_var($apiUrl, FILTER_VALIDATE_URL)) { - throw new \Exception('Invalid URL given'); + throw new \RuntimeException('Invalid URL given'); } $this->apiUrl = rtrim($apiUrl, '/') . '/'; @@ -64,7 +62,7 @@ public function __construct($apiUrl, $username = '', $apiKey = '', $curlOptions $this->cURL = curl_init(); curl_setopt($this->cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->cURL, CURLOPT_FOLLOWLOCATION, false); - if ($username != '' && $apiKey != '') { + if ($username !== '' && $apiKey !== '') { curl_setopt($this->cURL, CURLOPT_USERPWD, $username . ':' . $apiKey); } curl_setopt($this->cURL, CURLOPT_USERAGENT, self::USER_AGENT); @@ -75,19 +73,12 @@ public function __construct($apiUrl, $username = '', $apiKey = '', $curlOptions /** * Generic call method to perform an HTTP request with the given $method * - * @param string $url - * @param string $method - * @param array $parameters - * @param array $headers - * * @throws \Exception - * - * @return Response */ - public function call($url, $method = self::METHOD_GET, $parameters = [], $headers = []) + public function call(string $url, string $method = self::METHOD_GET, array $parameters = [], array $headers = []): Response { - if (!in_array($method, $this->validMethods)) { - throw new \Exception('Invalid HTTP method: ' . $method); + if (!\in_array($method, $this->validMethods, true)) { + throw new \RuntimeException('Invalid HTTP method: ' . $method); } $url = $this->apiUrl . $url; @@ -96,12 +87,7 @@ public function call($url, $method = self::METHOD_GET, $parameters = [], $header curl_setopt($this->cURL, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($this->cURL, CURLOPT_POSTFIELDS, $dataString); - $headers = array_merge( - [ - 'Content-Type: application/json; charset=utf-8', - ], - $headers - ); + array_unshift($headers, 'Content-Type: application/json; charset=utf-8'); curl_setopt($this->cURL, CURLOPT_HTTPHEADER, $headers); $body = curl_exec($this->cURL); diff --git a/src/Services/Rest/ResponseInterface.php b/src/Services/Rest/ResponseInterface.php index 79de59f0..e78e0f81 100644 --- a/src/Services/Rest/ResponseInterface.php +++ b/src/Services/Rest/ResponseInterface.php @@ -14,7 +14,7 @@ interface ResponseInterface * If an error occurred during request, it should be available here. * Else null should be returned * - * @return null|string + * @return string|null */ public function getErrorMessage(); @@ -34,8 +34,6 @@ public function getRawBody(); /** * Returns the decoded response body - * - * @return mixed */ public function getResult(); } diff --git a/src/Services/Rest/RestInterface.php b/src/Services/Rest/RestInterface.php index 827d1c09..98accb09 100644 --- a/src/Services/Rest/RestInterface.php +++ b/src/Services/Rest/RestInterface.php @@ -10,8 +10,6 @@ /** * General interfaces for REST classes - * - * Class RestInterface */ interface RestInterface { diff --git a/src/Services/Rest/RestServiceFactory.php b/src/Services/Rest/RestServiceFactory.php index f166ab02..411c3ca7 100644 --- a/src/Services/Rest/RestServiceFactory.php +++ b/src/Services/Rest/RestServiceFactory.php @@ -13,8 +13,6 @@ /** * Factory for cache decorated rest services - * - * Class RestServiceFactory */ class RestServiceFactory { @@ -32,15 +30,19 @@ public function __construct($container) } /** - * @param string $baseUrl * @param string $username * @param string $password - * @param int $cacheTime - * - * @return RestInterface */ - public function factory($baseUrl, $username = null, $password = null, $cacheTime = 3600) - { - return new CacheDecorator(new RestClient($baseUrl, $username, $password), $this->container->get('cache'), $cacheTime); + public function factory( + string $baseUrl, + ?string $username = null, + ?string $password = null, + int $cacheTime = 3600 + ): RestInterface { + return new CacheDecorator( + new RestClient($baseUrl, $username, $password), + $this->container->get('cache'), + $cacheTime + ); } } diff --git a/src/Services/ShopwareInfo.php b/src/Services/ShopwareInfo.php index f7c571d8..3ea3a54a 100644 --- a/src/Services/ShopwareInfo.php +++ b/src/Services/ShopwareInfo.php @@ -12,12 +12,10 @@ * Provides general info about shopware installations. * * Will take care of version dependent things. - * - * Class ShopwareInfo */ class ShopwareInfo { - public function getCacheDir($path) + public function getCacheDir($path): string { $path = $this->normalizePath($path); @@ -32,7 +30,7 @@ public function getCacheDir($path) throw new \RuntimeException('Cache path not found'); } - public function getLogDir($path) + public function getLogDir($path): string { $path = $this->normalizePath($path); @@ -47,22 +45,17 @@ public function getLogDir($path) throw new \RuntimeException('Log path not found'); } - public function getMediaDir($path) + public function getMediaDir($path): string { return $this->normalizePath($path) . 'media'; } - public function getFilesDir($path) + public function getFilesDir($path): string { return $this->normalizePath($path) . 'files'; } - /** - * @param $path - * - * @return string - */ - private function normalizePath($path) + private function normalizePath($path): string { return rtrim($path, '/\\') . '/'; } diff --git a/src/Services/StreamFileDownloader.php b/src/Services/StreamFileDownloader.php index 0cc90ca0..d2b4d285 100644 --- a/src/Services/StreamFileDownloader.php +++ b/src/Services/StreamFileDownloader.php @@ -8,21 +8,15 @@ namespace ShopwareCli\Services; -/** - * Class FileDownloader - */ class StreamFileDownloader implements FileDownloader { - const BLOCKSIZE = 8192; + private const BLOCKSIZE = 8192; /** * @var IoService */ private $ioService; - /** - * @param IoService $ioService - */ public function __construct(IoService $ioService) { $this->ioService = $ioService; @@ -36,11 +30,11 @@ public function __construct(IoService $ioService) */ public function download($sourceUrl, $destination) { - if (false === $readHandle = fopen($sourceUrl, 'rb')) { + if ($readHandle = fopen($sourceUrl, 'rb') === false) { throw new \RuntimeException(sprintf("Could not open URL '%s'.", $sourceUrl)); } - if (false === $writeHandle = fopen($destination, 'wb')) { + if ($writeHandle = fopen($destination, 'wb') === false) { throw new \RuntimeException(sprintf('Could not write file: %s.', $destination)); } @@ -56,7 +50,7 @@ public function download($sourceUrl, $destination) while (!feof($readHandle)) { $currentSize += fwrite($writeHandle, fread($readHandle, self::BLOCKSIZE)); - $progress->setCurrent($currentSize / 1024); + $progress->setProgress($currentSize / 1024); } $progress->finish(); @@ -68,17 +62,15 @@ public function download($sourceUrl, $destination) /** * @param resource $readHandle - * - * @return int */ - private function getContentLengthFromStream($readHandle) + private function getContentLengthFromStream($readHandle): int { $info = stream_get_meta_data($readHandle); $size = 0; foreach ($info['wrapper_data'] as $field) { if (stripos($field, 'content-length') !== false) { - list($header, $size) = explode(':', $field); + [, $size] = explode(':', $field); } } diff --git a/src/Services/ZipUtil/Adapter.php b/src/Services/ZipUtil/Adapter.php index 4502edc4..34813a10 100644 --- a/src/Services/ZipUtil/Adapter.php +++ b/src/Services/ZipUtil/Adapter.php @@ -11,9 +11,6 @@ use Countable; use SeekableIterator; -/** - * Class Adapter - */ abstract class Adapter implements SeekableIterator, Countable { /** diff --git a/src/Services/ZipUtil/Entry/Zip.php b/src/Services/ZipUtil/Entry/Zip.php index bbce1ad4..a679db6e 100644 --- a/src/Services/ZipUtil/Entry/Zip.php +++ b/src/Services/ZipUtil/Entry/Zip.php @@ -10,9 +10,6 @@ use ZipArchive; -/** - * Class ZipArchive - */ class Zip { /** @@ -49,34 +46,22 @@ public function getStream() return $this->stream->getStream($this->name); } - /** - * @return mixed - */ public function getContents() { return $this->stream->getFromIndex($this->position); } - /** - * @return bool - */ - public function isDir() + public function isDir(): bool { return substr($this->name, -1) === '/'; } - /** - * @return bool - */ - public function isFile() + public function isFile(): bool { return substr($this->name, -1) !== '/'; } - /** - * @return string - */ - public function getName() + public function getName(): string { $name = $this->name; if (strpos($name, './') === 0) { diff --git a/src/Services/ZipUtil/Zip.php b/src/Services/ZipUtil/Zip.php index 0a7351f0..86eddd01 100644 --- a/src/Services/ZipUtil/Zip.php +++ b/src/Services/ZipUtil/Zip.php @@ -10,9 +10,6 @@ use ZipArchive; -/** - * Class Zip - */ class Zip extends Adapter { /** @@ -28,14 +25,14 @@ class Zip extends Adapter */ public function __construct($fileName = null, $flags = null) { - if (!extension_loaded('zip')) { - throw new \Exception('The PHP extension "zip" is not loaded.'); + if (!\extension_loaded('zip')) { + throw new \RuntimeException('The PHP extension "zip" is not loaded.'); } $this->stream = new ZipArchive(); - if ($fileName != null) { - if (true !== ($retval = $this->stream->open($fileName, $flags))) { + if ($fileName !== null) { + if (($retval = $this->stream->open($fileName, $flags)) !== true) { throw new \RuntimeException($this->getErrorMessage($retval, $fileName), $retval); } $this->position = 0; @@ -64,7 +61,7 @@ public function getStream($name) /** * @param string $name * - * @return mixed + * @return false|string */ public function getContents($name) { @@ -72,19 +69,14 @@ public function getContents($name) } /** - * @param $position - * - * @return mixed + * @return array|false */ public function getEntry($position) { return $this->stream->statIndex($position); } - /** - * @return bool - */ - public function close() + public function close(): bool { return $this->stream->close(); } @@ -97,7 +89,7 @@ public function close() * * @return string */ - protected function getErrorMessage($retval, $file) + protected function getErrorMessage($retval, $file): ?string { switch ($retval) { case ZipArchive::ER_EXISTS: diff --git a/src/Struct.php b/src/Struct.php index 794df4b5..02ed8450 100644 --- a/src/Struct.php +++ b/src/Struct.php @@ -10,14 +10,9 @@ /** * Base struct with a simple constructor allowing to create a struct by array - * - * Class Struct */ abstract class Struct { - /** - * @param array $values - */ public function __construct(array $values = []) { foreach ($values as $name => $value) { @@ -32,18 +27,17 @@ public function __construct(array $values = []) */ public function __get($name) { - throw new \OutOfRangeException("Unknown property \${$name} in " . get_class($this) . '.'); + throw new \OutOfRangeException("Unknown property \${$name} in " . \get_class($this) . '.'); } /** * @param string $name - * @param $value * * @throws \OutOfRangeException */ public function __set($name, $value) { - throw new \OutOfRangeException("Unknown property \${$name} in " . get_class($this) . '.'); + throw new \OutOfRangeException("Unknown property \${$name} in " . \get_class($this) . '.'); } /** @@ -53,6 +47,6 @@ public function __set($name, $value) */ public function __unset($name) { - throw new \OutOfRangeException("Unknown property \${$name} in " . get_class($this) . '.'); + throw new \OutOfRangeException("Unknown property \${$name} in " . \get_class($this) . '.'); } } diff --git a/src/Utilities.php b/src/Utilities.php index 53af43e2..c0d05270 100644 --- a/src/Utilities.php +++ b/src/Utilities.php @@ -26,10 +26,8 @@ public function __construct(IoService $ioService) * Checks if a given path is a Shopware 5 installation * * @param string $path - * - * @return bool */ - public function isShopware5Installation($path) + public function isShopware5Installation($path): bool { return is_readable($path . '/shopware.php'); } @@ -38,10 +36,8 @@ public function isShopware5Installation($path) * Checks if a given path is a Shopware 6 installation * * @param string $path - * - * @return bool */ - public function isShopware6Installation($path) + public function isShopware6Installation($path): bool { return is_dir($path . '/vendor/shopware/platform') || is_dir($path . '/vendor/shopware/core'); } @@ -50,10 +46,8 @@ public function isShopware6Installation($path) * Ask for a valid Shopware path until the user enters it * * @param string|null $shopwarePath - * - * @return string */ - public function getValidShopwarePath($shopwarePath = null) + public function getValidShopwarePath($shopwarePath = null): string { if ($shopwarePath === null) { $shopwarePath = realpath(getcwd()); @@ -79,10 +73,8 @@ public function getValidShopwarePath($shopwarePath = null) * @param string $shopwarePath * * @throws \RuntimeException - * - * @return string */ - public function validateShopwarePath($shopwarePath) + public function validateShopwarePath($shopwarePath): string { $shopwarePathReal = realpath($shopwarePath); @@ -106,7 +98,7 @@ public function validateShopwarePath($shopwarePath) * * @throws \RuntimeException */ - public function changeDir($path) + public function changeDir($path): void { if (!chdir($path)) { throw new \RuntimeException("Could not cd into '$path''"); diff --git a/tests/ApplicationTestCaseTrait.php b/tests/ApplicationTestCaseTrait.php index aaec21b6..2b382997 100644 --- a/tests/ApplicationTestCaseTrait.php +++ b/tests/ApplicationTestCaseTrait.php @@ -17,10 +17,7 @@ trait ApplicationTestCaseTrait */ private static $application; - /** - * @return Application - */ - public static function getApplication() + public static function getApplication(): Application { if (!self::$application) { self::bootApplication(); @@ -29,7 +26,7 @@ public static function getApplication() return self::$application; } - public static function bootApplication() + public static function bootApplication(): void { self::$application = new Application(\TestLoaderProvider::getLoader()); } @@ -37,7 +34,7 @@ public static function bootApplication() /** * @after */ - protected function destoryApplicationAfter() + protected function destroyApplicationAfter(): void { self::$application = false; } diff --git a/tests/CommandTestCaseTrait.php b/tests/CommandTestCaseTrait.php index 08e914f0..deccf3fe 100644 --- a/tests/CommandTestCaseTrait.php +++ b/tests/CommandTestCaseTrait.php @@ -20,10 +20,8 @@ trait CommandTestCaseTrait * in a numeric indexed array. * * @param string $command - * - * @return array */ - public function runCommand($command) + public function runCommand($command): array { $fp = tmpfile(); $input = new StringInput($command); @@ -36,12 +34,7 @@ public function runCommand($command) return explode(PHP_EOL, $consoleOutput); } - /** - * @param $fp - * - * @return string - */ - private function readConsoleOutput($fp) + private function readConsoleOutput($fp): string { fseek($fp, 0); $output = ''; diff --git a/tests/Functional/ConfigFilesTest/ConfigFileCollectorTest.php b/tests/Functional/ConfigFilesTest/ConfigFileCollectorTest.php index aa257b9c..1894a964 100644 --- a/tests/Functional/ConfigFilesTest/ConfigFileCollectorTest.php +++ b/tests/Functional/ConfigFilesTest/ConfigFileCollectorTest.php @@ -8,32 +8,35 @@ namespace ShopwareCli\Tests\Functional\ConfigFileTest; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; use ShopwareCli\ConfigFileCollector; +use ShopwareCli\Services\PathProvider\PathProvider; -class ConfigFileCollectorTest extends \PHPUnit_Framework_TestCase +class ConfigFileCollectorTest extends TestCase { - public function testSome() + public function testSome(): void { $testDir = __DIR__ . '/_fixtures'; - $pathProvider = $this->getMockBuilder('ShopwareCli\Services\PathProvider\PathProvider') + /** @var PathProvider|MockObject $pathProvider */ + $pathProvider = $this->getMockBuilder(PathProvider::class) ->disableOriginalConstructor() ->getMock(); - $pathProvider->expects($this->once()) + $pathProvider->expects(static::once()) ->method('getConfigPath') - ->will($this->returnValue(__DIR__)); + ->willReturn(__DIR__); - $pathProvider->expects($this->once()) + $pathProvider->expects(static::once()) ->method('getExtensionPath') - ->will($this->returnValue($testDir)); + ->willReturn($testDir); - $pathProvider->expects($this->once()) + $pathProvider->expects(static::once()) ->method('getCliToolPath') - ->will($this->returnValue($testDir)); + ->willReturn($testDir); - $SUT = new ConfigFileCollector($pathProvider); - $result = $SUT->collectConfigFiles(); + $result = (new ConfigFileCollector($pathProvider))->collectConfigFiles(); $expectedResults = [ $testDir . '/VendorA/ExtB/config.yaml', @@ -42,7 +45,7 @@ public function testSome() ]; foreach ($expectedResults as $expectedResult) { - $this->assertContains($expectedResult, $result); + static::assertContains($expectedResult, $result); } } } diff --git a/tests/Functional/DirectoryGatewayTest.php b/tests/Functional/DirectoryGatewayTest.php index 010c65b9..4110a457 100644 --- a/tests/Functional/DirectoryGatewayTest.php +++ b/tests/Functional/DirectoryGatewayTest.php @@ -8,23 +8,24 @@ namespace ShopwareCli\Tests\Functional; +use PHPUnit\Framework\TestCase; use ShopwareCli\Services\PathProvider\DirectoryGateway\CliToolGateway; use ShopwareCli\Services\PathProvider\DirectoryGateway\XdgGateway; use XdgBaseDir\Xdg; -class DirectoryGatewayTest extends \PHPUnit_Framework_TestCase +class DirectoryGatewayTest extends TestCase { - public function testCliToolGateway() + public function testCliToolGateway(): void { $gateway = new CliToolGateway('/some/dir/'); - $this->assertEquals('/some/dir/extensions', $gateway->getExtensionDir()); - $this->assertEquals('/some/dir/assets', $gateway->getAssetsDir()); - $this->assertEquals('/some/dir/cache', $gateway->getCacheDir()); - $this->assertEquals('/some/dir', $gateway->getConfigDir()); + static::assertEquals('/some/dir/extensions', $gateway->getExtensionDir()); + static::assertEquals('/some/dir/assets', $gateway->getAssetsDir()); + static::assertEquals('/some/dir/cache', $gateway->getCacheDir()); + static::assertEquals('/some/dir', $gateway->getConfigDir()); } - public function testXdgGateway() + public function testXdgGateway(): void { putenv('HOME=/tmp/'); putenv('XDG_DATA_HOME=/tmp/xdg-data'); @@ -33,9 +34,9 @@ public function testXdgGateway() $gateway = new XdgGateway(new Xdg()); - $this->assertEquals('/tmp/xdg-config/sw-cli-tools/extensions', $gateway->getExtensionDir()); - $this->assertEquals('/tmp/xdg-data/sw-cli-tools/assets', $gateway->getAssetsDir()); - $this->assertEquals('/tmp/xdg-cache/sw-cli-tools', $gateway->getCacheDir()); - $this->assertEquals('/tmp/xdg-config/sw-cli-tools', $gateway->getConfigDir()); + static::assertEquals('/tmp/xdg-config/sw-cli-tools/extensions', $gateway->getExtensionDir()); + static::assertEquals('/tmp/xdg-data/sw-cli-tools/assets', $gateway->getAssetsDir()); + static::assertEquals('/tmp/xdg-cache/sw-cli-tools', $gateway->getCacheDir()); + static::assertEquals('/tmp/xdg-config/sw-cli-tools', $gateway->getConfigDir()); } } diff --git a/tests/Functional/IoServiceTest.php b/tests/Functional/IoServiceTest.php index 9170a3f5..f699e488 100644 --- a/tests/Functional/IoServiceTest.php +++ b/tests/Functional/IoServiceTest.php @@ -8,12 +8,13 @@ namespace ShopwareCli\Tests\Functional; +use PHPUnit\Framework\TestCase; use ShopwareCli\Services\IoService; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; -class IoServiceTest extends \PHPUnit_Framework_TestCase +class IoServiceTest extends TestCase { /** * @var ArrayInput @@ -25,7 +26,7 @@ class IoServiceTest extends \PHPUnit_Framework_TestCase */ private $output; - public function testShouldClearScreenInInteractiveMode() + public function testShouldClearScreenInInteractiveMode(): void { $SUT = $this->createSUT(); @@ -33,13 +34,13 @@ public function testShouldClearScreenInInteractiveMode() $SUT->cls(); - $this->assertEquals( - chr(27) . '[2J' . chr(27) . '[1;1H', + static::assertEquals( + \chr(27) . '[2J' . \chr(27) . '[1;1H', $this->output->fetch() ); } - public function testShouldNotClearScreenInNotInteractiveMode() + public function testShouldNotClearScreenInNotInteractiveMode(): void { $SUT = $this->createSUT(); @@ -47,24 +48,21 @@ public function testShouldNotClearScreenInNotInteractiveMode() $SUT->cls(); - $this->assertEquals( + static::assertEquals( '', $this->output->fetch() ); } - /** - * @return IoService - */ - private function createSUT() + private function createSUT(): IoService { - $this->input = $input = new ArrayInput([]); - $this->output = $output = new BufferedOutput(); + $this->input = new ArrayInput([]); + $this->output = new BufferedOutput(); $questionHelper = new QuestionHelper(); return new IoService( - $input, - $output, + $this->input, + $this->output, $questionHelper ); } diff --git a/tests/Functional/PluginCreator/LegacyOptionFileProviderLoaderTest.php b/tests/Functional/PluginCreator/LegacyOptionFileProviderLoaderTest.php index e459eac8..e5656acd 100644 --- a/tests/Functional/PluginCreator/LegacyOptionFileProviderLoaderTest.php +++ b/tests/Functional/PluginCreator/LegacyOptionFileProviderLoaderTest.php @@ -6,30 +6,27 @@ * file that was distributed with this source code. */ -namespace ShopwareCli\Tests\Functional\PluginCreater; +namespace ShopwareCli\Tests\Functional\PluginCreator; +use PHPUnit\Framework\TestCase; use Shopware\PluginCreator\Services\TemplateFileProvider\LegacyOptionFileProviderLoader; -class LegacyOptionFileProviderLoaderTest extends \PHPUnit_Framework_TestCase +class LegacyOptionFileProviderLoaderTest extends TestCase { - public function testLegacyLoad() + public function testLegacyLoad(): void { $expectedProviderAmount = 11; $isLegacy = true; - $loader = new LegacyOptionFileProviderLoader($isLegacy); + $result = (new LegacyOptionFileProviderLoader($isLegacy))->load(); - $result = $loader->load(); - - $this->assertEquals($expectedProviderAmount, count($result)); + static::assertCount($expectedProviderAmount, $result); } - public function testCurrentLoad() + public function testCurrentLoad(): void { $expectedProviderAmount = 11; $isLegacy = false; - $loader = new LegacyOptionFileProviderLoader($isLegacy); - - $result = $loader->load(); - $this->assertEquals($expectedProviderAmount, count($result)); + $result = (new LegacyOptionFileProviderLoader($isLegacy))->load(); + static::assertCount($expectedProviderAmount, $result); } } diff --git a/tests/Functional/PluginCreator/OutputDirectoryProvider/CurrentOutputDirectoryProviderTest.php b/tests/Functional/PluginCreator/OutputDirectoryProvider/CurrentOutputDirectoryProviderTest.php index 66096ef0..2ccc29e8 100644 --- a/tests/Functional/PluginCreator/OutputDirectoryProvider/CurrentOutputDirectoryProviderTest.php +++ b/tests/Functional/PluginCreator/OutputDirectoryProvider/CurrentOutputDirectoryProviderTest.php @@ -8,31 +8,33 @@ namespace ShopwareCli\Tests\Functional\PluginCreator\OutputDirectoryProvider; +use PHPUnit\Framework\TestCase; use Shopware\PluginCreator\Services\WorkingDirectoryProvider\CurrentOutputDirectoryProvider; +use Shopware\PluginCreator\Services\WorkingDirectoryProvider\RootDetector\ShopwareRootDetector; -class CurrentOutputDirectoryProviderTest extends \PHPUnit_Framework_TestCase +class CurrentOutputDirectoryProviderTest extends TestCase { - const PLUGIN_NAME = 'SwagTest'; + private const PLUGIN_NAME = 'SwagTest'; - public function testGetCurrentPath() + public function testGetCurrentPath(): void { $expectedPath = getcwd() . '/custom/plugins/' . self::PLUGIN_NAME . '/'; - $shopwareRootDetectorStub = $this->getMock('Shopware\PluginCreator\Services\WorkingDirectoryProvider\RootDetector\ShopwareRootDetector'); + $shopwareRootDetectorStub = $this->createMock(ShopwareRootDetector::class); $shopwareRootDetectorStub->method('isRoot') ->willReturn(true); $currentOutputDirectoryProvider = new CurrentOutputDirectoryProvider($shopwareRootDetectorStub, self::PLUGIN_NAME); $path = $currentOutputDirectoryProvider->getPath(); - $this->assertEquals($expectedPath, $path); + static::assertEquals($expectedPath, $path); } - public function testGetPathIfNotExecutedFromShopwareRootFolder() + public function testGetPathIfNotExecutedFromShopwareRootFolder(): void { $expectedPath = getcwd() . '/' . self::PLUGIN_NAME . '/'; - $shopwareRootDetectorStub = $this->getMock('Shopware\PluginCreator\Services\WorkingDirectoryProvider\RootDetector\ShopwareRootDetector'); + $shopwareRootDetectorStub = $this->createMock(ShopwareRootDetector::class); $shopwareRootDetectorStub->method('isRoot') ->willReturn(false); @@ -40,6 +42,6 @@ public function testGetPathIfNotExecutedFromShopwareRootFolder() $path = $currentOutputDirectoryProvider->getPath(); - $this->assertEquals($expectedPath, $path); + static::assertEquals($expectedPath, $path); } } diff --git a/tests/Functional/PluginCreator/OutputDirectoryProvider/LegacyOutputDirectoryProviderTest.php b/tests/Functional/PluginCreator/OutputDirectoryProvider/LegacyOutputDirectoryProviderTest.php index 01ace90a..bd9370e4 100644 --- a/tests/Functional/PluginCreator/OutputDirectoryProvider/LegacyOutputDirectoryProviderTest.php +++ b/tests/Functional/PluginCreator/OutputDirectoryProvider/LegacyOutputDirectoryProviderTest.php @@ -8,17 +8,19 @@ namespace ShopwareCli\Tests\Functional\PluginCreator\OutputDirectoryProvider; +use PHPUnit\Framework\TestCase; use Shopware\PluginCreator\Services\WorkingDirectoryProvider\LegacyOutputDirectoryProvider; +use Shopware\PluginCreator\Services\WorkingDirectoryProvider\RootDetector\ShopwareRootDetector; -class LegacyOutputDirectoryProviderTest extends \PHPUnit_Framework_TestCase +class LegacyOutputDirectoryProviderTest extends TestCase { - const PLUGIN_NAME = 'SwagTest'; + private const PLUGIN_NAME = 'SwagTest'; - public function testGetLegacyPath() + public function testGetLegacyPath(): void { $expectedPath = getcwd() . '/engine/Shopware/Plugins/Local/Frontend/' . self::PLUGIN_NAME . '/'; - $shopwareRootDetectorStub = $this->getMock('Shopware\PluginCreator\Services\WorkingDirectoryProvider\RootDetector\ShopwareRootDetector'); + $shopwareRootDetectorStub = $this->createMock(ShopwareRootDetector::class); $shopwareRootDetectorStub->method('isRoot') ->willReturn(true); @@ -30,14 +32,14 @@ public function testGetLegacyPath() $path = $legacyOutputDirectoryProvider->getPath(); - $this->assertEquals($expectedPath, $path); + static::assertEquals($expectedPath, $path); } - public function testGetLegacyPathIfNotExecutedFromShopwareRoot() + public function testGetLegacyPathIfNotExecutedFromShopwareRoot(): void { $expectedPath = getcwd() . '/' . self::PLUGIN_NAME . '/'; - $shopwareRootDetectorStub = $this->getMock('Shopware\PluginCreator\Services\WorkingDirectoryProvider\RootDetector\ShopwareRootDetector'); + $shopwareRootDetectorStub = $this->createMock(ShopwareRootDetector::class); $shopwareRootDetectorStub->method('isRoot') ->willReturn(false); @@ -49,6 +51,6 @@ public function testGetLegacyPathIfNotExecutedFromShopwareRoot() $path = $legacyOutputDirectoryProvider->getPath(); - $this->assertEquals($expectedPath, $path); + static::assertEquals($expectedPath, $path); } } diff --git a/tests/Functional/PluginCreator/OutputDirectoryProvider/RootDetector/ShopwareRootDetectorTest.php b/tests/Functional/PluginCreator/OutputDirectoryProvider/RootDetector/ShopwareRootDetectorTest.php index d0587381..66abb4d9 100644 --- a/tests/Functional/PluginCreator/OutputDirectoryProvider/RootDetector/ShopwareRootDetectorTest.php +++ b/tests/Functional/PluginCreator/OutputDirectoryProvider/RootDetector/ShopwareRootDetectorTest.php @@ -5,22 +5,26 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + +namespace ShopwareCli\Tests\Functional\PluginCreator\OutputDirectoryProvider\RootDetector; + +use PHPUnit\Framework\TestCase; use Shopware\PluginCreator\Services\WorkingDirectoryProvider\RootDetector\ShopwareRootDetector; -class ShopwareRootDetectorTest extends \PHPUnit_Framework_TestCase +class ShopwareRootDetectorTest extends TestCase { /** * @var ShopwareRootDetector */ private $SUT; - protected function setUp() + protected function setUp(): void { $this->createRootFolder(); $this->SUT = new ShopwareRootDetector(); } - protected function tearDown() + protected function tearDown(): void { foreach (ShopwareRootDetector::getDirectories() as $directory) { rmdir(self::getTestRoot() . $directory); @@ -32,24 +36,24 @@ protected function tearDown() rmdir(self::getTestRoot()); } - public function testPathIsShopwareRoot() + public function testPathIsShopwareRoot(): void { $return = $this->SUT->isRoot(self::getTestRoot()); - $this->assertTrue($return); + static::assertTrue($return); } - public function testPathIsNotShopwareRoot() + public function testPathIsNotShopwareRoot(): void { $return = $this->SUT->isRoot('/home/not_shopware'); - $this->assertFalse($return); + static::assertFalse($return); } - private static function getTestRoot() + private static function getTestRoot(): string { return __DIR__ . '/testroot'; } - private function createRootFolder() + private function createRootFolder(): void { mkdir(self::getTestRoot()); foreach (ShopwareRootDetector::getDirectories() as $directory) { diff --git a/tests/Functional/PluginCreator/PluginCreateTest.php b/tests/Functional/PluginCreator/PluginCreateTest.php index 7edea8a5..76b11504 100644 --- a/tests/Functional/PluginCreator/PluginCreateTest.php +++ b/tests/Functional/PluginCreator/PluginCreateTest.php @@ -6,26 +6,31 @@ * file that was distributed with this source code. */ -namespace ShopwareCli\Tests\Functional; +namespace ShopwareCli\Tests\Functional\PluginCreator; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; use Shopware\PluginCreator\Services\Generator; use Shopware\PluginCreator\Services\IoAdapter\Dummy; use Shopware\PluginCreator\Services\NameGenerator; use Shopware\PluginCreator\Services\Template; use Shopware\PluginCreator\Services\TemplateFileProvider\FileProviderInterface; use Shopware\PluginCreator\Services\TemplateFileProvider\LegacyOptionFileProviderLoader; +use Shopware\PluginCreator\Services\WorkingDirectoryProvider\CurrentOutputDirectoryProvider; +use Shopware\PluginCreator\Services\WorkingDirectoryProvider\LegacyOutputDirectoryProvider; use Shopware\PluginCreator\Services\WorkingDirectoryProvider\OutputDirectoryProviderInterface; use Shopware\PluginCreator\Struct\Configuration; -class PluginCreateTest extends \PHPUnit_Framework_TestCase +class PluginCreateTest extends TestCase { /** * Foreach file provider: Create a plugin which needs this file provider and check, * if all required / pre-defined files actually exists. */ - public function testFileProvider() + public function testFileProvider(): void { - $currentOutputDirectoryProvider = $this->getMockBuilder('Shopware\PluginCreator\Services\WorkingDirectoryProvider\CurrentOutputDirectoryProvider') + /** @var CurrentOutputDirectoryProvider|MockObject $currentOutputDirectoryProvider */ + $currentOutputDirectoryProvider = $this->getMockBuilder(CurrentOutputDirectoryProvider::class) ->disableOriginalConstructor() ->getMock(); @@ -45,9 +50,10 @@ public function testFileProvider() /** * Test each file provider with legacy files. */ - public function testLegacyFileProvider() + public function testLegacyFileProvider(): void { - $legacyOutputDirectoryProvider = $this->getMockBuilder('Shopware\PluginCreator\Services\WorkingDirectoryProvider\LegacyOutputDirectoryProvider') + /** @var LegacyOutputDirectoryProvider|MockObject $legacyOutputDirectoryProvider */ + $legacyOutputDirectoryProvider = $this->getMockBuilder(LegacyOutputDirectoryProvider::class) ->disableOriginalConstructor() ->getMock(); @@ -70,10 +76,8 @@ public function testLegacyFileProvider() * * name (array key + "$FileProvider") * * config flag that will trigger this file provider * * array of files (key = source template, value = target file) - * - * @return array */ - protected function getFileProvider() + protected function getFileProvider(): array { return [ 'Api' => [ @@ -181,10 +185,7 @@ protected function getFileProvider() ]; } - /** - * @return array - */ - protected function getLegacyFileProvider() + protected function getLegacyFileProvider(): array { return [ 'Api' => [ @@ -283,10 +284,7 @@ protected function getLegacyFileProvider() ]; } - /** - * @return Configuration - */ - private function getConfigObject() + private function getConfigObject(): Configuration { $config = new Configuration(); @@ -301,18 +299,12 @@ private function getConfigObject() return $config; } - /** - * @param Configuration $config - * @param array $provider - * @param array $fileProviders - * @param OutputDirectoryProviderInterface $outputDirectoryProvider - */ private function providerTest( Configuration $config, array $provider, array $fileProviders, OutputDirectoryProviderInterface $outputDirectoryProvider - ) { + ): void { $ioAdapter = new Dummy(); $generator = new Generator( $ioAdapter, @@ -327,8 +319,8 @@ private function providerTest( // Test, if the file provider files, do exist foreach ($provider['files'] as $file) { - $this->assertTrue( - in_array($file, array_keys($ioAdapter->getFiles())), + static::assertTrue( + \array_key_exists($file, $ioAdapter->getFiles()), "{$file} not found in generated files" ); } @@ -336,17 +328,19 @@ private function providerTest( // merge all provider files into one array $allProviderFiles = array_reduce( array_column($fileProviders, 'files'), - function ($a, $b) { + static function ($a, $b) { $a = $a ?: []; $b = $b ?: []; return array_merge($a, $b); - }); + } + ); // Test, if existing files are defined by a file provider foreach (array_keys($ioAdapter->getFiles()) as $file) { - $this->assertTrue( - in_array($file, $allProviderFiles), + static::assertContains( + $file, + $allProviderFiles, "{$file} is not defined by any file provider" ); } diff --git a/tests/Functional/ProcessExecutorTest.php b/tests/Functional/ProcessExecutorTest.php index ecaa7213..f30d0464 100644 --- a/tests/Functional/ProcessExecutorTest.php +++ b/tests/Functional/ProcessExecutorTest.php @@ -8,39 +8,39 @@ namespace ShopwareCli\Tests\Functional; +use PHPUnit\Framework\TestCase; use ShopwareCli\Services\ProcessExecutor; use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Process\Exception\ProcessTimedOutException; -class ProcessExecutorTest extends \PHPUnit_Framework_TestCase +class ProcessExecutorTest extends TestCase { - public function testCliToolGateway() + public function testCliToolGateway(): void { $output = new BufferedOutput(); $executor = new ProcessExecutor($output, 60); $exitCode = $executor->execute('true'); - $this->assertEquals(0, $exitCode); - $this->assertEquals('', $output->fetch()); + static::assertEquals(0, $exitCode); + static::assertEquals('', $output->fetch()); $exitCode = $executor->execute('echo foo'); - $this->assertEquals(0, $exitCode); - $this->assertEquals("foo\n", $output->fetch()); + static::assertEquals(0, $exitCode); + static::assertEquals("foo\n", $output->fetch()); } - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Command failed. Error Output: - * @expectedExceptionCode 1 - */ - public function testFailedCommand() + public function testFailedCommand(): void { $output = new BufferedOutput(); $executor = new ProcessExecutor($output, 60); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Command failed. Error Output:'); + $this->expectExceptionCode(1); $executor->execute('false'); } - public function testFailedCommand2() + public function testFailedCommand2(): void { $output = new BufferedOutput(); $executor = new ProcessExecutor($output, 60); @@ -49,17 +49,17 @@ public function testFailedCommand2() try { $executor->execute('LC_ALL=C ls /no-such-file'); } catch (\Exception $e) { - $this->assertEquals(2, $e->getCode()); - $this->assertContains($expectedOutput, $e->getMessage()); - $this->assertContains($expectedOutput, $output->fetch()); + static::assertEquals(2, $e->getCode()); + static::assertStringContainsString($expectedOutput, $e->getMessage()); + static::assertStringContainsString($expectedOutput, $output->fetch()); return; } - $this->fail('Executor should throw exception on failed command'); + static::fail('Executor should throw exception on failed command'); } - public function testAllowFailingCommand() + public function testAllowFailingCommand(): void { $output = new BufferedOutput(); $executor = new ProcessExecutor($output, 60); @@ -68,20 +68,20 @@ public function testAllowFailingCommand() $exitCode = $executor->execute('LC_ALL=C ls /no-such-file', null, true); - $this->assertEquals(2, $exitCode); - $this->assertContains($expectedOutput, $output->fetch()); + static::assertEquals(2, $exitCode); + static::assertStringContainsString($expectedOutput, $output->fetch()); } /** * @group slow - * @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException - * @expectedExceptionMessage The process "sleep 2" exceeded the timeout of 1 seconds. */ - public function testTimeout() + public function testTimeout(): void { $output = new BufferedOutput(); $executor = new ProcessExecutor($output, 1); + $this->expectException(ProcessTimedOutException::class); + $this->expectExceptionMessage('The process "sleep 2" exceeded the timeout of 1 seconds.'); $executor->execute('sleep 2', null, true); } } diff --git a/tests/Functional/TimeoutTest.php b/tests/Functional/TimeoutTest.php index 0bcd390b..5099bd18 100644 --- a/tests/Functional/TimeoutTest.php +++ b/tests/Functional/TimeoutTest.php @@ -5,28 +5,46 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -class TimeoutTest extends PHPUnit_Framework_TestCase + +use PHPUnit\Framework\TestCase; +use ShopwareCli\Application\DependencyInjection; +use ShopwareCli\Services\GitUtil; +use ShopwareCli\Services\ProcessExecutor; +use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +/** + * (c) shopware AG + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +class TimeoutTest extends TestCase { - public function getContainer() + public function getContainer(): ContainerBuilder { - $di = \ShopwareCli\Application\DependencyInjection::createContainer(__DIR__); + $di = DependencyInjection::createContainer(__DIR__); - $di->set('output_interface', new \Symfony\Component\Console\Output\NullOutput()); + $di->set('output_interface', new NullOutput()); return $di; } - public function testProcessExecutorTimeout() + public function testProcessExecutorTimeout(): void { putenv('SW_TIMEOUT=999'); + /** @var ProcessExecutor $executor */ $executor = $this->getContainer()->get('process_executor'); - $this->assertAttributeEquals('999', 'timeout', $executor); + + static::assertSame(999, $executor->getTimeout()); } - public function testGitUtilTimeout() + public function testGitUtilTimeout(): void { putenv('SW_TIMEOUT=123'); + /** @var GitUtil $util */ $util = $this->getContainer()->get('git_util'); - $this->assertAttributeEquals('123', 'timeout', $util); + + static::assertSame(123, $util->getTimeout()); } } diff --git a/tests/Unit/ConfigTest.php b/tests/Unit/ConfigTest.php index 52103ff2..a4895942 100644 --- a/tests/Unit/ConfigTest.php +++ b/tests/Unit/ConfigTest.php @@ -8,68 +8,69 @@ namespace ShopwareCli\Tests\Unit; +use PHPUnit\Framework\TestCase; use ShopwareCli\Config; use ShopwareCli\ConfigFileCollector; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends TestCase { - public function test_it_can_be_created() + public function test_it_can_be_created(): void { $config = new Config(new ConfigFileCollectorDummy()); - $this->assertInstanceOf(Config::class, $config); + static::assertInstanceOf(Config::class, $config); } - public function test_it_should_create_config_from_single_file() + public function test_it_should_create_config_from_single_file(): void { $config = new Config(new SingleConfigFileCollectorMock()); - $this->assertTrue($config->offsetExists('test')); - $this->assertEquals( + static::assertTrue($config->offsetExists('test')); + static::assertEquals( ['some_config' => 'some_value'], $config->offsetGet('test') ); } - public function test_it_should_create_config_from_multiple_files() + public function test_it_should_create_config_from_multiple_files(): void { $config = new Config(new MultiConfigFileCollectorMock()); - $this->assertEquals( + static::assertEquals( ['some_config1' => 'some_value1'], $config->offsetGet('config1') ); - $this->assertEquals( + static::assertEquals( ['some_config2' => 'some_value2'], $config->offsetGet('config2') ); } - public function test_it_should_override_first_config_file() + public function test_it_should_override_first_config_file(): void { $config = new Config(new OverrideConfigFileCollectorMock()); - $this->assertFileExists(__DIR__ . '/_fixtures/override_config1.yml'); - $this->assertEquals( + static::assertFileExists(__DIR__ . '/_fixtures/override_config1.yml'); + static::assertEquals( ['some_config' => 'override'], $config->offsetGet('config') ); } - public function test_it_should_merge_config_files() + public function test_it_should_merge_config_files(): void { $config = new Config(new MergeConfigFileCollectorMock()); - $this->assertEquals( + static::assertEquals( ['some_config' => 'some_value', 'merged_config' => 'merged_value'], $config->offsetGet('config') ); } - public function test_it_should_replace_and_merge_configs_recursive() + public function test_it_should_replace_and_merge_configs_recursive(): void { $config = new Config(new ExtendConfigFileCollectorMock()); - $this->assertEquals([ + static::assertEquals([ 'some_config' => 'override', 'extend_config' => 'extend', 'recursive' => [ @@ -88,7 +89,7 @@ public function __construct() { } - public function collectConfigFiles() + public function collectConfigFiles(): array { return []; } @@ -100,7 +101,7 @@ public function __construct() { } - public function collectConfigFiles() + public function collectConfigFiles(): array { return [ __DIR__ . '/_fixtures/single_config.yml', @@ -114,7 +115,7 @@ public function __construct() { } - public function collectConfigFiles() + public function collectConfigFiles(): array { return [ __DIR__ . '/_fixtures/multi_config1.yml', @@ -129,7 +130,7 @@ public function __construct() { } - public function collectConfigFiles() + public function collectConfigFiles(): array { return [ __DIR__ . '/_fixtures/override_config1.yml', @@ -144,7 +145,7 @@ public function __construct() { } - public function collectConfigFiles() + public function collectConfigFiles(): array { return [ __DIR__ . '/_fixtures/merge_config1.yml', @@ -159,7 +160,7 @@ public function __construct() { } - public function collectConfigFiles() + public function collectConfigFiles(): array { return [ __DIR__ . '/_fixtures/extend_config1.yml',