mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-29 19:37:55 +01:00
drop html from RectorRecipe, buggy and confusing, handle manually (#4199)
This commit is contained in:
parent
a6444fb801
commit
42f377c825
@ -46,7 +46,7 @@ final class TemplateFinder
|
||||
$filePaths = $this->addRuleAndTestCase($rectorRecipe, $filePaths);
|
||||
|
||||
/** @var string[] $filePaths */
|
||||
$filePaths[] = $this->resolveFixtureFilePath($rectorRecipe->isPhpSnippet());
|
||||
$filePaths[] = $this->resolveFixtureFilePath();
|
||||
|
||||
$this->ensureFilePathsExists($filePaths);
|
||||
|
||||
@ -85,14 +85,9 @@ final class TemplateFinder
|
||||
return $filePaths;
|
||||
}
|
||||
|
||||
private function resolveFixtureFilePath(bool $isPhpSnippet): string
|
||||
private function resolveFixtureFilePath(): string
|
||||
{
|
||||
if ($isPhpSnippet) {
|
||||
return __DIR__ . '/../../templates/rules/__package__/tests/Rector/__Category__/__Name__/Fixture/fixture.php.inc';
|
||||
}
|
||||
|
||||
// is html snippet
|
||||
return __DIR__ . '/../../templates/rules/__package__/tests/Rector/__Category__/__Name__/Fixture/html_fixture.php.inc';
|
||||
return __DIR__ . '/../../templates/rules/__package__/tests/Rector/__Category__/__Name__/Fixture/fixture.php.inc';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,11 +43,6 @@ final class RectorRecipe
|
||||
*/
|
||||
private $isRectorRepository = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isPhpSnippet = true;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -182,11 +177,6 @@ final class RectorRecipe
|
||||
return $this->extraFileContent;
|
||||
}
|
||||
|
||||
public function isPhpSnippet(): bool
|
||||
{
|
||||
return $this->isPhpSnippet;
|
||||
}
|
||||
|
||||
public function isRectorRepository(): bool
|
||||
{
|
||||
return $this->isRectorRepository;
|
||||
@ -293,8 +283,6 @@ final class RectorRecipe
|
||||
|
||||
private function setCodeBefore(string $codeBefore): void
|
||||
{
|
||||
$this->detectIsPhpSnippet($codeBefore);
|
||||
|
||||
$this->codeBefore = $this->normalizeCode($codeBefore);
|
||||
}
|
||||
|
||||
@ -311,12 +299,6 @@ final class RectorRecipe
|
||||
$this->category = (string) Strings::after($nodeTypes[0], '\\', -1);
|
||||
}
|
||||
|
||||
private function detectIsPhpSnippet(string $codeBefore): void
|
||||
{
|
||||
// dummy yet effective way to detect PHP snippet from HTML
|
||||
$this->isPhpSnippet = Strings::startsWith($codeBefore, '<?php') || Strings::match($codeBefore, '#^class #ms');
|
||||
}
|
||||
|
||||
private function normalizeCode(string $code): string
|
||||
{
|
||||
if (Strings::startsWith($code, '<?php')) {
|
||||
|
@ -1,3 +0,0 @@
|
||||
__CodeBefore__
|
||||
-----
|
||||
__CodeAfter__
|
Loading…
x
Reference in New Issue
Block a user