-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
f0bacb5
commit 0b97c8e
Showing
3,321 changed files
with
321,744 additions
and
6,194 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 ECSPrefix202405; | ||
|
||
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 ECSPrefix202405; | ||
|
||
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 \ECSPrefix202405\PhpParser\Node\Stmt\ClassMethod('withPhpCsFixerSets'); | ||
$classMethod->flags = \ECSPrefix202405\PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC; | ||
$classMethod->returnType = new \ECSPrefix202405\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 \ECSPrefix202405\PhpParser\Node\Param(new \ECSPrefix202405\PhpParser\Node\Expr\Variable($paramName), new \ECSPrefix202405\PhpParser\Node\Expr\ConstFetch(new \ECSPrefix202405\PhpParser\Node\Name('false')), new \ECSPrefix202405\PhpParser\Node\Identifier('bool')); | ||
$dynamicSetsPropertyFetch = new \ECSPrefix202405\PhpParser\Node\Expr\PropertyFetch(new \ECSPrefix202405\PhpParser\Node\Expr\Variable('this'), 'dynamicSets'); | ||
$classMethod->stmts[] = new \ECSPrefix202405\PhpParser\Node\Stmt\If_(new \ECSPrefix202405\PhpParser\Node\Expr\Variable($paramName), ['stmts' => [new \ECSPrefix202405\PhpParser\Node\Stmt\Expression(new \ECSPrefix202405\PhpParser\Node\Expr\Assign(new \ECSPrefix202405\PhpParser\Node\Expr\ArrayDimFetch($dynamicSetsPropertyFetch), new \ECSPrefix202405\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 \ECSPrefix202405\PhpParser\Node\Stmt\Return_(new \ECSPrefix202405\PhpParser\Node\Expr\Variable('this')); | ||
$printerStandard = new \ECSPrefix202405\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.