-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
1 parent
d32bd7d
commit 8aa33fe
Showing
3,209 changed files
with
310,239 additions
and
6,069 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,4 +1,5 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
<?php | ||
namespace ECSPrefix202402; | ||
|
||
require __DIR__ . '/ecs.php'; |
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,77 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
declare (strict_types=1); | ||
namespace ECSPrefix202402; | ||
|
||
use PhpCsFixer\RuleSet\RuleSets; | ||
|
||
// this helper script generates the withPhpCsFixerSets() method for ECSConfigBuilder class | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$setsDirectory = __DIR__ . '/../vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/'; | ||
|
||
$setDefinitions = RuleSets::getSetDefinitions(); | ||
|
||
$setNames = []; | ||
foreach ($setDefinitions as $setDefinition) { | ||
$setNames[] = $setDefinition->getName(); | ||
} | ||
|
||
// create withPhpCsFixerSets() method here | ||
$classMethod = new \PhpParser\Node\Stmt\ClassMethod('withPhpCsFixerSets'); | ||
$classMethod->flags = \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC; | ||
$classMethod->returnType = new \PhpParser\Node\Name('self'); | ||
|
||
$classMethod = new \ECSPrefix202402\PhpParser\Node\Stmt\ClassMethod('withPhpCsFixerSets'); | ||
$classMethod->flags = \ECSPrefix202402\PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC; | ||
$classMethod->returnType = new \ECSPrefix202402\PhpParser\Node\Name('self'); | ||
foreach ($setNames as $setName) { | ||
// convert to PHP variable name | ||
$paramName = ltrim( $setName, '@'); | ||
|
||
$paramName = \ltrim($setName, '@'); | ||
$paramName = lowercaseUntilFirstLower($paramName); | ||
$paramName = str_replace(':r', 'R', $paramName); | ||
$paramName = str_replace(['.', '-', '_'], '', $paramName); | ||
|
||
$paramName = \str_replace(':r', 'R', $paramName); | ||
$paramName = \str_replace(['.', '-', '_'], '', $paramName); | ||
// lowercase only the first uppercase letters | ||
|
||
$classMethod->params[] = new \PhpParser\Node\Param( | ||
new \PhpParser\Node\Expr\Variable($paramName), | ||
new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('false')), | ||
new \PhpParser\Node\Identifier('bool') | ||
); | ||
|
||
$dynamicSetsPropertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), 'dynamicSets'); | ||
|
||
$classMethod->stmts[] = new \PhpParser\Node\Stmt\If_(new \PhpParser\Node\Expr\Variable($paramName), [ | ||
'stmts' => [ | ||
new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign( | ||
new \PhpParser\Node\Expr\ArrayDimFetch($dynamicSetsPropertyFetch), | ||
new \PhpParser\Node\Scalar\String_($setName) | ||
)) | ||
] | ||
]); | ||
$classMethod->params[] = new \ECSPrefix202402\PhpParser\Node\Param(new \ECSPrefix202402\PhpParser\Node\Expr\Variable($paramName), new \ECSPrefix202402\PhpParser\Node\Expr\ConstFetch(new \ECSPrefix202402\PhpParser\Node\Name('false')), new \ECSPrefix202402\PhpParser\Node\Identifier('bool')); | ||
$dynamicSetsPropertyFetch = new \ECSPrefix202402\PhpParser\Node\Expr\PropertyFetch(new \ECSPrefix202402\PhpParser\Node\Expr\Variable('this'), 'dynamicSets'); | ||
$classMethod->stmts[] = new \ECSPrefix202402\PhpParser\Node\Stmt\If_(new \ECSPrefix202402\PhpParser\Node\Expr\Variable($paramName), ['stmts' => [new \ECSPrefix202402\PhpParser\Node\Stmt\Expression(new \ECSPrefix202402\PhpParser\Node\Expr\Assign(new \ECSPrefix202402\PhpParser\Node\Expr\ArrayDimFetch($dynamicSetsPropertyFetch), new \ECSPrefix202402\PhpParser\Node\Scalar\String_($setName)))]]); | ||
} | ||
|
||
|
||
function lowercaseUntilFirstLower($input) { | ||
function lowercaseUntilFirstLower($input) | ||
{ | ||
$output = ''; | ||
$foundLower = false; | ||
|
||
for ($i = 0; $i < strlen($input); $i++) { | ||
$foundLower = \false; | ||
for ($i = 0; $i < \strlen($input); $i++) { | ||
$char = $input[$i]; | ||
|
||
if (!$foundLower && ctype_upper($char)) { | ||
$output .= strtolower($char); | ||
if (!$foundLower && \ctype_upper($char)) { | ||
$output .= \strtolower($char); | ||
} else { | ||
$output .= $char; | ||
$foundLower = true; | ||
$foundLower = \true; | ||
} | ||
} | ||
|
||
return $output; | ||
} | ||
// add dynamic set includes | ||
|
||
$classMethod->stmts[] = new \PhpParser\Node\Stmt\Return_(new \PhpParser\Node\Expr\Variable('this')); | ||
|
||
|
||
$printerStandard = new \PhpParser\PrettyPrinter\Standard(); | ||
$classMethod->stmts[] = new \ECSPrefix202402\PhpParser\Node\Stmt\Return_(new \ECSPrefix202402\PhpParser\Node\Expr\Variable('this')); | ||
$printerStandard = new \ECSPrefix202402\PhpParser\PrettyPrinter\Standard(); | ||
echo $printerStandard->prettyPrint([$classMethod]); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.