|
@@ -4,8 +4,6 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace Fgm\Drupal\Composer;
|
|
|
|
|
|
-require_once __DIR__ . '/../../../../vendor/autoload.php';
|
|
|
-
|
|
|
use Composer\Command\BaseCommand;
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
@@ -49,14 +47,14 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
|
* @param string $buildName
|
|
|
* The template name as a composer.json extra section.
|
|
|
*
|
|
|
- * @return array
|
|
|
+ * @return array{string,int}
|
|
|
* - string Template name
|
|
|
* - int Error
|
|
|
*/
|
|
|
public function validateTemplateName(
|
|
|
InputInterface $input,
|
|
|
OutputInterface $output,
|
|
|
- string $buildName
|
|
|
+ string $buildName,
|
|
|
): array {
|
|
|
$conf = $this->getComposer()->getPackage()->getExtra()[Builder::NAME] ?? [];
|
|
|
$templateName = $conf['templates'][$buildName] ?? '';
|
|
@@ -77,19 +75,19 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
|
*
|
|
|
* @param \Twig\TemplateWrapper $wrapper
|
|
|
* A Twig user-space template wrapper.
|
|
|
- * @param array $context
|
|
|
+ * @param mixed[] $context
|
|
|
* The data context with which to perform the rendering.
|
|
|
* @param string $destination
|
|
|
* The path where to write the rendering result.
|
|
|
*
|
|
|
- * @return array
|
|
|
+ * @return array{string,int}
|
|
|
* - string message
|
|
|
* - int status: 0 on success, other values on errors.
|
|
|
*/
|
|
|
protected function render(
|
|
|
TemplateWrapper $wrapper,
|
|
|
array $context,
|
|
|
- string $destination
|
|
|
+ string $destination,
|
|
|
): array {
|
|
|
if (file_exists($destination)) {
|
|
|
$ok = unlink($destination);
|
|
@@ -117,7 +115,7 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
|
* @param string $buildName
|
|
|
* Machine name of build process.
|
|
|
*
|
|
|
- * @return array
|
|
|
+ * @return array{?\Twig\TemplateWrapper,array<string,mixed>,string,int}
|
|
|
* - TemplateWrapper|NULL: Twig template wrapper
|
|
|
* - array: template parameters
|
|
|
* - string: error message
|
|
@@ -130,7 +128,7 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
|
protected function prepare(
|
|
|
InputInterface $input,
|
|
|
OutputInterface $output,
|
|
|
- string $buildName
|
|
|
+ string $buildName,
|
|
|
): array {
|
|
|
[
|
|
|
$templateName,
|
|
@@ -141,7 +139,7 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
|
};
|
|
|
|
|
|
$settingsPath = $this->getSettingsPath();
|
|
|
- $templatePath = "${settingsPath}/${templateName}";
|
|
|
+ $templatePath = "{$settingsPath}/{$templateName}";
|
|
|
$realTemplatePath = realpath($templatePath);
|
|
|
if (empty($realTemplatePath)) {
|
|
|
return [
|
|
@@ -172,7 +170,7 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
|
/**
|
|
|
* Get parameters as obtained from configuration.
|
|
|
*
|
|
|
- * @return array
|
|
|
+ * @return array{array<string,mixed>,string,int}
|
|
|
* - array: parameters
|
|
|
* - string: error message
|
|
|
* - int: error, 0 if OK. If non-zero, only the error message is reliable.
|