Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Downgrade to PHP 7.4 #230

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 20 additions & 5 deletions packages/extension-installer/src/PackagesFileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,26 @@ private function __construct() {}
}
PHP;

public function __construct(
private readonly InstalledRepositoryInterface $repository,
private readonly InstallationManager $installationManager,
private readonly string $fileToGenerate
) {
/**
* @readonly
*/
private InstalledRepositoryInterface $repository;

/**
* @readonly
*/
private InstallationManager $installationManager;

/**
* @readonly
*/
private string $fileToGenerate;

public function __construct(InstalledRepositoryInterface $repository, InstallationManager $installationManager, string $fileToGenerate)
{
$this->repository = $repository;
$this->installationManager = $installationManager;
$this->fileToGenerate = $fileToGenerate;
}

public function generate(): void
Expand Down
28 changes: 22 additions & 6 deletions packages/fractor-composer-json/src/ComposerJsonFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,32 @@
/**
* @implements FileProcessor<ComposerJsonFractorRule>
*/
final readonly class ComposerJsonFileProcessor implements FileProcessor
final class ComposerJsonFileProcessor implements FileProcessor
{
/**
* @var iterable<ComposerJsonFractorRule>
* @readonly
*/
private iterable $rules;

/**
* @readonly
*/
private ComposerJsonPrinter $composerJsonPrinter;

/**
* @readonly
*/
private ComposerJsonFactory $composerJsonFactory;

/**
* @param iterable<ComposerJsonFractorRule> $rules
*/
public function __construct(
private iterable $rules,
private ComposerJsonPrinter $composerJsonPrinter,
private ComposerJsonFactory $composerJsonFactory
) {
public function __construct(iterable $rules, ComposerJsonPrinter $composerJsonPrinter, ComposerJsonFactory $composerJsonFactory)
{
$this->rules = $rules;
$this->composerJsonPrinter = $composerJsonPrinter;
$this->composerJsonFactory = $composerJsonFactory;
}

public function handle(File $file, iterable $appliedRules): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
use a9f\FractorComposerJson\Contract\ComposerJsonPrinter;
use Ergebnis\Json\Printer\PrinterInterface;

final readonly class ErgebnisComposerJsonPrinter implements ComposerJsonPrinter
final class ErgebnisComposerJsonPrinter implements ComposerJsonPrinter
{
public function __construct(
private PrinterInterface $printer
) {
/**
* @readonly
*/
private PrinterInterface $printer;

public function __construct(PrinterInterface $printer)
{
$this->printer = $printer;
}

public function printToString(Indent $indent, ComposerJson $composerJson): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
use a9f\Fractor\Application\ValueObject\File;
use a9f\FractorComposerJson\Contract\ComposerJson;

final readonly class EtaOrionisComposerJson implements ComposerJson
final class EtaOrionisComposerJson implements ComposerJson
{
public function __construct(
private \EtaOrionis\ComposerJsonManipulator\ComposerJson $composerJson
) {
/**
* @readonly
*/
private \EtaOrionis\ComposerJsonManipulator\ComposerJson $composerJson;

public function __construct(\EtaOrionis\ComposerJsonManipulator\ComposerJson $composerJson)
{
$this->composerJson = $composerJson;
}

public static function fromFile(File $file): self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@

namespace a9f\FractorComposerJson\ValueObject;

final readonly class PackageAndVersion
final class PackageAndVersion
{
public function __construct(
private string $packageName,
private string $version
) {
/**
* @readonly
*/
private string $packageName;

/**
* @readonly
*/
private string $version;

public function __construct(string $packageName, string $version)
{
$this->packageName = $packageName;
$this->version = $version;
}

public function getPackageName(): string
Expand Down
20 changes: 15 additions & 5 deletions packages/fractor-composer-json/src/ValueObject/RenamePackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@

namespace a9f\FractorComposerJson\ValueObject;

final readonly class RenamePackage
final class RenamePackage
{
public function __construct(
private string $oldPackageName,
private string $newPackageName
) {
/**
* @readonly
*/
private string $oldPackageName;

/**
* @readonly
*/
private string $newPackageName;

public function __construct(string $oldPackageName, string $newPackageName)
{
$this->oldPackageName = $oldPackageName;
$this->newPackageName = $newPackageName;
}

public function getOldPackageName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@
use a9f\FractorComposerJson\ChangePackageVersionComposerJsonFractor;
use Webmozart\Assert\Assert;

final readonly class ReplacePackageAndVersion
final class ReplacePackageAndVersion
{
/**
* @readonly
*/
private string $version;

/**
* @readonly
*/
private string $oldPackageName;

/**
* @readonly
*/
private string $newPackageName;

public function __construct(
string $oldPackageName,
string $newPackageName,
private string $version
string $version
) {
$this->version = $version;
Assert::notSame(
$oldPackageName,
$newPackageName,
Expand Down
14 changes: 10 additions & 4 deletions packages/fractor-fluid/src/FluidFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
/**
* @implements FileProcessor<FluidFractorRule>
*/
final readonly class FluidFileProcessor implements FileProcessor
final class FluidFileProcessor implements FileProcessor
{
/**
* @var iterable<FluidFractorRule>
* @readonly
*/
private iterable $rules;

/**
* @param iterable<FluidFractorRule> $rules
*/
public function __construct(
private iterable $rules
) {
public function __construct(iterable $rules)
{
$this->rules = $rules;
}

public function canHandle(File $file): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,27 @@
/**
* @implements Rule<Class_>
*/
final readonly class AddChangelogDocBlockForFractorRule implements Rule
final class AddChangelogDocBlockForFractorRule implements Rule
{
/**
* @var string
*/
public const ERROR_MESSAGE = 'Provide @changelog doc block for "%s" Fractor rule';

public function __construct(
private ReflectionProvider $reflectionProvider,
private FileTypeMapper $fileTypeMapper
) {
/**
* @readonly
*/
private ReflectionProvider $reflectionProvider;

/**
* @readonly
*/
private FileTypeMapper $fileTypeMapper;

public function __construct(ReflectionProvider $reflectionProvider, FileTypeMapper $fileTypeMapper)
{
$this->reflectionProvider = $reflectionProvider;
$this->fileTypeMapper = $fileTypeMapper;
}

public function getNodeType(): string
Expand Down Expand Up @@ -84,7 +94,7 @@ public function processNode(Node $node, Scope $scope): array
);

$phpDocString = $resolvedPhpDoc->getPhpDocString();
if (\str_contains($phpDocString, '@changelog')) {
if (strpos($phpDocString, '@changelog') !== false) {
return [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final public function beforeTraversal(File $file, array $statements): void
/**
* @return Statement|list<Statement>|int
*/
final public function enterNode(Statement $node): Statement|array|int
final public function enterNode(Statement $node)
{
$result = $this->refactor($node);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@

interface TypoScriptFractor extends FractorRule, TypoScriptNodeVisitor
{
public function refactor(Statement $statement): null|Statement|int;
/**
* @return null|Statement|int
*/
public function refactor(Statement $statement);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function beforeTraversal(File $file, array $statements): void;
/**
* @return Statement|list<Statement>|TypoScriptStatementsIterator::*
*/
public function enterNode(Statement $node): Statement|array|int;
public function enterNode(Statement $node);

public function leaveNode(Statement $node): void;

Expand Down
50 changes: 42 additions & 8 deletions packages/fractor-typoscript/src/TypoScriptFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,54 @@
/**
* @implements FileProcessor<TypoScriptFractor>
*/
final readonly class TypoScriptFileProcessor implements FileProcessor
final class TypoScriptFileProcessor implements FileProcessor
{
/**
* @var iterable<TypoScriptFractor>
* @readonly
*/
private iterable $rules;

/**
* @readonly
*/
private Parser $parser;

/**
* @readonly
*/
private PrettyPrinter $printer;

/**
* @readonly
*/
private PrettyPrinterConfigurationFactory $prettyPrinterConfigurationFactory;

/**
* @readonly
*/
private TypoScriptPrettyPrinterFormatConfiguration $typoScriptPrettyPrinterFormatConfiguration;

/**
* @readonly
*/
private BufferedOutput $output;

/**
* @param iterable<TypoScriptFractor> $rules
*/
public function __construct(
private iterable $rules,
private Parser $parser,
private PrettyPrinter $printer,
private PrettyPrinterConfigurationFactory $prettyPrinterConfigurationFactory,
private TypoScriptPrettyPrinterFormatConfiguration $typoScriptPrettyPrinterFormatConfiguration
iterable $rules,
Parser $parser,
PrettyPrinter $printer,
PrettyPrinterConfigurationFactory $prettyPrinterConfigurationFactory,
TypoScriptPrettyPrinterFormatConfiguration $typoScriptPrettyPrinterFormatConfiguration
) {
$this->rules = $rules;
$this->parser = $parser;
$this->printer = $printer;
$this->prettyPrinterConfigurationFactory = $prettyPrinterConfigurationFactory;
$this->typoScriptPrettyPrinterFormatConfiguration = $typoScriptPrettyPrinterFormatConfiguration;
$this->output = new BufferedOutput();
}

Expand Down Expand Up @@ -59,9 +93,9 @@ public function handle(File $file, iterable $appliedRules): void
$newTypoScriptContent = $this->output->fetch();
$typoScriptContent = rtrim($newTypoScriptContent) . "\n";
$file->changeFileContent($typoScriptContent);
} catch (TokenizerException) {
} catch (TokenizerException $exception) {
return;
} catch (ParseError) {
} catch (ParseError $exception) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Helmich\TypoScriptParser\Parser\AST\Statement;
use Webmozart\Assert\Assert;

final readonly class TypoScriptStatementsIterator
final class TypoScriptStatementsIterator
{
/**
* @var int
Expand All @@ -20,6 +20,7 @@

/**
* @var array<TypoScriptNodeVisitor>
* @readonly
*/
private iterable $visitors;

Expand Down Expand Up @@ -75,7 +76,7 @@ private function processStatementList(array $statements): array
/**
* @return self::*|Statement|list<Statement>
*/
private function traverseNode(Statement $node): int|Statement|array
private function traverseNode(Statement $node)
{
$lastCalledVisitor = null;
$result = $node;
Expand Down
Loading