-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⬆️ upgrade grumphp to 0.16.* and php to mininum 7.2 (#9)
⬆️ upgrade grumphp to 0.16.* and php to mininum 7.2
- Loading branch information
Showing
5 changed files
with
23 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | ||
|
@@ -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']); | ||
|
@@ -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 */ | ||
|
@@ -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); | ||
|
@@ -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'); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|