mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 03:40:50 +00:00
184cf49468
f9de5d311e
[Php80] Handle RenameClassRector+AnnotationToAttributeRector with auto import and existing attribute defined (#5219)
36 lines
988 B
PHP
36 lines
988 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Testing\Fixture;
|
|
|
|
use RectorPrefix202311\Nette\Utils\FileSystem;
|
|
/**
|
|
* @api
|
|
*/
|
|
final class FixtureSplitter
|
|
{
|
|
public static function containsSplit(string $fixtureFileContent) : bool
|
|
{
|
|
return \strpos($fixtureFileContent, "-----\n") !== \false || \strpos($fixtureFileContent, "-----\r\n") !== \false;
|
|
}
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function split(string $filePath) : array
|
|
{
|
|
$fixtureFileContents = FileSystem::read($filePath);
|
|
return self::splitFixtureFileContents($fixtureFileContents);
|
|
}
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function splitFixtureFileContents(string $fixtureFileContents) : array
|
|
{
|
|
$posixContents = \explode("-----\n", $fixtureFileContents);
|
|
if (isset($posixContents[1])) {
|
|
return $posixContents;
|
|
}
|
|
return \explode("-----\r\n", $fixtureFileContents);
|
|
}
|
|
}
|