From 6b08fe537ab7980ac532cc33e57f64e3f5b5458f Mon Sep 17 00:00:00 2001 From: Tobias Zimmermann Date: Tue, 25 Jun 2019 15:04:53 +0200 Subject: [PATCH 1/8] Use latest version of stecman/symfony-console-completion --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 81085136..3b2e5509 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "symfony/flex": "^1.1", "symfony/dotenv": "^2.8|^3|^4.1", "ext-json": "*", - "stecman/symfony-console-completion": "^0.9.0", + "stecman/symfony-console-completion": "^0.10.0", "symfony/finder": "^4.1", "thibaud-dauce/mattermost-php": "^1.2", "twig/twig": "^2.5", From 1070795de341a4ea249609a4aa2e5c66045b155f Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Fri, 21 Jun 2019 16:34:49 +0200 Subject: [PATCH 2/8] Fix issue with special characters in the pw --- src/Method/FtpSyncMethod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Method/FtpSyncMethod.php b/src/Method/FtpSyncMethod.php index b6bcf0bc..a6322451 100644 --- a/src/Method/FtpSyncMethod.php +++ b/src/Method/FtpSyncMethod.php @@ -170,7 +170,7 @@ public function deploy(HostConfig $host_config, TaskContextInterface $context) $command_file = $host_config['tmpFolder'] . '/lftp_commands_' . time() . '.x'; $shell->run(sprintf('touch %s', $command_file)); $shell->run(sprintf( - 'echo "open -u %s,%s -p%s %s" >> %s', + "echo 'open -u %s,%s -p%s %s' >> %s", $host_config['ftp']['user'], $host_config['ftp']['password'], $host_config['ftp']['port'], From 28a04fb7e32d33757fae1926aaa91b96330836a1 Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Fri, 28 Jun 2019 17:41:10 +0200 Subject: [PATCH 3/8] Prevent filename collision when running docker copySSHKeys, fixes #52 --- src/Method/DockerMethod.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Method/DockerMethod.php b/src/Method/DockerMethod.php index e2132e95..27ae418d 100644 --- a/src/Method/DockerMethod.php +++ b/src/Method/DockerMethod.php @@ -256,6 +256,8 @@ private function copySSHKeys(HostConfig $hostconfig, TaskContextInterface $conte { $files = []; $temp_files = []; + $temp_nam_prefix = 'phab-' . md5($hostconfig['configName'] . mt_rand()); + // Backwards-compatibility: if ($file = $context->getConfigurationService()->getSetting('dockerAuthorizedKeyFile')) { @@ -304,7 +306,7 @@ private function copySSHKeys(HostConfig $hostconfig, TaskContextInterface $conte // If no authorized_keys file is set, then add all public keys from the agent into the container. if (empty($files['/root/.ssh/authorized_keys'])) { - $file = tempnam("/tmp", "phabalicious"); + $file = tempnam("/tmp", $temp_nam_prefix); try { $result = $shell->run(sprintf('#!ssh-add -L > %s', $file)); @@ -336,7 +338,7 @@ private function copySSHKeys(HostConfig $hostconfig, TaskContextInterface $conte if ((substr($data['source'], 0, 7) == 'http://') || (substr($data['source'], 0, 8) == 'https://')) { $content = $context->getConfigurationService()->readHttpResource($data['source']); - $temp_file = tempnam("/tmp", "phabalicious"); + $temp_file = tempnam("/tmp", $temp_nam_prefix); file_put_contents($temp_file, $content); $data['source'] = $temp_file; $temp_files[] = $temp_file; @@ -360,7 +362,7 @@ private function copySSHKeys(HostConfig $hostconfig, TaskContextInterface $conte } } - $temp_file = $docker_config['tmpFolder'] . '/' . 'phab.tmp.' . basename($data['source']); + $temp_file = $docker_config['tmpFolder'] . '/' . $temp_nam_prefix . '-' . basename($data['source']); $shell->putFile($data['source'], $temp_file, $context); $shell->run(sprintf('#!docker cp %s %s:%s', $temp_file, $container_name, $dest)); From 1f2292c2bedb0f940e979ad6c2a34139edd5b85f Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Fri, 28 Jun 2019 17:57:33 +0200 Subject: [PATCH 4/8] Fix drush and other commands when using local shell provider --- src/ShellProvider/LocalShellProvider.php | 9 +++++---- src/ShellProvider/SshShellProvider.php | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ShellProvider/LocalShellProvider.php b/src/ShellProvider/LocalShellProvider.php index 70f97359..516c4ff3 100644 --- a/src/ShellProvider/LocalShellProvider.php +++ b/src/ShellProvider/LocalShellProvider.php @@ -263,11 +263,12 @@ public function createTunnelProcess(HostConfig $target_config, array $prefix = [ */ public function wrapCommandInLoginShell(array $command) { - return [ + array_unshift( + $command, '/bin/bash', '--login', - '-c', - '\'' . implode(' ', $command). '\'', - ]; + '-c' + ); + return $command; } } diff --git a/src/ShellProvider/SshShellProvider.php b/src/ShellProvider/SshShellProvider.php index 96d68abf..e8cd8340 100644 --- a/src/ShellProvider/SshShellProvider.php +++ b/src/ShellProvider/SshShellProvider.php @@ -268,4 +268,17 @@ public function copyFileFrom( } return parent::copyFileFrom($from_shell, $source_file_name, $target_file_name, $context, $verbose); } + + /** + * {@inheritdoc} + */ + public function wrapCommandInLoginShell(array $command) + { + return [ + '/bin/bash', + '--login', + '-c', + '\'' . implode(' ', $command). '\'', + ]; + } } From 8e747dc764dba898b43747bacaf698ef8d065bc6 Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Sun, 7 Jul 2019 13:50:21 +0200 Subject: [PATCH 5/8] Satisfy phpstan and add it as a new precommit-hook --- .pre-commit-config.yaml | 12 + composer.json | 4 +- composer.lock | 1020 ++++++++++++++++- src/Command/AppScaffoldCommand.php | 4 +- src/Command/BaseCommand.php | 24 +- src/Command/BaseOptionsCommand.php | 2 +- src/Command/CompletionCommand.php | 2 +- src/Command/ListBlueprintsCommand.php | 23 +- src/Command/ListCommand.php | 23 +- src/Command/SelfUpdateCommand.php | 3 +- src/Configuration/BlueprintConfiguration.php | 13 +- src/Configuration/ConfigurationService.php | 19 +- .../UnknownReplacementPatternException.php | 10 +- src/Method/BaseMethod.php | 12 +- src/Method/BaseNotifyMethod.php | 11 +- src/Method/DockerMethod.php | 14 +- src/Method/DrupalconsoleMethod.php | 2 +- src/Method/DrushMethod.php | 2 +- src/Method/LocalMethod.php | 1 + src/Method/MatterMostNotificationMethod.php | 4 +- src/Method/MethodFactory.php | 32 +- src/Method/ScriptMethod.php | 21 +- src/Method/TaskContext.php | 10 +- src/Method/TaskContextInterface.php | 11 +- .../FishShellCompletionContext.php | 2 +- .../FishShellCompletionDescriptor.php | 4 +- src/ShellProvider/BaseShellProvider.php | 4 +- src/ShellProvider/CommandResult.php | 4 +- src/ShellProvider/DockerExecShellProvider.php | 2 +- src/ShellProvider/LocalShellProvider.php | 2 +- src/ShellProvider/SshShellProvider.php | 4 +- symfony.lock | 45 + tests/ScriptMethodTest.php | 102 +- 33 files changed, 1227 insertions(+), 221 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2aec5c81..1ab99c5c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,5 +11,17 @@ files: \.php$ args: - --standard=PSR2 -p + +- repo: local + hooks: + - id: phpstan + name: "PHPStan" + language: script + files: ^src/(.*)\.php$ + entry: ./vendor/bin/phpstan analyze --no-progress --error-format raw --level 4 + +- repo: https://github.com/digitalpulp/pre-commit-php.git + sha: 1.3.0 + hooks: - id: php-unit files: \.php$ diff --git a/composer.json b/composer.json index 3b2e5509..0fac0b3f 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,9 @@ }, "require-dev": { "symfony/phpunit-bridge": "^2.8|^3|^4.1", - "phpunit/phpunit": "^7.3" + "phpunit/phpunit": "^7.3", + "phpstan/phpstan": "^0.11.9", + "phpstan/phpstan-symfony": "^0.11.6" }, "autoload": { "psr-4": {"Phabalicious\\": "src/"} diff --git a/composer.lock b/composer.lock index 49d74a61..20e27fd4 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": "541fb263e53a32ebbcab8c0e1a3eb3cb", + "content-hash": "01824884920783e645d401709c59687e", "packages": [ { "name": "composer/ca-bundle", @@ -1002,16 +1002,16 @@ }, { "name": "stecman/symfony-console-completion", - "version": "0.9.0", + "version": "0.10.1", "source": { "type": "git", "url": "https://github.com/stecman/symfony-console-completion.git", - "reference": "bd07a24190541de2828c1d6469a8ddce599d3c5a" + "reference": "7bfa9b93e216896419f2f8de659935d7e04fecd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stecman/symfony-console-completion/zipball/bd07a24190541de2828c1d6469a8ddce599d3c5a", - "reference": "bd07a24190541de2828c1d6469a8ddce599d3c5a", + "url": "https://api.github.com/repos/stecman/symfony-console-completion/zipball/7bfa9b93e216896419f2f8de659935d7e04fecd8", + "reference": "7bfa9b93e216896419f2f8de659935d7e04fecd8", "shasum": "" }, "require": { @@ -1024,7 +1024,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.6.x-dev" + "dev-master": "0.10.x-dev" } }, "autoload": { @@ -1043,7 +1043,7 @@ } ], "description": "Automatic BASH completion for Symfony Console Component based applications.", - "time": "2019-01-19T21:25:25+00:00" + "time": "2019-04-29T03:20:18+00:00" }, { "name": "symfony/config", @@ -2221,107 +2221,826 @@ } ], "packages-dev": [ + { + "name": "composer/xdebug-handler", + "version": "1.3.3", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/46867cbf8ca9fb8d60c506895449eb799db1184f", + "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2019-05-27T17:52:04+00:00" + }, { "name": "doctrine/instantiator", "version": "1.1.0", "source": { "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "url": "https://github.com/doctrine/instantiator.git", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2017-07-22T11:58:36+00:00" + }, + { + "name": "jean85/pretty-package-versions", + "version": "1.2", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48", + "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48", + "shasum": "" + }, + "require": { + "ocramius/package-versions": "^1.2.0", + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A wrapper for ocramius/package-versions to get pretty versions strings", + "keywords": [ + "composer", + "package", + "release", + "versions" + ], + "time": "2018-06-13T13:22:40+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "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": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2018-06-11T23:09:50+00:00" + }, + { + "name": "nette/bootstrap", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/nette/bootstrap.git", + "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/e1075af05c211915e03e0c86542f3ba5433df4a3", + "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3", + "shasum": "" + }, + "require": { + "nette/di": "^3.0", + "nette/utils": "^3.0", + "php": ">=7.1" + }, + "require-dev": { + "latte/latte": "^2.2", + "nette/application": "^3.0", + "nette/caching": "^3.0", + "nette/database": "^3.0", + "nette/forms": "^3.0", + "nette/http": "^3.0", + "nette/mail": "^3.0", + "nette/robot-loader": "^3.0", + "nette/safe-stream": "^2.2", + "nette/security": "^3.0", + "nette/tester": "^2.0", + "tracy/tracy": "^2.6" + }, + "suggest": { + "nette/robot-loader": "to use Configurator::createRobotLoader()", + "tracy/tracy": "to use Configurator::enableTracy()" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "๐Ÿ…ฑ Nette Bootstrap: the simple way to configure and bootstrap your Nette application.", + "homepage": "https://nette.org", + "keywords": [ + "bootstrapping", + "configurator", + "nette" + ], + "time": "2019-03-26T12:59:07+00:00" + }, + { + "name": "nette/di", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/nette/di.git", + "reference": "19d83539245aaacb59470828919182411061841f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/di/zipball/19d83539245aaacb59470828919182411061841f", + "reference": "19d83539245aaacb59470828919182411061841f", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/neon": "^3.0", + "nette/php-generator": "^3.2.2", + "nette/robot-loader": "^3.2", + "nette/schema": "^1.0", + "nette/utils": "^3.0", + "php": ">=7.1" + }, + "conflict": { + "nette/bootstrap": "<3.0" + }, + "require-dev": { + "nette/tester": "^2.2", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ], + "files": [ + "src/compatibility.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "๐Ÿ’Ž Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.", + "homepage": "https://nette.org", + "keywords": [ + "compiled", + "di", + "dic", + "factory", + "ioc", + "nette", + "static" + ], + "time": "2019-04-03T19:35:46+00:00" + }, + { + "name": "nette/finder", + "version": "v2.5.0", + "source": { + "type": "git", + "url": "https://github.com/nette/finder.git", + "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/finder/zipball/6be1b83ea68ac558aff189d640abe242e0306fe2", + "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2", + "shasum": "" + }, + "require": { + "nette/utils": "^2.4 || ~3.0.0", + "php": ">=7.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "? Nette Finder: find files and directories with an intuitive API.", + "homepage": "https://nette.org", + "keywords": [ + "filesystem", + "glob", + "iterator", + "nette" + ], + "time": "2019-02-28T18:13:25+00:00" + }, + { + "name": "nette/neon", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/nette/neon.git", + "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/neon/zipball/cbff32059cbdd8720deccf9e9eace6ee516f02eb", + "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "ext-json": "*", + "php": ">=7.0" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "? Nette NEON: encodes and decodes NEON file format.", + "homepage": "http://ne-on.org", + "keywords": [ + "export", + "import", + "neon", + "nette", + "yaml" + ], + "time": "2019-02-05T21:30:40+00:00" + }, + { + "name": "nette/php-generator", + "version": "v3.2.3", + "source": { + "type": "git", + "url": "https://github.com/nette/php-generator.git", + "reference": "aea6e81437bb238e5f0e5b5ce06337433908e63b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/php-generator/zipball/aea6e81437bb238e5f0e5b5ce06337433908e63b", + "reference": "aea6e81437bb238e5f0e5b5ce06337433908e63b", + "shasum": "" + }, + "require": { + "nette/utils": "^2.4.2 || ~3.0.0", + "php": ">=7.1" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "๐Ÿ˜ Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.3 features.", + "homepage": "https://nette.org", + "keywords": [ + "code", + "nette", + "php", + "scaffolding" + ], + "time": "2019-07-05T13:01:56+00:00" + }, + { + "name": "nette/robot-loader", + "version": "v3.2.0", + "source": { + "type": "git", + "url": "https://github.com/nette/robot-loader.git", + "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", + "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/finder": "^2.5", + "nette/utils": "^3.0", + "php": ">=7.1" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "? Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", + "homepage": "https://nette.org", + "keywords": [ + "autoload", + "class", + "interface", + "nette", + "trait" + ], + "time": "2019-03-08T21:57:24+00:00" + }, + { + "name": "nette/schema", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/nette/schema.git", + "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/nette/schema/zipball/6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", + "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", "shasum": "" }, "require": { - "php": "^7.1" + "nette/utils": "^3.0.1", + "php": ">=7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "nette/tester": "^2.2", + "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.0-dev" } }, "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" ], "authors": [ { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" } ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "description": "๐Ÿ“ Nette Schema: validating data structures against a given Schema.", + "homepage": "https://nette.org", "keywords": [ - "constructor", - "instantiate" + "config", + "nette" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2019-04-03T15:53:25+00:00" }, { - "name": "myclabs/deep-copy", - "version": "1.8.1", + "name": "nette/utils", + "version": "v3.0.1", "source": { "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + "url": "https://github.com/nette/utils.git", + "reference": "bd961f49b211997202bda1d0fbc410905be370d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "url": "https://api.github.com/repos/nette/utils/zipball/bd961f49b211997202bda1d0fbc410905be370d4", + "reference": "bd961f49b211997202bda1d0fbc410905be370d4", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.1" }, - "replace": { - "myclabs/deep-copy": "self.version" + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "suggest": { + "ext-gd": "to use Image", + "ext-iconv": "to use Strings::webalize() and toAscii()", + "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", + "ext-json": "to use Nette\\Utils\\Json", + "ext-mbstring": "to use Strings::lower() etc...", + "ext-xml": "to use Strings::length() etc. when mbstring is not available" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "๐Ÿ›  Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", + "homepage": "https://nette.org", + "keywords": [ + "array", + "core", + "datetime", + "images", + "json", + "nette", + "paginator", + "password", + "slugify", + "string", + "unicode", + "utf-8", + "utility", + "validation" + ], + "time": "2019-03-22T01:00:30+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.2.2", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bd73cc04c3843ad8d6b0bfc0956026a151fc420", + "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^6.5 || ^7.0" }, + "bin": [ + "bin/php-parse" + ], "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, "autoload": { "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] + "PhpParser\\": "lib/PhpParser" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], - "description": "Create deep copies (clones) of your objects", + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" + "parser", + "php" ], - "time": "2018-06-11T23:09:50+00:00" + "time": "2019-05-25T20:07:01+00:00" + }, + { + "name": "ocramius/package-versions", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/PackageVersions.git", + "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0.0", + "php": "^7.1.0" + }, + "require-dev": { + "composer/composer": "^1.6.3", + "doctrine/coding-standard": "^5.0.1", + "ext-zip": "*", + "infection/infection": "^0.7.1", + "phpunit/phpunit": "^7.0.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "PackageVersions\\": "src/PackageVersions" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "time": "2019-02-21T12:16:21+00:00" }, { "name": "phar-io/manifest", @@ -2640,6 +3359,197 @@ ], "time": "2018-08-05T17:53:17+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "0.3.5", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/8c4ef2aefd9788238897b678a985e1d5c8df6db4", + "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "require-dev": { + "consistence/coding-standard": "^3.5", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/phpstan": "^0.10", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "^4.7.2", + "squizlabs/php_codesniffer": "^3.3.2", + "symfony/process": "^3.4 || ^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "time": "2019-06-07T19:13:52+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "0.11.9", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "6771e622ad93f0aff16a100547811e1e50781acb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6771e622ad93f0aff16a100547811e1e50781acb", + "reference": "6771e622ad93f0aff16a100547811e1e50781acb", + "shasum": "" + }, + "require": { + "composer/xdebug-handler": "^1.3.0", + "jean85/pretty-package-versions": "^1.0.3", + "nette/bootstrap": "^2.4 || ^3.0", + "nette/di": "^2.4.7 || ^3.0", + "nette/robot-loader": "^3.0.1", + "nette/schema": "^1.0", + "nette/utils": "^2.4.5 || ^3.0", + "nikic/php-parser": "^4.0.2", + "php": "~7.1", + "phpstan/phpdoc-parser": "^0.3.5", + "symfony/console": "~3.2 || ~4.0", + "symfony/finder": "~3.2 || ~4.0" + }, + "conflict": { + "symfony/console": "3.4.16 || 4.1.5" + }, + "require-dev": { + "brianium/paratest": "^2.0", + "consistence/coding-standard": "^3.5", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ext-intl": "*", + "ext-mysqli": "*", + "ext-simplexml": "*", + "ext-soap": "*", + "ext-zip": "*", + "jakub-onderka/php-parallel-lint": "^1.0", + "localheinz/composer-normalize": "^1.1.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-deprecation-rules": "^0.11", + "phpstan/phpstan-php-parser": "^0.11", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-strict-rules": "^0.11", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.7.2", + "squizlabs/php_codesniffer": "^3.3.2" + }, + "bin": [ + "bin/phpstan" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.11-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": [ + "src/", + "build/PHPStan" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "time": "2019-07-03T21:25:16+00:00" + }, + { + "name": "phpstan/phpstan-symfony", + "version": "0.11.6", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-symfony.git", + "reference": "c7be3054c21fd472a52b1c38eb129c3f93776084" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/c7be3054c21fd472a52b1c38eb129c3f93776084", + "reference": "c7be3054c21fd472a52b1c38eb129c3f93776084", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "nikic/php-parser": "^4.0", + "php": "^7.1", + "phpstan/phpstan": "^0.11.7" + }, + "conflict": { + "symfony/framework-bundle": "<3.0" + }, + "require-dev": { + "consistence/coding-standard": "^3.0.1", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "jakub-onderka/php-parallel-lint": "^1.0", + "nette/di": "^3.0-stable", + "phing/phing": "^2.16.0", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-strict-rules": "^0.11", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.5.2", + "squizlabs/php_codesniffer": "^3.3.2", + "symfony/console": "^3.0 || ^4.0", + "symfony/framework-bundle": "^3.0 || ^4.0", + "symfony/messenger": "^4.2", + "symfony/serializer": "^3.0 || ^4.0" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.11-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Lukรกลก Unger", + "email": "looky.msc@gmail.com", + "homepage": "https://lookyman.net" + } + ], + "description": "Symfony Framework extensions and rules for PHPStan", + "time": "2019-05-19T17:40:25+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "6.1.4", diff --git a/src/Command/AppScaffoldCommand.php b/src/Command/AppScaffoldCommand.php index 7ea3e7ad..b64be454 100644 --- a/src/Command/AppScaffoldCommand.php +++ b/src/Command/AppScaffoldCommand.php @@ -261,7 +261,7 @@ public function logMessage(TaskContextInterface $context, $log_level, $log_messa /** * @param TaskContextInterface $context - * @param $target_folder + * @param string $target_folder * @param string $data_key * @param bool $limitedForTwigExtension */ @@ -402,7 +402,7 @@ protected function askQuestions(InputInterface $input, array $questions, TaskCon } /** - * @param $tokens + * @param array $tokens * @return array */ protected function getReplacements($tokens): array diff --git a/src/Command/BaseCommand.php b/src/Command/BaseCommand.php index 1a48b5d1..29f1a7bb 100644 --- a/src/Command/BaseCommand.php +++ b/src/Command/BaseCommand.php @@ -4,6 +4,12 @@ use Phabalicious\Configuration\ConfigurationService; use Phabalicious\Configuration\HostConfig; +use Phabalicious\Exception\BlueprintTemplateNotFoundException; +use Phabalicious\Exception\FabfileNotFoundException; +use Phabalicious\Exception\FabfileNotReadableException; +use Phabalicious\Exception\MismatchedVersionException; +use Phabalicious\Exception\MissingDockerHostConfigException; +use Phabalicious\Exception\ShellProviderNotFoundException; use Phabalicious\Exception\ValidationFailedException; use Phabalicious\Exception\MissingHostConfigException; use Phabalicious\ShellProvider\ShellProviderInterface; @@ -81,12 +87,12 @@ public function completeOptionValues($optionName, CompletionContext $context) /** * {@inheritdoc} - * @throws \Phabalicious\Exception\MismatchedVersionException - * @throws \Phabalicious\Exception\FabfileNotFoundException - * @throws \Phabalicious\Exception\FabfileNotReadableException - * @throws \Phabalicious\Exception\MissingDockerHostConfigException - * @throws \Phabalicious\Exception\ShellProviderNotFoundException - * @throws \Phabalicious\Exception\BlueprintTemplateNotFoundException + * @throws MismatchedVersionException + * @throws FabfileNotFoundException + * @throws FabfileNotReadableException + * @throws MissingDockerHostConfigException + * @throws ShellProviderNotFoundException + * @throws BlueprintTemplateNotFoundException */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -113,9 +119,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->dockerConfig = $this->getConfiguration()->getDockerConfig($docker_config_name); } - if ($this->hostConfig->shell()) { - $this->hostConfig->shell()->setOutput($output); - } + $this->hostConfig->shell()->setOutput($output); if ($input->getOption('variants')) { $this->handleVariants($input->getOption('variants'), $input, $output); @@ -205,7 +209,7 @@ protected function startInteractiveShell(ShellProviderInterface $shell, array $c /** * Handle variants. * - * @param $variants + * @param string $variants * @param InputInterface $input * @param OutputInterface $output * @return bool|int diff --git a/src/Command/BaseOptionsCommand.php b/src/Command/BaseOptionsCommand.php index 96d9b143..c7acbd88 100644 --- a/src/Command/BaseOptionsCommand.php +++ b/src/Command/BaseOptionsCommand.php @@ -101,7 +101,7 @@ protected function checkAllRequiredOptionsAreNotEmpty(InputInterface $input) /** @var InputOption $option */ foreach ($options as $option) { $name = $option->getName(); - /** @var InputOption $value */ + /** @var mixed $value */ $value = $input->getOption($name); if ($option->isValueRequired() && diff --git a/src/Command/CompletionCommand.php b/src/Command/CompletionCommand.php index 758cca64..a854d6fc 100644 --- a/src/Command/CompletionCommand.php +++ b/src/Command/CompletionCommand.php @@ -85,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $command_name =$input->getOption('complete-command'); $argument = $input->getOption('complete-argument'); $command = $this->getApplication()->find($command_name); - if (!$command || !($command instanceof CompletionAwareInterface)) { + if (!($command instanceof CompletionAwareInterface)) { throw new \InvalidArgumentException('Could not find command '. $command_name); } diff --git a/src/Command/ListBlueprintsCommand.php b/src/Command/ListBlueprintsCommand.php index 6b2f5105..e496be2a 100644 --- a/src/Command/ListBlueprintsCommand.php +++ b/src/Command/ListBlueprintsCommand.php @@ -4,6 +4,11 @@ use Phabalicious\Configuration\ConfigurationService; use Phabalicious\Configuration\HostConfig; +use Phabalicious\Exception\BlueprintTemplateNotFoundException; +use Phabalicious\Exception\FabfileNotFoundException; +use Phabalicious\Exception\FabfileNotReadableException; +use Phabalicious\Exception\MismatchedVersionException; +use Phabalicious\Exception\ValidationFailedException; use Phabalicious\Method\MethodFactory; use Phabalicious\Method\TaskContext; use Phabalicious\Utilities\Utilities; @@ -30,12 +35,12 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * @return void - * @throws \Phabalicious\Exception\BlueprintTemplateNotFoundException - * @throws \Phabalicious\Exception\FabfileNotFoundException - * @throws \Phabalicious\Exception\FabfileNotReadableException - * @throws \Phabalicious\Exception\MismatchedVersionException - * @throws \Phabalicious\Exception\ValidationFailedException + * @return int + * @throws BlueprintTemplateNotFoundException + * @throws FabfileNotFoundException + * @throws FabfileNotReadableException + * @throws MismatchedVersionException + * @throws ValidationFailedException */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -50,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $io = new SymfonyStyle($input, $output); $io->title('List of found blueprints:'); $io->listing($blueprints); - } - -} \ No newline at end of file + return 0; + } +} diff --git a/src/Command/ListCommand.php b/src/Command/ListCommand.php index 3324b751..fcf265b0 100644 --- a/src/Command/ListCommand.php +++ b/src/Command/ListCommand.php @@ -4,6 +4,11 @@ use Phabalicious\Configuration\ConfigurationService; use Phabalicious\Configuration\HostConfig; +use Phabalicious\Exception\BlueprintTemplateNotFoundException; +use Phabalicious\Exception\FabfileNotFoundException; +use Phabalicious\Exception\FabfileNotReadableException; +use Phabalicious\Exception\MismatchedVersionException; +use Phabalicious\Exception\ValidationFailedException; use Phabalicious\Method\MethodFactory; use Phabalicious\Method\TaskContext; use Phabalicious\Utilities\Utilities; @@ -30,12 +35,12 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * @return void - * @throws \Phabalicious\Exception\BlueprintTemplateNotFoundException - * @throws \Phabalicious\Exception\FabfileNotFoundException - * @throws \Phabalicious\Exception\FabfileNotReadableException - * @throws \Phabalicious\Exception\MismatchedVersionException - * @throws \Phabalicious\Exception\ValidationFailedException + * @return int + * @throws BlueprintTemplateNotFoundException + * @throws FabfileNotFoundException + * @throws FabfileNotReadableException + * @throws MismatchedVersionException + * @throws ValidationFailedException */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -46,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $io = new SymfonyStyle($input, $output); $io->title('List of found host-configurations:'); $io->listing($hosts); - } - -} \ No newline at end of file + return 0; + } +} diff --git a/src/Command/SelfUpdateCommand.php b/src/Command/SelfUpdateCommand.php index 9c5152d0..10d17deb 100644 --- a/src/Command/SelfUpdateCommand.php +++ b/src/Command/SelfUpdateCommand.php @@ -119,8 +119,7 @@ public static function registerListener(EventDispatcher $dispatcher) /** @var SelfUpdateCommand command */ $command = $event->getCommand()->getApplication()->find('self-update'); - if ($command - && $output->isDecorated() + if ($output->isDecorated() && !$output->isQuiet() && !$event->getCommand()->isHidden() && !$command->getConfiguration()->isOffline() diff --git a/src/Configuration/BlueprintConfiguration.php b/src/Configuration/BlueprintConfiguration.php index cf5715ba..2d4d6b5c 100644 --- a/src/Configuration/BlueprintConfiguration.php +++ b/src/Configuration/BlueprintConfiguration.php @@ -39,7 +39,7 @@ public function __construct(ConfigurationService $service) /** * Get a template by key. - * @param $key + * @param string $key * @return BlueprintTemplate * @throws BlueprintTemplateNotFoundException */ @@ -66,7 +66,7 @@ public function getTemplates() /** * Expand variants. * - * @param $blueprints + * @param array $blueprints * @throws BlueprintTemplateNotFoundException * @throws ValidationFailedException */ @@ -89,9 +89,10 @@ public function expandVariants($blueprints) $host = $template->expand($variant); if (!$this->configuration->hasHostConfig($host['configName'])) { $this->configuration->addHost($template->expand($variant)); - } - else { - $this->configuration->getLogger()->notice('There\'s an existing config with that name, skipping creating one from blueprint'); + } else { + $this->configuration->getLogger()->notice( + 'There\'s an existing config with that name, skipping creating one from blueprint' + ); } } } @@ -101,7 +102,7 @@ public function expandVariants($blueprints) /** * Get all variants for a given config. * - * @param $config_name + * @param string $config_name * @return bool|array */ public function getVariants($config_name) diff --git a/src/Configuration/ConfigurationService.php b/src/Configuration/ConfigurationService.php index aaec319d..46b0fca4 100644 --- a/src/Configuration/ConfigurationService.php +++ b/src/Configuration/ConfigurationService.php @@ -31,7 +31,7 @@ class ConfigurationService private $application; /** - * @var MethodFactory + * @var MethodFactory|null */ private $methods; @@ -262,7 +262,7 @@ private function applyDefaults(array $data, array $defaults, array $disallowed_k * Resolve inheritance for given data. * * @param array $data - * @param $lookup + * @param array $lookup * * @return array * @throws MismatchedVersionException @@ -383,7 +383,7 @@ function ($severity, $message) { * * @return HostConfig * @throws \Phabalicious\Exception\BlueprintTemplateNotFoundException - * @throws \Phabalicious\Exception\FabfileNotReadableException + * @throws FabfileNotReadableException * @throws \Phabalicious\Exception\MismatchedVersionException * @throws \Phabalicious\Exception\MissingHostConfigException * @throws \Phabalicious\Exception\ShellProviderNotFoundException @@ -421,7 +421,7 @@ public function getHostConfig(string $config_name) * @throws ShellProviderNotFoundException * @throws ValidationFailedException * @throws BlueprintTemplateNotFoundException - * @throws \Phabalicious\Exception\FabfileNotReadableException + * @throws FabfileNotReadableException */ public function getHostConfigFromBlueprint(string $blueprint, string $identifier) { @@ -448,14 +448,14 @@ public function getHostConfigFromBlueprint(string $blueprint, string $identifier } /** - * @param $config_name - * @param $data + * @param string $config_name + * @param array $data * * @return HostConfig * @throws MismatchedVersionException * @throws ShellProviderNotFoundException * @throws ValidationFailedException - * @throws \Phabalicious\Exception\FabfileNotReadableException + * @throws FabfileNotReadableException */ private function validateHostConfig($config_name, $data) { @@ -690,12 +690,13 @@ public function setLogger(LoggerInterface $logger) /** * @param string $config_name - * @param $data + * @param array $data * @return array + * @throws BlueprintTemplateNotFoundException + * @throws FabfileNotReadableException * @throws MismatchedVersionException * @throws ShellProviderNotFoundException * @throws ValidationFailedException - * @throws BlueprintTemplateNotFoundException */ protected function inheritFromBlueprint(string $config_name, $data): array { diff --git a/src/Exception/UnknownReplacementPatternException.php b/src/Exception/UnknownReplacementPatternException.php index f13d408f..00d7cb0a 100644 --- a/src/Exception/UnknownReplacementPatternException.php +++ b/src/Exception/UnknownReplacementPatternException.php @@ -6,15 +6,18 @@ class UnknownReplacementPatternException extends \Exception { private $patterns; private $offendingLine; + /** * ValidationFailedException constructor. * - * @param \Phabalicious\Validation\ValidationErrorBagInterface $validation_errors + * @param string $offending_line + * @param array $patterns */ public function __construct(string $offending_line, array $patterns) { $this->offendingLine = $offending_line; $this->patterns = $patterns; + parent::__construct(); } public function getPatterns() @@ -34,7 +37,8 @@ public function __toString() /** * @return string */ - public function getOffendingLine(): string { + public function getOffendingLine(): string + { return $this->offendingLine; } -} \ No newline at end of file +} diff --git a/src/Method/BaseMethod.php b/src/Method/BaseMethod.php index 6b4b9632..ac1781e6 100644 --- a/src/Method/BaseMethod.php +++ b/src/Method/BaseMethod.php @@ -8,13 +8,14 @@ use Phabalicious\ShellProvider\ShellProviderInterface; use Phabalicious\Validation\ValidationErrorBagInterface; use Psr\Log\LoggerInterface; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; abstract class BaseMethod implements MethodInterface { /** - * @var \Psr\Log\LoggerInterface + * @var LoggerInterface */ protected $logger; @@ -73,13 +74,13 @@ public function fallback(string $task, HostConfig $config, TaskContextInterface /** * @param TaskContext $context - * @param $command_name - * @param $args + * @param string $command_name + * @param array $args * @throws \Exception */ public function executeCommand(TaskContext $context, $command_name, $args) { - /** @var \Symfony\Component\Console\Command\Command $command */ + /** @var Command $command */ $command = $context->getCommand()->getApplication()->find($command_name); if (isset($args[0])) { $args[$command_name] = $args[0]; @@ -148,5 +149,4 @@ protected function parseBackupFile(HostConfig $host_config, string $file, string 'file' => $file ]; } - -} \ No newline at end of file +} diff --git a/src/Method/BaseNotifyMethod.php b/src/Method/BaseNotifyMethod.php index 6f377dba..a583ad5d 100644 --- a/src/Method/BaseNotifyMethod.php +++ b/src/Method/BaseNotifyMethod.php @@ -5,6 +5,8 @@ use Phabalicious\Configuration\ConfigurationService; use Phabalicious\Configuration\HostConfig; use Phabalicious\Configuration\HostType; +use Phabalicious\Exception\MethodNotFoundException; +use Phabalicious\Exception\TaskNotFoundInMethodException; use Phabalicious\Validation\ValidationErrorBagInterface; abstract class BaseNotifyMethod extends BaseMethod implements MethodInterface, NotifyMethodInterface @@ -65,11 +67,11 @@ public function notify(HostConfig $host_config, TaskContextInterface $context) /** * @param HostConfig $host_config - * @param $message + * @param string $message * @param TaskContextInterface $context * @param string $type - * @throws \Phabalicious\Exception\MethodNotFoundException - * @throws \Phabalicious\Exception\TaskNotFoundInMethodException + * @throws MethodNotFoundException + * @throws TaskNotFoundInMethodException */ private function sendNotificationImpl( HostConfig $host_config, @@ -88,5 +90,4 @@ private function sendNotificationImpl( $this->sendNotification($host_config, $message, $context, $type, $meta); } - -} \ No newline at end of file +} diff --git a/src/Method/DockerMethod.php b/src/Method/DockerMethod.php index 27ae418d..06a6a9a1 100644 --- a/src/Method/DockerMethod.php +++ b/src/Method/DockerMethod.php @@ -87,11 +87,11 @@ public function alterConfig(ConfigurationService $configuration_service, array & /** * @param HostConfig $host_config - * @param TaskContextInterface $context + * @param ConfigurationService $config * @return DockerConfig - * @throws ValidationFailedException * @throws MismatchedVersionException * @throws MissingDockerHostConfigException + * @throws ValidationFailedException */ public static function getDockerConfig(HostConfig $host_config, ConfigurationService $config) { @@ -124,8 +124,8 @@ public function docker(HostConfig $host_config, TaskContextInterface $context) /** * @param HostConfig $host_config * @param TaskContextInterface $context - * @param $task - * @param $silent + * @param string $task + * @param bool $silent * @throws MethodNotFoundException * @throws MismatchedVersionException * @throws MissingDockerHostConfigException @@ -173,7 +173,7 @@ private function runTaskImpl(HostConfig $host_config, TaskContextInterface $cont /** @var CommandResult $cr */ $cr = $context->getResult('commandResult', false); - if ($cr && $cr->failed()) { + if ($cr->failed()) { $cr->throwException(sprintf('Docker task `%s` failed!', $task)); } } @@ -541,8 +541,8 @@ public function runAppSpecificTask(HostConfig $host_config, TaskContextInterface /** * @param HostConfig $host_config - * @param TaskContextInterface $context - * @return bool + * @param ConfigurationService $config + * @return string * @throws MismatchedVersionException * @throws MissingDockerHostConfigException * @throws ValidationFailedException diff --git a/src/Method/DrupalconsoleMethod.php b/src/Method/DrupalconsoleMethod.php index 3ada27a3..bb44aec6 100644 --- a/src/Method/DrupalconsoleMethod.php +++ b/src/Method/DrupalconsoleMethod.php @@ -52,7 +52,7 @@ private function getRootFolder(HostConfig $host_config) return $root_folder; } - public function drupalConsole(HostConfig $host_config, TaskCOntextInterface $context) + public function drupalConsole(HostConfig $host_config, TaskContextInterface $context) { $shell = $this->getShell($host_config, $context); $shell->cd($host_config['siteFolder']); diff --git a/src/Method/DrushMethod.php b/src/Method/DrushMethod.php index f2f1d5cc..38772887 100644 --- a/src/Method/DrushMethod.php +++ b/src/Method/DrushMethod.php @@ -282,7 +282,7 @@ private function handleModules( } $drush_command = ($should_enable) ? 'en -y %s' : 'dis -y %s'; - if (!$context->getOutput() || $context->getOutput()->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) { + if (!$context->getOutput() || ($context->getOutput()->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE)) { $modules = [ implode(' ', $modules), ]; diff --git a/src/Method/LocalMethod.php b/src/Method/LocalMethod.php index 1abf7e10..f9333026 100644 --- a/src/Method/LocalMethod.php +++ b/src/Method/LocalMethod.php @@ -4,6 +4,7 @@ use Phabalicious\Configuration\ConfigurationService; use Phabalicious\ShellProvider\LocalShellProvider; +use Phabalicious\ShellProvider\ShellProviderFactory; use Phabalicious\Validation\ValidationErrorBagInterface; use Phabalicious\Validation\ValidationService; diff --git a/src/Method/MatterMostNotificationMethod.php b/src/Method/MatterMostNotificationMethod.php index aa2511b9..9843630c 100644 --- a/src/Method/MatterMostNotificationMethod.php +++ b/src/Method/MatterMostNotificationMethod.php @@ -91,7 +91,7 @@ public function sendNotification( } } - $mmm->attachment(function (Attachment $attachment) use ($message, $type, $host_config, $config, $meta) { + $mmm->attachment(function (Attachment $attachment) use ($message, $type, $host_config, $meta) { $attachment->fallback($message); if ($type == BaseNotifyMethod::SUCCESS) { $attachment->success(); @@ -110,4 +110,4 @@ public function sendNotification( $mattermost->send($mmm, $config['webhook']); } -} \ No newline at end of file +} diff --git a/src/Method/MethodFactory.php b/src/Method/MethodFactory.php index a0a7feeb..8f492386 100644 --- a/src/Method/MethodFactory.php +++ b/src/Method/MethodFactory.php @@ -17,7 +17,7 @@ class MethodFactory protected $methods = []; /** - * @var \Phabalicious\Configuration\ConfigurationService + * @var ConfigurationService */ protected $configuration; @@ -31,7 +31,7 @@ class MethodFactory /** * MethodFactory constructor. * - * @param \Phabalicious\Configuration\ConfigurationService $configuration + * @param ConfigurationService $configuration * @param \Psr\Log\LoggerInterface $logger */ public function __construct(ConfigurationService $configuration, LoggerInterface $logger) @@ -58,7 +58,7 @@ public function addMethod(MethodInterface $method) * @param string $name * * @return \Phabalicious\Method\MethodInterface - * @throws \Phabalicious\Exception\MethodNotFoundException + * @throws MethodNotFoundException */ public function getMethod(string $name): MethodInterface { @@ -81,11 +81,11 @@ public function getMethod(string $name): MethodInterface * * @param string $task_name * @param \Phabalicious\Configuration\HostConfig $configuration - * @param \Phabalicious\Method\TaskContextInterface|NULL $context + * @param TaskContextInterface|NULL $context * @param array $nextTasks * - * @return \Phabalicious\Method\TaskContext|\Phabalicious\Method\TaskContextInterface - * @throws \Phabalicious\Exception\MethodNotFoundException + * @return \Phabalicious\Method\TaskContext|TaskContextInterface + * @throws MethodNotFoundException * @throws TaskNotFoundInMethodException */ public function runTask( @@ -114,12 +114,12 @@ public function runTask( /** * Run a task (implementation). * - * @param $task_name + * @param string $task_name * @param HostConfig $configuration - * @param \Phabalicious\Method\TaskContextInterface $context - * @param $fallback_allowed + * @param TaskContextInterface $context + * @param bool $fallback_allowed * - * @throws \Phabalicious\Exception\MethodNotFoundException + * @throws MethodNotFoundException * @throws TaskNotFoundInMethodException */ protected function runTaskImpl( @@ -155,7 +155,7 @@ protected function runTaskImpl( * @param \Phabalicious\Method\MethodInterface $method * @param string $task_name * @param \Phabalicious\Configuration\HostConfig $configuration - * @param \Phabalicious\Method\TaskContextInterface $in_context + * @param TaskContextInterface $in_context * @param bool $optional * @throws MethodNotFoundException * @throws TaskNotFoundInMethodException @@ -199,10 +199,10 @@ private function callImpl( * @param string $method_name * @param string $task_name * @param \Phabalicious\Configuration\HostConfig $configuration - * @param \Phabalicious\Method\TaskContextInterface $context + * @param TaskContextInterface $context * - * @return \Phabalicious\Method\TaskContextInterface - * @throws \Phabalicious\Exception\MethodNotFoundException + * @return TaskContextInterface + * @throws MethodNotFoundException * @throws TaskNotFoundInMethodException */ public function call( @@ -225,9 +225,9 @@ public function call( * @param string $step_name * @param string $task_name * @param HostConfig $configuration - * @param \Phabalicious\Method\TaskContextInterface $context + * @param TaskContextInterface $context * - * @throws \Phabalicious\Exception\MethodNotFoundException + * @throws MethodNotFoundException */ private function preflight( string $step_name, diff --git a/src/Method/ScriptMethod.php b/src/Method/ScriptMethod.php index 14795673..dfb16eb2 100644 --- a/src/Method/ScriptMethod.php +++ b/src/Method/ScriptMethod.php @@ -4,6 +4,7 @@ use Phabalicious\Configuration\ConfigurationService; use Phabalicious\Configuration\HostConfig; +use Phabalicious\ShellProvider\CommandResult; use Phabalicious\ShellProvider\ShellProviderInterface; use Phabalicious\Utilities\Utilities; use Phabalicious\Validation\ValidationErrorBagInterface; @@ -135,7 +136,7 @@ public function runScript(HostConfig $host_config, TaskContextInterface $context * @param array $environment * @param array $replacements * - * @return \Phabalicious\ShellProvider\CommandResult + * @return CommandResult|null * @throws MissingScriptCallbackImplementation * @throws UnknownReplacementPatternException */ @@ -146,7 +147,7 @@ private function runScriptImpl( array $callbacks = [], array $environment = [], array $replacements = [] - ) { + ) : ?CommandResult { $command_result = null; $context->set('break_on_first_error', $this->getBreakOnFirstError()); @@ -189,8 +190,8 @@ private function runScriptImpl( } /** - * @param $strings - * @return bool + * @param string[] $strings + * @return true|string */ private function validateReplacements($strings) { @@ -207,9 +208,9 @@ private function validateReplacements($strings) * Execute callback. * * @param TaskContextInterface $context - * @param $callbacks - * @param $callback - * @param $args + * @param array $callbacks + * @param string $callback + * @param array $args * * @return bool * @throws MissingScriptCallbackImplementation @@ -247,7 +248,7 @@ public function handleExecuteCallback() /** * @param TaskContextInterface $context - * @param $flag + * @param bool $flag */ public function handleFailOnErrorDeprecatedCallback(TaskContextInterface $context, $flag) { @@ -257,7 +258,7 @@ public function handleFailOnErrorDeprecatedCallback(TaskContextInterface $contex /** * @param TaskContextInterface $context - * @param $flag + * @param bool $flag */ public function handleFailOnErrorCallback(TaskContextInterface $context, $flag) { @@ -267,7 +268,7 @@ public function handleFailOnErrorCallback(TaskContextInterface $context, $flag) /** * @param TaskContextInterface $context - * @param $dir + * @param string $dir * @throws \Exception */ public function handleFailOnMissingDirectoryCallback(TaskContextInterface $context, $dir) diff --git a/src/Method/TaskContext.php b/src/Method/TaskContext.php index f1e19bba..70a20691 100644 --- a/src/Method/TaskContext.php +++ b/src/Method/TaskContext.php @@ -44,9 +44,7 @@ public function __construct(BaseOptionsCommand $command, InputInterface $input, $this->setInput($input); $this->setOutput($output); $this->setCommand($command); - if ($command->getConfiguration()) { - $this->setConfigurationService($command->getConfiguration()); - } + $this->setConfigurationService($command->getConfiguration()); } public function set(string $key, $value) @@ -64,12 +62,12 @@ public function setOutput(OutputInterface $output) $this->output = $output; } - public function getOutput(): OutputInterface + public function getOutput(): ?OutputInterface { return $this->output; } - public function setConfigurationService(ConfigurationService $service) + public function setConfigurationService(?ConfigurationService $service) { $this->configurationService = $service; } @@ -112,7 +110,7 @@ public function getCommandResult(): ?CommandResult return $this->commandResult; } - public function getShell() + public function getShell() : ?ShellProviderInterface { return $this->shell; } diff --git a/src/Method/TaskContextInterface.php b/src/Method/TaskContextInterface.php index 306418cc..cf1a4ae3 100644 --- a/src/Method/TaskContextInterface.php +++ b/src/Method/TaskContextInterface.php @@ -24,7 +24,7 @@ public function getInput(): InputInterface; public function setOutput(OutputInterface $output); - public function getOutput(): OutputInterface; + public function getOutput(): ?OutputInterface; public function setCommand(BaseOptionsCommand $command); @@ -42,6 +42,11 @@ public function setResult($key, $value); public function addResult(string $key, array $rows); + /** + * @param string $key + * @param mixed $default + * @return mixed + */ public function getResult($key, $default = null); public function getResults(): array; @@ -49,9 +54,9 @@ public function getResults(): array; public function clearResults(); /** - * @return ShellProviderInterface + * @return ShellProviderInterface|null */ - public function getShell(); + public function getShell() : ?ShellProviderInterface; public function setShell(ShellProviderInterface $shell); diff --git a/src/ShellCompletion/FishShellCompletionContext.php b/src/ShellCompletion/FishShellCompletionContext.php index 2f08b520..d6deacd9 100644 --- a/src/ShellCompletion/FishShellCompletionContext.php +++ b/src/ShellCompletion/FishShellCompletionContext.php @@ -22,7 +22,7 @@ class FishShellCompletionContext extends CompletionContext { - /** @var ConfigurationService */ + /** @var ConfigurationService|null */ protected $configuration; protected $configName; diff --git a/src/ShellCompletion/FishShellCompletionDescriptor.php b/src/ShellCompletion/FishShellCompletionDescriptor.php index 14105240..35a82d4e 100644 --- a/src/ShellCompletion/FishShellCompletionDescriptor.php +++ b/src/ShellCompletion/FishShellCompletionDescriptor.php @@ -32,6 +32,7 @@ public function __construct() protected function describeInputArgument(InputArgument $argument, array $options = array()) { global $argv; + /** @var Command $command */ $command = $options['command']; if (!$command instanceof CompletionAwareInterface) { return; @@ -40,7 +41,6 @@ protected function describeInputArgument(InputArgument $argument, array $options "complete -c phab -n '__fish_seen_subcommand_from " . $command->getName() . "' -f" ); - global $argv; $this->output->write( " -a '(__fish_phab_get_arguments " . @@ -64,7 +64,7 @@ protected function describeInputArgument(InputArgument $argument, array $options */ protected function describeInputOption(InputOption $option, array $options = array()) { - global $argv; + /** @var Command $command */ $command = $options['command']; $this->output->write( "complete -c phab -n '__fish_seen_subcommand_from " . $command->getName() . diff --git a/src/ShellProvider/BaseShellProvider.php b/src/ShellProvider/BaseShellProvider.php index 7f8a5dfc..a0324184 100644 --- a/src/ShellProvider/BaseShellProvider.php +++ b/src/ShellProvider/BaseShellProvider.php @@ -26,7 +26,7 @@ abstract class BaseShellProvider implements ShellProviderInterface /** @var \Psr\Log\LoggerInterface */ protected $logger; - /** @var OutputInterface */ + /** @var OutputInterface|null */ protected $output; /** @var LogLevelStack */ @@ -118,7 +118,7 @@ public function popWorkingDir() /** * Expand a command. * - * @param $line + * @param string $line * @return null|string|string[] */ public function expandCommand($line) diff --git a/src/ShellProvider/CommandResult.php b/src/ShellProvider/CommandResult.php index 33980aff..b14c0264 100644 --- a/src/ShellProvider/CommandResult.php +++ b/src/ShellProvider/CommandResult.php @@ -43,7 +43,7 @@ public function getExitCode() } /** - * @param $message + * @param string $message * @throws FailedShellCommandException */ public function throwException($message) @@ -52,4 +52,4 @@ public function throwException($message) $message . "\n" . implode("\n", $this->getOutput()) ); } -} \ No newline at end of file +} diff --git a/src/ShellProvider/DockerExecShellProvider.php b/src/ShellProvider/DockerExecShellProvider.php index 242026fe..3f47a822 100644 --- a/src/ShellProvider/DockerExecShellProvider.php +++ b/src/ShellProvider/DockerExecShellProvider.php @@ -57,7 +57,7 @@ public function getShellCommand(array $options = []): array } /** - * @param $dir + * @param string $dir * @return bool * @throws \Exception */ diff --git a/src/ShellProvider/LocalShellProvider.php b/src/ShellProvider/LocalShellProvider.php index 516c4ff3..ae33762b 100644 --- a/src/ShellProvider/LocalShellProvider.php +++ b/src/ShellProvider/LocalShellProvider.php @@ -18,7 +18,7 @@ class LocalShellProvider extends BaseShellProvider implements ShellProviderInter const RESULT_IDENTIFIER = '##RESULT:'; const PROVIDER_NAME = 'local'; - /** @var Process */ + /** @var Process|null */ private $process; /** @var InputStream */ diff --git a/src/ShellProvider/SshShellProvider.php b/src/ShellProvider/SshShellProvider.php index e8cd8340..26229085 100644 --- a/src/ShellProvider/SshShellProvider.php +++ b/src/ShellProvider/SshShellProvider.php @@ -13,7 +13,7 @@ class SshShellProvider extends LocalShellProvider { const PROVIDER_NAME = 'ssh'; - static protected $cachedSshPorts = []; + protected static $cachedSshPorts = []; public function getDefaultConfig(ConfigurationService $configuration_service, array $host_config): array { @@ -105,7 +105,7 @@ public function getShellCommand(array $options = []): array } /** - * @param $dir + * @param string $dir * @return bool * @throws \Exception */ diff --git a/symfony.lock b/symfony.lock index 7490a874..fc3acc00 100644 --- a/symfony.lock +++ b/symfony.lock @@ -5,6 +5,9 @@ "composer/semver": { "version": "1.4.2" }, + "composer/xdebug-handler": { + "version": "1.3.3" + }, "doctrine/instantiator": { "version": "1.1.0" }, @@ -29,6 +32,9 @@ "jakeasmith/http_build_url": { "version": "1.0.1" }, + "jean85/pretty-package-versions": { + "version": "1.2" + }, "lesstif/php-jira-rest-client": { "version": "1.35.0" }, @@ -41,6 +47,36 @@ "netresearch/jsonmapper": { "version": "v1.4.0" }, + "nette/bootstrap": { + "version": "v3.0.0" + }, + "nette/di": { + "version": "v3.0.0" + }, + "nette/finder": { + "version": "v2.5.0" + }, + "nette/neon": { + "version": "v3.0.0" + }, + "nette/php-generator": { + "version": "v3.2.3" + }, + "nette/robot-loader": { + "version": "v3.2.0" + }, + "nette/schema": { + "version": "v1.0.0" + }, + "nette/utils": { + "version": "v3.0.1" + }, + "nikic/php-parser": { + "version": "v4.2.2" + }, + "ocramius/package-versions": { + "version": "1.4.0" + }, "padraic/humbug_get_contents": { "version": "1.1.2" }, @@ -65,6 +101,15 @@ "phpspec/prophecy": { "version": "1.8.0" }, + "phpstan/phpdoc-parser": { + "version": "0.3.5" + }, + "phpstan/phpstan": { + "version": "0.11.9" + }, + "phpstan/phpstan-symfony": { + "version": "0.11.6" + }, "phpunit/php-code-coverage": { "version": "6.0.7" }, diff --git a/tests/ScriptMethodTest.php b/tests/ScriptMethodTest.php index 4fbe6a83..6d99fd57 100644 --- a/tests/ScriptMethodTest.php +++ b/tests/ScriptMethodTest.php @@ -1,16 +1,17 @@ expectException(MissingScriptCallbackImplementation::class); + $this->context->set('callbacks', [ 'debug' => [$this, 'missingScriptDebugCallback'], ]); From cef12335b083b5b6db731ec8da461a4838f39885 Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Sun, 7 Jul 2019 14:36:56 +0200 Subject: [PATCH 6/8] Show error-message if shell could not be initialized. Fixes #54 --- src/Command/BaseCommand.php | 35 ++++++++++++++++++++-------- src/Command/DrupalConsoleCommand.php | 2 +- src/Command/DrushCommand.php | 2 +- src/Command/ShellCommand.php | 2 +- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/Command/BaseCommand.php b/src/Command/BaseCommand.php index 29f1a7bb..3e7270f7 100644 --- a/src/Command/BaseCommand.php +++ b/src/Command/BaseCommand.php @@ -177,12 +177,26 @@ public function runCommand(string $command, array $args, InputInterface $origina } /** + * @param SymfonyStyle $io * @param ShellProviderInterface $shell * @param array $command + * @param bool $use_tty * @return Process */ - protected function startInteractiveShell(ShellProviderInterface $shell, array $command = [], $use_tty = true) - { + protected function startInteractiveShell( + SymfonyStyle $io, + ShellProviderInterface $shell, + array $command = [], + $use_tty = true + ) { + $fn = function ($type, $buffer) use ($io) { + if ($type == Process::ERR) { + $io->error($buffer); + } else { + $io->write($buffer); + } + }; + $options = ['tty' => true]; /** @var Process $process */ if (!empty($command)) { @@ -194,14 +208,15 @@ protected function startInteractiveShell(ShellProviderInterface $shell, array $c $process->setInput($stdin); $process->setTimeout(0); $process->setTty($use_tty); - $process->start(); - $process->wait(function ($type, $buffer) { - if ($type == Process::ERR) { - fwrite(STDERR, $buffer); - } else { - fwrite(STDOUT, $buffer); - } - }); + $process->start($fn); + $process->wait($fn); + if ($process->isTerminated() && !$process->isSuccessful()) { + $io->error(sprintf( + 'Command %s failed with error %s', + $process->getCommandLine(), + $process->getExitCode() + )); + } return $process; } diff --git a/src/Command/DrupalConsoleCommand.php b/src/Command/DrupalConsoleCommand.php index 08aa0fa3..989e99c1 100644 --- a/src/Command/DrupalConsoleCommand.php +++ b/src/Command/DrupalConsoleCommand.php @@ -60,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Starting drupal-console on `' . $host_config['configName'] . '`'); - $process = $this->startInteractiveShell($shell, $command, $output->isDecorated()); + $process = $this->startInteractiveShell($context->io(), $shell, $command, $output->isDecorated()); return $process->getExitCode(); } diff --git a/src/Command/DrushCommand.php b/src/Command/DrushCommand.php index b470e37e..d853c679 100644 --- a/src/Command/DrushCommand.php +++ b/src/Command/DrushCommand.php @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Starting drush on `' . $host_config['configName'] . '`'); - $process = $this->startInteractiveShell($shell, $command, $output->isDecorated()); + $process = $this->startInteractiveShell($context->io(), $shell, $command, $output->isDecorated()); return $process->getExitCode(); } } diff --git a/src/Command/ShellCommand.php b/src/Command/ShellCommand.php index 4e447a17..946d404d 100644 --- a/src/Command/ShellCommand.php +++ b/src/Command/ShellCommand.php @@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Starting shell on `' . $host_config['configName'] . '`'); - $process = $this->startInteractiveShell($shell); + $process = $this->startInteractiveShell($context->io(), $shell); return $process->getExitCode(); } } From 8dc2b176be353ada67e761c7733dcbc45531eb0b Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Sun, 7 Jul 2019 14:41:50 +0200 Subject: [PATCH 7/8] Bump version number --- src/Utilities/Utilities.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utilities/Utilities.php b/src/Utilities/Utilities.php index 60a2b429..9134c7c8 100644 --- a/src/Utilities/Utilities.php +++ b/src/Utilities/Utilities.php @@ -5,7 +5,7 @@ class Utilities { - const FALLBACK_VERSION = '3.0.19'; + const FALLBACK_VERSION = '3.0.20'; public static function mergeData(array $data, array $override_data): array { From 221123f713c9d5fd2226993dfab2f6105be99da6 Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Sun, 7 Jul 2019 14:43:08 +0200 Subject: [PATCH 8/8] Update changelog --- Changelog.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Changelog.md b/Changelog.md index a97c867c..46a8c33a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,16 @@ # Changelog +## 3.0.20 / 2019-07-07 + +### Fixed + + * Show error-message if shell could not be initialized. Fixes #54 + * Satisfy phpstan and add it as a new precommit-hook + * Fix drush and other commands when using local shell provider + * Prevent filename collision when running docker copySSHKeys, fixes #52 + * Fix issue with special characters in the pw + * Use latest version of stecman/symfony-console-completion + ## 3.0.19 / 2019-06-25 ### Fixed