Skip to content

Commit

Permalink
Update Compliance.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwriter committed Dec 4, 2023
1 parent d164fd2 commit c6df30c
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/Compliance.php
Expand Up @@ -4,11 +4,19 @@

namespace Ghostwriter\Compliance;

use Composer\InstalledVersions;
use Ghostwriter\Compliance\Event\GitHubEvent;
use Ghostwriter\Compliance\ServiceProvider\ApplicationServiceProvider;
use Ghostwriter\Container\Container;
use Ghostwriter\Environment\EnvironmentVariables;
use Ghostwriter\EventDispatcher\Interface\DispatcherInterface;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\SingleCommandApplication;
use Throwable;

final class Compliance
Expand Down Expand Up @@ -59,8 +67,7 @@ final class Compliance
public static function main(
?InputInterface $input = null,
?OutputInterface $output = null,
): void
{
): void {
$container = Container::getInstance();

$container->provide(ApplicationServiceProvider::class);
Expand All @@ -74,6 +81,27 @@ public static function main(
}

$container->get(Application::class)
->run($container->get(InputInterface::class), $container->get(OutputInterface::class));
->run($container->get(InputInterface::class), $container->get(OutputInterface::class));

// wip
$environmentVariables = $container->get(EnvironmentVariables::class);
(new SingleCommandApplication(self::NAME))
->setVersion(InstalledVersions::getPrettyVersion(self::PACKAGE))

Check failure on line 89 in src/Compliance.php

View workflow job for this annotation

GitHub Actions / Psalm [ubuntu-php-8.3-composer-locked]

PossiblyNullArgument

src/Compliance.php:89:26: PossiblyNullArgument: Argument 1 of Symfony\Component\Console\SingleCommandApplication::setVersion cannot be null, possibly null value provided (see https://psalm.dev/078)
->addArgument('event', InputArgument::REQUIRED, 'The name of the event that triggered the workflow.')
->addArgument('payload', InputArgument::REQUIRED, 'The path to the file on the runner that contains the full event webhook payload.')
->setCode(
// static fn(InputInterface $input, OutputInterface $output) => $container->get(DispatcherInterface::class)
// ->dispatch(new GitHubEvent($input, $output))
// ->isPropagationStopped() ? Command::FAILURE : Command::SUCCESS
$container->get(SingleCommandApplicationDispatcher::class)
)
->run(
new ArrayInput([
'event' => $environmentVariables->get('GITHUB_EVENT_NAME', 'testing'),
'payload' => $environmentVariables->get('GITHUB_EVENT_PATH', '/github/workflow/event.json')
]),
$container->get(OutputInterface::class)
);
// end wip
}
}

0 comments on commit c6df30c

Please sign in to comment.