From b1ddaedf09895ad5d6da0e135be9d9ca90f84810 Mon Sep 17 00:00:00 2001 From: Marcin Harasim Date: Sat, 28 Dec 2019 13:24:02 +0100 Subject: [PATCH] Add Symfony 5 support + update dependency packages --- composer.json | 22 +++++++++++----------- src/Command/InstallCommand.php | 31 ++++++++++++++++++++++++++++++- src/Command/UninstallCommand.php | 4 +++- src/dist/grumphp.yml | 3 ++- src/dist/phpstan.neon | 19 ++++++++----------- src/dist/phpunit.xml.dist | 2 +- 6 files changed, 55 insertions(+), 26 deletions(-) diff --git a/composer.json b/composer.json index d77e139..24b07fc 100644 --- a/composer.json +++ b/composer.json @@ -11,23 +11,23 @@ ], "type": "library", "require": { - "php": ">=7.1", + "php": "^7.1", "composer/composer": "^1.8", "friendsofphp/php-cs-fixer": "^2.14", "jakub-onderka/php-parallel-lint": "^1.0", "phpmd/phpmd": "^2.6", - "phpro/grumphp": "^0.15.0", - "phpstan/phpstan": "^0.11.2", - "phpstan/phpstan-doctrine": "^0.11.1", - "phpstan/phpstan-phpunit": "^0.11.0", - "phpstan/phpstan-symfony": "^0.11.1", + "phpro/grumphp": "^0.15.0|^0.16.0|^0.17.0", + "phpstan/phpstan": "^0.11.2|^0.12.0", + "phpstan/phpstan-doctrine": "^0.11.1|^0.12.0", + "phpstan/phpstan-phpunit": "^0.11.0|^0.12.0", + "phpstan/phpstan-symfony": "^0.11.1|^0.12.0", "povils/phpmnd": "^2.1", "sebastian/phpcpd": "^4.1", - "sensiolabs/security-checker": "^5.0", - "symfony/console": "^4.0", - "symfony/filesystem": "^4.0", - "symfony/phpunit-bridge": "^4.0", - "thecodingmachine/phpstan-strict-rules": "^0.11.2" + "sensiolabs/security-checker": "^5.0|^6.0", + "symfony/console": "^4.0|^5.0", + "symfony/filesystem": "^4.0|^5.0", + "symfony/phpunit-bridge": "^4.0|^5.0", + "thecodingmachine/phpstan-strict-rules": "^0.11.2|^0.12.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2" diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index 832dc89..b77b559 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -22,7 +22,7 @@ final class InstallCommand extends AbstractCommand /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this ->setDescription('Create configuration files of SymfonyGrumPHP') @@ -52,7 +52,36 @@ protected function execute(InputInterface $input, OutputInterface $output) } $filesystem->copy($sourceFile, $destinationFile); + + if ('phpstan.neon' === $file) { + $this->modifyNeonFile($destinationFile); + } + $output->writeln(sprintf('File [%s] has been created.', $file)); } + + return 0; + } + + /** + * @param string $destinationFile + */ + private function modifyNeonFile(string $destinationFile): void + { + $symfonyKernel = 'Symfony\Component\HttpKernel\Kernel'; + if (class_exists($symfonyKernel)) { + $containerXmlPath = '%rootDir%/../../../var/cache/dev/srcDevDebugProjectContainer.xml'; + + if (version_compare($symfonyKernel::VERSION, '5.0.0', '>=')) { + $containerXmlPath = '%rootDir%/../../../var/cache/dev/App_KernelDevDebugContainer.xml'; + } + + if (version_compare($symfonyKernel::VERSION, '4.2.0', '>=')) { + $containerXmlPath = '%rootDir%/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml'; + } + + file_put_contents($destinationFile, sprintf(' symfony:%s', PHP_EOL), FILE_APPEND); + file_put_contents($destinationFile, sprintf(' container_xml_path: %s', $containerXmlPath), FILE_APPEND); + } } } diff --git a/src/Command/UninstallCommand.php b/src/Command/UninstallCommand.php index fcd36a7..9fe6f95 100644 --- a/src/Command/UninstallCommand.php +++ b/src/Command/UninstallCommand.php @@ -22,7 +22,7 @@ final class UninstallCommand extends AbstractCommand /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this ->setDescription('Remove configuration files of SymfonyGrumPHP') @@ -45,5 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(sprintf('Files [%s, %s.scbak] have been deleted.', $file, $file)); } } + + return 0; } } diff --git a/src/dist/grumphp.yml b/src/dist/grumphp.yml index 2d30584..345407a 100644 --- a/src/dist/grumphp.yml +++ b/src/dist/grumphp.yml @@ -21,7 +21,7 @@ parameters: metadata: priority: 999 phpcpd: - directory: '.' + directory: ['.'] exclude: ['vendor', 'public', 'var', 'config', 'bin', 'translations', 'src/Migrations'] names_exclude: [] fuzzy: false @@ -62,6 +62,7 @@ parameters: phpstan: configuration: phpstan.neon level: 7 + memory_limit: '-1' metadata: priority: 993 securitychecker: diff --git a/src/dist/phpstan.neon b/src/dist/phpstan.neon index e2328af..f93a204 100644 --- a/src/dist/phpstan.neon +++ b/src/dist/phpstan.neon @@ -1,3 +1,11 @@ +includes: + - vendor/phpstan/phpstan-doctrine/extension.neon + - vendor/phpstan/phpstan-doctrine/rules.neon + - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-phpunit/rules.neon + - vendor/phpstan/phpstan-symfony/extension.neon + - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon + parameters: excludes_analyse: - %rootDir%/../../../var/* @@ -8,16 +16,6 @@ parameters: - %rootDir%/../../../php_cs.php autoload_directories: - %rootDir%/../../../src - includes: - - vendor/phpstan/phpstan-doctrine/extension.neon - - vendor/phpstan/phpstan-doctrine/rules.neon - - vendor/phpstan/phpstan-phpunit/extension.neon - - vendor/phpstan/phpstan-phpunit/rules.neon - - vendor/phpstan/phpstan-symfony/extension.neon - - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - parameters: - symfony: - container_xml_path: %rootDir%/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml ignoreErrors: - '#PHPDoc tag @return with type object is not subtype of native type#' - '#Method .* should return .* but returns object#' @@ -30,4 +28,3 @@ parameters: - '#call_user_func_array expects callable()#' - '#Call to an undefined method Doctrine\\ORM\\Event\\LifecycleEventArgs::getNewValue()#' - '#Call to an undefined method Doctrine\\ORM\\Event\\LifecycleEventArgs::getOldValue()#' - - '#.* Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch().*invoked with 2 parameters, 1 required.#' diff --git a/src/dist/phpunit.xml.dist b/src/dist/phpunit.xml.dist index e51999f..0bff411 100644 --- a/src/dist/phpunit.xml.dist +++ b/src/dist/phpunit.xml.dist @@ -2,7 +2,7 @@