-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to Twig 3 and rename package (#9)
- Loading branch information
Showing
14 changed files
with
281 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.github export-ignore | ||
tests export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.php_cs.dist export-ignore | ||
.travis.yml export-ignore | ||
phpunit.xml.dist export-ignore |
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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Twig\DeferredExtension; | ||
|
||
use PhpCsFixer\Config; | ||
use PhpCsFixer\Fixer\ConfigurableFixerInterface; | ||
use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer; | ||
use PhpCsFixer\Fixer\FixerInterface; | ||
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer; | ||
use PhpCsFixer\Tokenizer\Tokens; | ||
|
||
final class FilterableFixer implements FixerInterface, ConfigurableFixerInterface | ||
{ | ||
private $fixer; | ||
private $pathRegex; | ||
|
||
public function __construct(FixerInterface $fixer, string $pathRegex) | ||
{ | ||
$this->fixer = $fixer; | ||
$this->pathRegex = $pathRegex; | ||
} | ||
|
||
public function isCandidate(Tokens $tokens) : bool | ||
{ | ||
return $this->fixer->isCandidate($tokens); | ||
} | ||
|
||
public function isRisky() : bool | ||
{ | ||
return $this->fixer->isRisky(); | ||
} | ||
|
||
public function fix(\SplFileInfo $file, Tokens $tokens) : void | ||
{ | ||
$this->fixer->fix($file, $tokens); | ||
} | ||
|
||
public function getName() : string | ||
{ | ||
return (new \ReflectionClass($this))->getShortName().'/'.$this->fixer->getName(); | ||
} | ||
|
||
public function getPriority() : int | ||
{ | ||
return $this->fixer->getPriority(); | ||
} | ||
|
||
public function supports(\SplFileInfo $file) : bool | ||
{ | ||
if (1 !== preg_match($this->pathRegex, $file->getRealPath())) { | ||
return false; | ||
} | ||
|
||
return $this->fixer->supports($file); | ||
} | ||
|
||
public function configure(array $configuration = null) | ||
{ | ||
if ($this->fixer instanceof ConfigurableFixerInterface) { | ||
$this->fixer->configure($configuration); | ||
} | ||
} | ||
}; | ||
|
||
$header = <<<EOF | ||
This file is part of the rybakit/twig-deferred-extension package. | ||
(c) Eugene Leonovich <gen.work@gmail.com> | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
EOF; | ||
|
||
return Config::create() | ||
->setUsingCache(false) | ||
->setRiskyAllowed(true) | ||
->registerCustomFixers([ | ||
new FilterableFixer(new NativeConstantInvocationFixer(), '/\bsrc\b/'), | ||
new FilterableFixer(new NativeFunctionInvocationFixer(), '/\bsrc\b/'), | ||
]) | ||
->setRules([ | ||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'binary_operator_spaces' => ['operators' => ['=' => null, '=>' => null]], | ||
'declare_strict_types' => true, | ||
'native_constant_invocation' => false, | ||
'native_function_invocation' => false, | ||
'FilterableFixer/native_constant_invocation' => true, | ||
'FilterableFixer/native_function_invocation' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'ordered_imports' => [ | ||
'sort_algorithm' => 'alpha', | ||
'imports_order' => ['class', 'function', 'const'], | ||
], | ||
'phpdoc_align' => false, | ||
'phpdoc_order' => true, | ||
'phpdoc_to_comment' => false, | ||
'phpdoc_separation' => false, // do not separate @param and @psalm-param | ||
'return_type_declaration' => ['space_before' => 'one'], | ||
'strict_comparison' => true, | ||
'header_comment' => [ | ||
'comment_type' => 'PHPDoc', | ||
'header' => $header, | ||
'location' => 'after_open', | ||
'separate' => 'both', | ||
], | ||
]) | ||
; |
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,10 +1,9 @@ | ||
language: php | ||
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 | ||
|
||
install: | ||
- travis_retry composer install |
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
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
Oops, something went wrong.