-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
233 additions
and
176 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
vendor | ||
|
||
.phpunit.result.cache | ||
.php-cs-fixer.cache | ||
|
||
# Devenv | ||
.devenv* | ||
|
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,59 @@ | ||
<?php | ||
/* | ||
* This document has been generated with | ||
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.14|configurator | ||
* you can change this configuration by importing this file. | ||
*/ | ||
return (new PhpCsFixer\Config()) | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PSR12' => true, | ||
'@PSR12:risky' => true, | ||
'@PHP80Migration:risky' => true, | ||
'@PHP81Migration' => true, | ||
'@PhpCsFixer' => true, | ||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
// Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line. | ||
'blank_line_after_opening_tag' => false, | ||
// Using `isset($var) &&` multiple times should be done in one call. | ||
'combine_consecutive_issets' => false, | ||
// Calling `unset` on multiple items should be done in one call. | ||
'combine_consecutive_unsets' => false, | ||
// Concatenation should be spaced according configuration. | ||
'concat_space' => ['spacing'=>'one'], | ||
// Pre- or post-increment and decrement operators should be used if possible. | ||
'increment_style' => ['style'=>'post'], | ||
// Ensure there is no code on the same line as the PHP open tag. | ||
'linebreak_after_opening_tag' => false, | ||
// Replace non multibyte-safe functions with corresponding mb function. | ||
'mb_str_functions' => true, | ||
// Add leading `\` before function invocation to speed up resolving. | ||
'native_function_invocation' => false, | ||
// Adds or removes `?` before type declarations for parameters with a default `null` value. | ||
'nullable_type_declaration_for_default_null_value' => true, | ||
// All items of the given phpdoc tags must be either left-aligned or (by default) aligned vertically. | ||
'phpdoc_align' => ['align'=>'left'], | ||
// PHPDoc summary should end in either a full stop, exclamation mark, or question mark. | ||
'phpdoc_summary' => false, | ||
// Throwing exception must be done in single line. | ||
'single_line_throw' => false, | ||
// Comparisons should be strict. | ||
'strict_comparison' => true, | ||
// Functions should be used with `$strict` param set to `true`. | ||
'strict_param' => true, | ||
// Anonymous functions with one-liner return statement must use arrow functions. | ||
'use_arrow_functions' => false, | ||
// Write conditions in Yoda style (`true`), non-Yoda style (`['equal' => false, 'identical' => false, 'less_and_greater' => false]`) or ignore those conditions (`null`) based on configuration. | ||
'yoda_style' => false, | ||
// Currently waiting for https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/5572 to be implemented to ignore @var (needed for LSP) | ||
'phpdoc_to_comment' => false, | ||
// Multi-line arrays, arguments list, parameters list and `match` expressions must have a trailing comma. | ||
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'arrays', 'match', 'parameters']], | ||
]) | ||
->setFinder(PhpCsFixer\Finder::create() | ||
->exclude('vendor') | ||
->exclude('stubs') | ||
->in(__DIR__) | ||
) | ||
; |
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,63 +1,60 @@ | ||
<?php | ||
|
||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; | ||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; | ||
<?php declare(strict_types=1); | ||
|
||
$place = $_SERVER['argv'][1]; | ||
$name = $_SERVER['argv'][2]; | ||
|
||
$rectorTpl = <<<'RECTOR' | ||
<?php | ||
<?php | ||
namespace #NAMESPACE#; | ||
namespace #NAMESPACE#; | ||
use PhpParser\Node; | ||
use Rector\Core\Rector\AbstractRector; | ||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; | ||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; | ||
use PhpParser\Node; | ||
use Rector\Core\Rector\AbstractRector; | ||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; | ||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; | ||
class #NAME# extends AbstractRector | ||
{ | ||
public function getRuleDefinition(): RuleDefinition | ||
class #NAME# extends AbstractRector | ||
{ | ||
return new RuleDefinition('NAME', [ | ||
new CodeSample( | ||
<<<'CODE_SAMPLE' | ||
class Foo implements Test { | ||
} | ||
CODE_SAMPLE | ||
, | ||
<<<'PHP' | ||
class Foo extends AbstractTest { | ||
} | ||
PHP | ||
), | ||
]); | ||
} | ||
public function getRuleDefinition(): RuleDefinition | ||
{ | ||
return new RuleDefinition('NAME', [ | ||
new CodeSample( | ||
<<<'CODE_SAMPLE' | ||
class Foo implements Test { | ||
public function getNodeTypes(): array | ||
{ | ||
return [ | ||
Node\Stmt\Class_::class, | ||
]; | ||
} | ||
CODE_SAMPLE | ||
, | ||
<<<'PHP' | ||
class Foo extends AbstractTest { | ||
/** | ||
* @param Node\Stmt\Class_ $node | ||
*/ | ||
public function refactor(Node $node): ?Node | ||
{ | ||
return null; | ||
} | ||
} | ||
RECTOR; | ||
PHP | ||
), | ||
]); | ||
} | ||
public function getNodeTypes(): array | ||
{ | ||
return [ | ||
Node\Stmt\Class_::class, | ||
]; | ||
} | ||
/** | ||
* @param Node\Stmt\Class_ $node | ||
*/ | ||
public function refactor(Node $node): ?Node | ||
{ | ||
return null; | ||
} | ||
} | ||
RECTOR; | ||
|
||
$vals = [ | ||
'#NAMESPACE#' => 'Frosh\Rector\Rule\\' . $place, | ||
'#NAME#' => $name, | ||
]; | ||
$rector = str_replace(array_keys($vals), $vals, $rectorTpl); | ||
|
||
file_put_contents(sprintf('%s/src/Rule/%s/%s.php', __DIR__, $place, $name), $rector,LOCK_EX); | ||
file_put_contents(sprintf('%s/src/Rule/%s/%s.php', __DIR__, $place, $name), $rector, \LOCK_EX); |
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.