Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ composer.lock

# often customized locally - example on Github is just fine
create-rector.yaml
phpstan-dependencies.json
phpstan-paths.txt

# tests - travis
/laravel-dir

uuid-migration.json
/utils

# compiler
/compiler/composer.lock
/compiler/vendor
/tmp

# from "scan-fatal-errors" command
rector-types.yaml
rector-types.yaml
1 change: 0 additions & 1 deletion compiler/build/box.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"directories": [
"config",
"src",
"helpers",
"packages",
"vendor"
],
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@
"Rector\\Twig\\": "packages/Twig/src",
"Rector\\TypeDeclaration\\": "packages/TypeDeclaration/src",
"Rector\\ZendToSymfony\\": "packages/ZendToSymfony/src",
"Rector\\Utils\\DocumentationGenerator\\": "utils/DocumentationGenerator/src",
"Rector\\Utils\\RectorGenerator\\": "utils/RectorGenerator/src",
"Rector\\Utils\\PHPStanAttributeTypeSyncer\\": "utils/PHPStanAttributeTypeSyncer/src",
"Rector\\Utils\\PHPStanStaticTypeMapperChecker\\": "utils/PHPStanStaticTypeMapperChecker/src",
"Rector\\RectorGenerator\\": "packages/RectorGenerator/src",
"Rector\\StrictCodeQuality\\": "packages/StrictCodeQuality/src",
"Rector\\DynamicTypeAnalysis\\": "packages/DynamicTypeAnalysis/src",
"Rector\\PhpDeglobalize\\": "packages/PhpDeglobalize/src",
Expand All @@ -116,7 +113,7 @@
"Rector\\CakePHPToSymfony\\": "packages/CakePHPToSymfony/src"
},
"files": [
"helpers/rector_dump_function.php"
"src/functions/rector_dump_function.php"
]
},
"autoload-dev": {
Expand Down Expand Up @@ -176,6 +173,9 @@
"Rector\\DynamicTypeAnalysis\\Tests\\": "packages/DynamicTypeAnalysis/tests",
"Rector\\PhpDeglobalize\\Tests\\": "packages/PhpDeglobalize/tests",
"Rector\\Phalcon\\Tests\\": "packages/Phalcon/tests",
"Rector\\Utils\\DocumentationGenerator\\": "utils/DocumentationGenerator/src",
"Rector\\Utils\\PHPStanAttributeTypeSyncer\\": "utils/PHPStanAttributeTypeSyncer/src",
"Rector\\Utils\\PHPStanStaticTypeMapperChecker\\": "utils/PHPStanStaticTypeMapperChecker/src",
"Rector\\DoctrineGedmoToKnplabs\\Tests\\": "packages/DoctrineGedmoToKnplabs/tests",
"Rector\\MinimalScope\\Tests\\": "packages/MinimalScope/tests",
"Rector\\Polyfill\\Tests\\": "packages/Polyfill/tests",
Expand Down
3 changes: 2 additions & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ imports:
- { resource: '../packages/**/config/config.yaml' }
- { resource: 'services.yaml' }
# only in local repository
- { resource: '../utils/**/config/config.yaml' }
# ignore errors, because utils are not part of composer package nor rector.phar
- { resource: '../utils/**/config/config.yaml', ignore_errors: true }

parameters:
# processed paths
Expand Down
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
- '../src/DependencyInjection/Loader/*'
- '../src/HttpKernel/*'
- '../src/ValueObject/*'
- '../src/functions/*'

# extra services
Rector\Symfony\Rector\Form\Helper\FormTypeStringToTypeProvider: null
Expand Down
17 changes: 0 additions & 17 deletions helpers/rector_dump_function.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
autowire: true
autoconfigure: true

Rector\Utils\RectorGenerator\:
Rector\RectorGenerator\:
resource: '../src'
exclude:
- '../src/Exception/*'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\Command;
namespace Rector\RectorGenerator\Command;

use Nette\Utils\FileSystem;
use Nette\Utils\Strings;
use Rector\Utils\RectorGenerator\Composer\ComposerPackageAutoloadUpdater;
use Rector\Utils\RectorGenerator\Configuration\ConfigurationFactory;
use Rector\Utils\RectorGenerator\FileSystem\TemplateFileSystem;
use Rector\Utils\RectorGenerator\Finder\TemplateFinder;
use Rector\Utils\RectorGenerator\TemplateVariablesFactory;
use Rector\Utils\RectorGenerator\ValueObject\Configuration;
use Rector\RectorGenerator\Composer\ComposerPackageAutoloadUpdater;
use Rector\RectorGenerator\Configuration\ConfigurationFactory;
use Rector\RectorGenerator\FileSystem\TemplateFileSystem;
use Rector\RectorGenerator\Finder\TemplateFinder;
use Rector\RectorGenerator\TemplateVariablesFactory;
use Rector\RectorGenerator\ValueObject\Configuration;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\Composer;
namespace Rector\RectorGenerator\Composer;

use Rector\Utils\RectorGenerator\FileSystem\JsonFileSystem;
use Rector\Utils\RectorGenerator\ValueObject\Configuration;
use Rector\Utils\RectorGenerator\ValueObject\Package;
use Rector\RectorGenerator\FileSystem\JsonFileSystem;
use Rector\RectorGenerator\ValueObject\Configuration;
use Rector\RectorGenerator\ValueObject\Package;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\Process;

Expand Down Expand Up @@ -50,7 +50,7 @@ public function processComposerAutoload(Configuration $configuration): void
$package->getSrcNamespace(),
PHP_EOL
));
if ($isConfirmed === false) {
if (! $isConfirmed) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\Configuration;
namespace Rector\RectorGenerator\Configuration;

use Nette\Utils\Strings;
use PhpParser\Node;
use Rector\Exception\ShouldNotHappenException;
use Rector\RectorGenerator\Guard\RecipeGuard;
use Rector\RectorGenerator\Node\NodeClassProvider;
use Rector\RectorGenerator\ValueObject\Configuration;
use Rector\Set\Set;
use Rector\Utils\RectorGenerator\Guard\RecipeGuard;
use Rector\Utils\RectorGenerator\Node\NodeClassProvider;
use Rector\Utils\RectorGenerator\ValueObject\Configuration;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\Exception;
namespace Rector\RectorGenerator\Exception;

use Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\FileSystem;
namespace Rector\RectorGenerator\FileSystem;

use Nette\Utils\FileSystem;
use Nette\Utils\Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\FileSystem;
namespace Rector\RectorGenerator\FileSystem;

use Nette\Utils\Strings;

Expand All @@ -29,14 +29,13 @@ public function inlineSections(string $jsonContent, array $sections): string
public function inlineAuthors(string $jsonContent): string
{
$pattern = '#(?<start>"authors": \[\s+)(?<content>.*?)(?<end>\s+\](,))#ms';
$jsonContent = Strings::replace($jsonContent, $pattern, function (array $match): string {

return Strings::replace($jsonContent, $pattern, function (array $match): string {
$inlined = Strings::replace($match['content'], '#\s+#', ' ');
$inlined = trim($inlined);
$inlined = Strings::replace($inlined, '#},#', "},\n ");

return $match['start'] . $inlined . $match['end'];
});

return $jsonContent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\FileSystem;
namespace Rector\RectorGenerator\FileSystem;

use Nette\Utils\Strings;
use Rector\Utils\RectorGenerator\Finder\TemplateFinder;
use Rector\Utils\RectorGenerator\ValueObject\Configuration;
use Rector\Utils\RectorGenerator\ValueObject\Package;
use Rector\RectorGenerator\Finder\TemplateFinder;
use Rector\RectorGenerator\ValueObject\Configuration;
use Rector\RectorGenerator\ValueObject\Package;
use Symplify\SmartFileSystem\SmartFileInfo;

final class TemplateFileSystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\Finder;
namespace Rector\RectorGenerator\Finder;

use Symfony\Component\Finder\Finder;
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
Expand Down Expand Up @@ -35,9 +35,10 @@ public function __construct(FinderSanitizer $finderSanitizer)
*/
public function find(bool $isPhpSnippet): array
{
$finder = Finder::create()->files()
->in(self::TEMPLATES_DIRECTORY)
->exclude(self::TEMPLATES_FIXTURE_DIRECTORY);
$finder = Finder::create()
->files()
->exclude('Fixture/')
->in(self::TEMPLATES_DIRECTORY);

$smartFileInfos = $this->finderSanitizer->sanitize($finder);
$smartFileInfos[] = $this->createFixtureSmartFileInfo($isPhpSnippet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\Guard;
namespace Rector\RectorGenerator\Guard;

use Rector\Utils\RectorGenerator\Exception\ConfigurationException;
use Rector\RectorGenerator\Exception\ConfigurationException;

final class RecipeGuard
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\Node;
namespace Rector\RectorGenerator\Node;

use Nette\Loaders\RobotLoader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator;
namespace Rector\RectorGenerator;

use Nette\Utils\Strings;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Name\FullyQualified;
use Rector\PhpParser\Printer\BetterStandardPrinter;
use Rector\Utils\RectorGenerator\ValueObject\Configuration;
use Rector\RectorGenerator\ValueObject\Configuration;

final class TemplateVariablesFactory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\ValueObject;
namespace Rector\RectorGenerator\ValueObject;

use Nette\Utils\Strings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Utils\RectorGenerator\ValueObject;
namespace Rector\RectorGenerator\ValueObject;

final class Package
{
Expand Down
21 changes: 21 additions & 0 deletions src/functions/rector_dump_function.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Tracy\Debugger;

if (! function_exists('rd')) {
function rd($var)
{
array_map([Debugger::class, 'dump'], func_get_args());
return $var;
}
}

if (! function_exists('rdd')) {
function rdd($var): void
{
rd($var);
die;
}
}