Skip to content

Commit

Permalink
Add Symfony 5 support + update dependency packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sci3ma committed Dec 28, 2019
1 parent a98b318 commit b1ddaed
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 26 deletions.
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
31 changes: 30 additions & 1 deletion src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class InstallCommand extends AbstractCommand
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Create configuration files of SymfonyGrumPHP')
Expand Down Expand Up @@ -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);
}
}
}
4 changes: 3 additions & 1 deletion src/Command/UninstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class UninstallCommand extends AbstractCommand
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setDescription('Remove configuration files of SymfonyGrumPHP')
Expand All @@ -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;
}
}
3 changes: 2 additions & 1 deletion src/dist/grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ parameters:
metadata:
priority: 999
phpcpd:
directory: '.'
directory: ['.']
exclude: ['vendor', 'public', 'var', 'config', 'bin', 'translations', 'src/Migrations']
names_exclude: []
fuzzy: false
Expand Down Expand Up @@ -62,6 +62,7 @@ parameters:
phpstan:
configuration: phpstan.neon
level: 7
memory_limit: '-1'
metadata:
priority: 993
securitychecker:
Expand Down
19 changes: 8 additions & 11 deletions src/dist/phpstan.neon
Original file line number Diff line number Diff line change
@@ -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/*
Expand All @@ -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#'
Expand All @@ -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.#'
2 changes: 1 addition & 1 deletion src/dist/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="bin/.phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="config/bootstrap.php"
Expand Down

0 comments on commit b1ddaed

Please sign in to comment.