Skip to content

Commit

Permalink
add return statements to functionsList.php
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Feb 9, 2025
1 parent bd3f11f commit 47a1689
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions generated/functionsList.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generator/src/Commands/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$fileCreator->generateVersionSplitters($moduleName, FileCreator::getSafeRootDir() . "/generated/", \array_keys($versions));
$fileCreator->createExceptionFile((string) $moduleName);
}
$fileCreator->generateVersionSplitters("functionsList", FileCreator::getSafeRootDir() . "/generated/", \array_keys($versions));
$fileCreator->generateVersionSplitters("functionsList", FileCreator::getSafeRootDir() . "/generated/", \array_keys($versions), true);

$this->runCsFix($output);

Expand Down
5 changes: 3 additions & 2 deletions generator/src/Generator/FileCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,19 @@ public function generatePhpFile(array $functions, array $missingFunctions, strin
/**
* @param string[] $versions
*/
public function generateVersionSplitters(string $module, string $path, array $versions): void
public function generateVersionSplitters(string $module, string $path, array $versions, bool $return = false): void
{
$lcModule = \lcfirst($module);
$stream = \fopen($path.$lcModule.'.php', 'w');
if ($stream === false) {
throw new \RuntimeException('Unable to write to '.$path);
}
$return = $return ? "return " : "";
\fwrite($stream, "<?php\n");
foreach ($versions as $version) {
if (file_exists("$path/$version/$lcModule.php")) {
\fwrite($stream, "\nif (str_starts_with(PHP_VERSION, \"$version.\")) {");
\fwrite($stream, "\n require_once __DIR__ . '/$version/$lcModule.php';");
\fwrite($stream, "\n {$return}require_once __DIR__ . '/$version/$lcModule.php';");
\fwrite($stream, "\n}");
}
}
Expand Down

0 comments on commit 47a1689

Please sign in to comment.