mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 17:00:51 +00:00
compiler: update dependencies
This commit is contained in:
parent
48431d5e11
commit
d3902eec38
|
@ -66,6 +66,12 @@ final class EasyPrefixer
|
|||
|
||||
return $prefix . '\\' . $class;
|
||||
}
|
||||
|
||||
public static function unprefixQuotedValues(string $prefix, string $content): string
|
||||
{
|
||||
$content = str_replace(sprintf('\'%s\\\\r\\\\n\'', $prefix), '\'\\\\r\\\\n\'', $content);
|
||||
return str_replace(sprintf('\'%s\\\\', $prefix), '\'', $content);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -151,10 +157,7 @@ return [
|
|||
return $content;
|
||||
}
|
||||
|
||||
var_dump($content);
|
||||
die;
|
||||
|
||||
// @todo - prefix classes in yaml files?
|
||||
// @todo - unprefix classes in yaml files?
|
||||
return $content;
|
||||
},
|
||||
|
||||
|
@ -200,12 +203,15 @@ return [
|
|||
|
||||
// mimics https://github.com/phpstan/phpstan-src/commit/fd8f0a852207a1724ae4a262f47d9a449de70da4#diff-463a36e4a5687fb2366b5ee56cdad92d
|
||||
function (string $filePath, string $prefix, string $content): string {
|
||||
if (strpos($filePath, 'src/') !== 0) {
|
||||
if (! Strings::contains($filePath, 'src/')) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$content = str_replace(sprintf('\'%s\\\\r\\\\n\'', $prefix), '\'\\\\r\\\\n\'', $content);
|
||||
return str_replace(sprintf('\'%s\\\\', $prefix), '\'', $content);
|
||||
if (Strings::startsWith($filePath, 'src/')) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
return EasyPrefixer::unprefixQuotedValues($prefix, $content);
|
||||
},
|
||||
],
|
||||
'whitelist' => EasyPrefixer::EXCLUDED_NAMESPACES,
|
||||
|
|
|
@ -5,20 +5,22 @@
|
|||
"require": {
|
||||
"php": "^7.2",
|
||||
"nette/neon": "^3.0",
|
||||
"nette/utils": "^3.0",
|
||||
"ondram/ci-detector": "^3.3",
|
||||
"nette/utils": "^3.1",
|
||||
"ondram/ci-detector": "^3.4",
|
||||
"sebastian/diff": "^3.0|^4.0",
|
||||
"symfony/console": "^4.4|^5.0",
|
||||
"symfony/process": "^4.4|^5.0",
|
||||
"symfony/filesystem": "^4.4|^5.0",
|
||||
"symfony/finder": "^4.4|^5.0",
|
||||
"symplify/console-color-diff": "^7.3",
|
||||
"symplify/auto-bind-parameter": "^7.3",
|
||||
"symplify/package-builder": "^7.3"
|
||||
"symplify/console-color-diff": "^8.0",
|
||||
"symplify/auto-bind-parameter": "^8.0",
|
||||
"symplify/package-builder": "^8.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rector\\Compiler\\": "src"
|
||||
}
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
|
7
compiler/tests/Fixture/nested/unprefix_this.neon
Normal file
7
compiler/tests/Fixture/nested/unprefix_this.neon
Normal file
|
@ -0,0 +1,7 @@
|
|||
services:
|
||||
-
|
||||
arguments: 'Prefix__\SomeClass'
|
||||
-----
|
||||
services:
|
||||
-
|
||||
arguments: 'SomeClass'
|
|
@ -8,6 +8,7 @@ use Iterator;
|
|||
use Nette\Utils\Strings;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symplify\PackageBuilder\Tests\StaticFixtureLoader;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class ScopingTest extends TestCase
|
||||
|
@ -28,36 +29,26 @@ final class ScopingTest extends TestCase
|
|||
$this->patcherCallbacks = $scoper['patchers'];
|
||||
}
|
||||
|
||||
public function test(): void
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(SmartFileInfo $fileInfo): void
|
||||
{
|
||||
/** @var SmartFileInfo[] $fileInfos */
|
||||
$fileInfos = self::loadFromDirectory(__DIR__ . '/Fixture/');
|
||||
[$content, $expectedContent] = Strings::split($fileInfo->getContents(), "#-----\n#");
|
||||
|
||||
foreach ($fileInfos as $fileInfo) {
|
||||
[$content, $expectedContent] = Strings::split($fileInfo->getContents(), "#-----\n#");
|
||||
|
||||
foreach ($this->patcherCallbacks as $patcherCallback) {
|
||||
$relativeFilePath = $fileInfo->getRelativeFilePathFromDirectory(__DIR__ . '/Fixture');
|
||||
$content = $patcherCallback($relativeFilePath, self::PREFIX, $content);
|
||||
}
|
||||
|
||||
// normalize end-line spaces
|
||||
$expectedContent = rtrim($expectedContent);
|
||||
$content = rtrim($content);
|
||||
$this->assertSame($expectedContent, $content);
|
||||
foreach ($this->patcherCallbacks as $patcherCallback) {
|
||||
$relativeFilePath = $fileInfo->getRelativeFilePathFromDirectory(__DIR__ . '/Fixture');
|
||||
$content = $patcherCallback($relativeFilePath, self::PREFIX, $content);
|
||||
}
|
||||
|
||||
// normalize end-line spaces
|
||||
$expectedContent = rtrim($expectedContent);
|
||||
$content = rtrim($content);
|
||||
$this->assertSame($expectedContent, $content, $fileInfo->getRelativeFilePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Iterator<SmartFileInfo>
|
||||
*/
|
||||
private static function loadFromDirectory(string $directory): Iterator
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
$finder = (new Finder())->files()
|
||||
->in($directory);
|
||||
|
||||
foreach ($finder as $fileInfo) {
|
||||
yield new SmartFileInfo($fileInfo->getRealPath());
|
||||
}
|
||||
return StaticFixtureLoader::loadFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"nette/robot-loader": "^3.2",
|
||||
"nette/utils": "^3.1",
|
||||
"nikic/php-parser": "^4.4",
|
||||
"ondram/ci-detector": "^3.1",
|
||||
"ondram/ci-detector": "^3.4",
|
||||
"phpstan/phpdoc-parser": "^0.4.7",
|
||||
"phpstan/phpstan": "^0.12.25",
|
||||
"phpstan/phpstan-phpunit": "^0.12",
|
||||
|
|
Loading…
Reference in New Issue
Block a user