Skip to content

Commit

Permalink
⬆️ upgrade grumphp to 0.16.* and php to mininum 7.2 (#9)
Browse files Browse the repository at this point in the history
⬆️ upgrade grumphp to 0.16.* and php to mininum 7.2
  • Loading branch information
Kanti committed Oct 29, 2019
2 parents c53ce7d + fb88c70 commit aed5093
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 82 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ git:
depth: 5

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

env:
matrix:
-
- dependencies=lowest
- dependencies=highest

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"config": {
"platform": {
"php": "5.6"
"php": "7.2"
}
},
"support": {
Expand All @@ -25,10 +25,10 @@
}
},
"require": {
"php": ">=5.6",
"phpro/grumphp": "0.14.*"
"php": ">=7.2",
"phpro/grumphp": "0.16.*"
},
"require-dev": {
"squizlabs/php_codesniffer": "2.* | 3.*"
"squizlabs/php_codesniffer": ">=3.5.0 <4.0.0"
}
}
10 changes: 4 additions & 6 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ parameters:
- "exit;"
triggered_by: [php]
git_commit_message:
matchers:
- /(\[(!!!|WIP)]|)(\[(BUGFIX|FEATURE|TASK|CLEANUP|SECURITY)]|Merge branch '.+' into) .+/
case_insensitive: false
multiline: true
additional_modifiers: ''
max_subject_width: 120
max_body_width: 120
enforce_capitalized_subject: false
jsonlint:
detect_key_conflicts: true
phpcs:
standard: "PSR2"
standard: "PSR12"
warning_severity: 900000
tab_width: 4
yamllint: ~
Expand Down
65 changes: 13 additions & 52 deletions src/BomFixerTask.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
<?php

namespace PLUS\GrumPHPBomTask;

use GrumPHP\Runner\TaskResult;
use GrumPHP\Runner\TaskResultInterface;
use GrumPHP\Task\AbstractExternalTask;
use GrumPHP\Task\Context\ContextInterface;
use GrumPHP\Task\Context\GitPreCommitContext;
use GrumPHP\Task\Context\RunContext;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* Class BomFixerTask
*
* @author Matthias Vogel <[email protected]>
* @package PLUS\GrumphpBomTask
*/
class BomFixerTask extends AbstractExternalTask
{
/**
* @return string
*/
public function getName()
public function getName(): string
{
return 'plus_bom_fixer';
}

/**
* @return \Symfony\Component\OptionsResolver\OptionsResolver
* @throws \Symfony\Component\OptionsResolver\Exception\AccessException
* @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
*/
public function getConfigurableOptions()
public function getConfigurableOptions(): OptionsResolver
{
$resolver = new OptionsResolver();
$resolver->setDefaults(
Expand All @@ -43,29 +31,12 @@ public function getConfigurableOptions()
return $resolver;
}

/**
* @param ContextInterface $context
*
* @return bool
*/
public function canRunInContext(ContextInterface $context)
public function canRunInContext(ContextInterface $context): bool
{
return ($context instanceof GitPreCommitContext || $context instanceof RunContext);
}

/**
* @param ContextInterface $context
*
* @return \GrumPHP\Runner\TaskResult
* @throws \GrumPHP\Exception\RuntimeException
* @throws \Symfony\Component\OptionsResolver\Exception\AccessException
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
* @throws \Symfony\Component\OptionsResolver\Exception\MissingOptionsException
* @throws \Symfony\Component\OptionsResolver\Exception\NoSuchOptionException
* @throws \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
* @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
*/
public function run(ContextInterface $context)
public function run(ContextInterface $context): TaskResultInterface
{
$config = $this->getConfiguration();
$files = $context->getFiles()->extensions($config['triggered_by']);
Expand All @@ -75,10 +46,12 @@ public function run(ContextInterface $context)

if (is_file('./vendor/bin/fixbom')) {
$fixCommand = './vendor/bin/fixbom';
} else if (is_file('./bin/fixbom')) {
$fixCommand = './bin/fixbom';
} else {
$fixCommand = 'fixbom';
if (is_file('./bin/fixbom')) {
$fixCommand = './bin/fixbom';
} else {
$fixCommand = 'fixbom';
}
}
$shouldGetFixedLog = [];
/** @var \Symfony\Component\Finder\SplFileInfo $file */
Expand All @@ -102,14 +75,7 @@ public function run(ContextInterface $context)
return TaskResult::createPassed($this, $context);
}


/**
* @param string $filename
* @param string $search
*
* @return bool
*/
protected function fileInfoSearch($filename, $search)
protected function fileInfoSearch(string $filename, string $search): bool
{
$output = [];
exec('file ' . '"' . $filename . '"', $output, $returnVar);
Expand All @@ -119,12 +85,7 @@ protected function fileInfoSearch($filename, $search)
return false;
}

/**
* @param string $filename
*
* @return bool
*/
public function isFileWithBOM($filename)
public function isFileWithBOM(string $filename): bool
{
return $this->fileInfoSearch($filename, 'BOM');
}
Expand Down
17 changes: 1 addition & 16 deletions src/ExtensionLoader.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
<?php

namespace PLUS\GrumPHPBomTask;

use GrumPHP\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* Class ExtensionLoader
*
* @author Matthias Vogel <[email protected]>
* @package PLUS\GrumphpBomTask
*/
class ExtensionLoader implements ExtensionInterface
{
/**
* @param ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Definition
* @throws \Exception
* @throws \Symfony\Component\DependencyInjection\Exception\BadMethodCallException
* @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
* @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
* @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
*/
public function load(ContainerBuilder $container)
{
return $container->register('task.plus_bom_fixer', BomFixerTask::class)
Expand Down

0 comments on commit aed5093

Please sign in to comment.