-
Notifications
You must be signed in to change notification settings - Fork 7
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
0 parents
commit 35c81c3
Showing
373 changed files
with
21,206 additions
and
0 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,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 4 |
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,9 @@ | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
|
||
ecs.php export-ignore | ||
phpstan.neon export-ignore | ||
phpunit.xml export-ignore | ||
stubs export-ignore | ||
tests 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,35 @@ | ||
name: Code Analysis | ||
|
||
on: | ||
pull_request: null | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
code_analysis: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
actions: | ||
- | ||
name: 'PHPStan' | ||
run: composer phpstan | ||
- | ||
name: 'ECS' | ||
run: composer check-cs | ||
|
||
name: ${{ matrix.actions.name }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 7.3 | ||
coverage: none | ||
|
||
- uses: "ramsey/composer-install@v1" | ||
|
||
- run: ${{ matrix.actions.run }} |
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,29 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: null | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ['7.3', '7.4', '8.0'] | ||
|
||
name: PHP ${{ matrix.php }} tests | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: none | ||
|
||
- uses: "ramsey/composer-install@v1" | ||
|
||
- run: vendor/bin/phpunit tests |
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,20 @@ | ||
/vendor | ||
composer.lock | ||
|
||
# PHPStorm meta files | ||
.idea/ | ||
|
||
.phpunit.result.cache | ||
|
||
# often customized locally - example on Github is just fine | ||
rector-recipe.php | ||
|
||
# testing | ||
abz | ||
|
||
# scoped & downgraded version | ||
php-scoper.phar | ||
box.phar | ||
php-parallel-lint | ||
|
||
tmp |
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,9 @@ | ||
# Rector Rules for Nette | ||
|
||
## Install | ||
|
||
```bash | ||
composer require rector/rector-nette | ||
``` | ||
|
||
@todo |
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,36 @@ | ||
{ | ||
"name": "rector/rector-nette", | ||
"license": "MIT", | ||
"description": "Rector upgrades rules for Nette Framework", | ||
"require": { | ||
"php": ">=7.3", | ||
"ext-xml": "*", | ||
"rector/rector": "dev-main" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5", | ||
"symplify/phpstan-rules": "^9.2", | ||
"symplify/phpstan-extensions": "^9.2", | ||
"symplify/easy-coding-standard": "^9.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Rector\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Rector\\Tests\\": "tests" | ||
}, | ||
"classmap": [ | ||
"stubs" | ||
] | ||
}, | ||
"scripts": { | ||
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify", | ||
"check-cs": "vendor/bin/ecs check --ansi", | ||
"fix-cs": "vendor/bin/ecs check --fix --ansi" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$services = $containerConfigurator->services(); | ||
|
||
$services->defaults() | ||
->public() | ||
->autowire() | ||
->autoconfigure(); | ||
|
||
$services->load('Rector\\', __DIR__ . '/../src') | ||
->exclude([__DIR__ . '/../src/*/{Rector,ValueObject}']); | ||
}; |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
use Symplify\EasyCodingStandard\ValueObject\Option; | ||
use Symplify\EasyCodingStandard\ValueObject\Set\SetList; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$parameters = $containerConfigurator->parameters(); | ||
|
||
$parameters->set(Option::PATHS, [ | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
__DIR__ . '/config', | ||
__DIR__ . '/ecs.php', | ||
]); | ||
|
||
$parameters->set(Option::SETS, [SetList::PSR_12, SetList::SYMPLIFY, SetList::COMMON, SetList::CLEAN_CODE]); | ||
$parameters->set(Option::SKIP, [ | ||
'*/Source/*', '*/Fixture/*', | ||
|
||
// breaks annotated code - removed on symplify dev-main | ||
\PhpCsFixer\Fixer\ReturnNotation\ReturnAssignmentFixer::class, | ||
]); | ||
$parameters->set(Option::LINE_ENDING, "\n"); | ||
}; |
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,58 @@ | ||
includes: | ||
- vendor/symplify/phpstan-extensions/config/config.neon | ||
- vendor/symplify/phpstan-rules/config/symplify-rules.neon | ||
|
||
parameters: | ||
level: max | ||
|
||
paths: | ||
- config | ||
- src | ||
- tests | ||
|
||
scanDirectories: | ||
- stubs | ||
|
||
excludePaths: | ||
- */Source/* | ||
- *Source/* | ||
|
||
# ignoreErrors: | ||
# - | ||
# message: '#Do not inherit from abstract class, better use composition#' | ||
# path: "*Rector.php" | ||
# | ||
# - '#Constant string value need to only have small letters, _, \-, \. and numbers#' | ||
# | ||
# # symfony native values | ||
# - | ||
# message: '#Parameter "(.*?)" cannot be nullable#' | ||
# path: src/Symfony/ValueObject/ServiceDefinition.php | ||
# | ||
# - | ||
# message: '#Use decoupled factory service to create "PHPStan\\Type\\ObjectType" object#' | ||
# path: src/Symfony/ValueObject/ServiceMap/ServiceMap.php | ||
# | ||
# - | ||
# message: '#Parameter "return" cannot be nullable#' | ||
# path: src/Symfony/NodeFactory/ThisRenderFactory.php | ||
# | ||
# # fixed in dev php-parser | ||
# - '#Method Rector\\Symfony\\NodeFactory\\RouteNameClassFactory\:\:create\(\) should return PhpParser\\Node\\Stmt\\Namespace_ but returns PhpParser\\Node#' | ||
# | ||
# # should be fixed on master | ||
# - | ||
# message: '#Do not use chained method calls\. Put each on separated lines#' | ||
# paths: | ||
# - src/Symfony/ConstantNameAndValueMatcher.php | ||
# | ||
# - | ||
# message: '#Parameter "priority" cannot be nullable#' | ||
# paths: | ||
# - src/Symfony/NodeFactory/GetSubscribedEventsClassMethodFactory.php | ||
# | ||
# # good place for value object | ||
# - | ||
# message: '#Use another value object over array with string\-keys and objects, array<string, ValueObject\>#' | ||
# paths: | ||
# - src/Symfony3/Rector/MethodCall/FormTypeInstanceToClassConstRector.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="main"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Nette\Contract; | ||
|
||
use PhpParser\Node\Expr; | ||
use PhpParser\Node\Expr\Assign; | ||
use PhpParser\Node\Expr\BinaryOp\Identical; | ||
use PhpParser\Node\Expr\Cast\Bool_; | ||
use PhpParser\Node\Expr\FuncCall; | ||
use PhpParser\Node\Expr\StaticCall; | ||
|
||
interface PregToNetteUtilsStringInterface | ||
{ | ||
public function refactorIdentical(Identical $identical): ?Bool_; | ||
|
||
/** | ||
* @return FuncCall|StaticCall|Assign|null | ||
*/ | ||
public function refactorFuncCall(FuncCall $funcCall): ?Expr; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Nette/Contract/ValueObject/ParameterArrayInterface.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Nette\Contract\ValueObject; | ||
|
||
use PhpParser\Node\Expr; | ||
|
||
interface ParameterArrayInterface | ||
{ | ||
/** | ||
* @return array<string, Expr> | ||
*/ | ||
public function getTemplateVariables(): array; | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getConditionalVariableNames(): array; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Nette/NodeAnalyzer/ConditionalTemplateAssignReplacer.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Nette\NodeAnalyzer; | ||
|
||
use PhpParser\Node\Expr\Variable; | ||
use Rector\Nette\ValueObject\TemplateParametersAssigns; | ||
|
||
/** | ||
* Replaces: | ||
* | ||
* if (...) { | ||
* $this->template->key = 'some'; | ||
* } else { | ||
* $this->template->key = 'another'; | ||
* } | ||
* | ||
* ↓ | ||
* | ||
* if (...) { | ||
* $key = 'some'; | ||
* } else { | ||
* $key = 'another'; | ||
* } | ||
*/ | ||
final class ConditionalTemplateAssignReplacer | ||
{ | ||
public function processClassMethod(TemplateParametersAssigns $templateParametersAssigns): void | ||
{ | ||
foreach ($templateParametersAssigns->getConditionalTemplateParameterAssign() as $conditionalTemplateParameterAssign) { | ||
$assign = $conditionalTemplateParameterAssign->getAssign(); | ||
$assign->var = new Variable($conditionalTemplateParameterAssign->getParameterName()); | ||
} | ||
} | ||
} |
Oops, something went wrong.