Skip to content
Snippets Groups Projects
Forked from Stud.IP / Stud.IP
1316 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Tinker.php 1.17 KiB
<?php

namespace Studip\Cli\Commands\Base;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use Psy\Configuration;
use Psy\Shell;
use Psy\VersionUpdater\Checker;

class Tinker extends Command
{
    protected static $defaultName = 'tinker';

    protected function configure(): void
    {
        $this->setDescription('Interact with your Stud.IP in a read-eval-print loop (REPL).');
    }

    /**
     * @SuppressWarnings(PHPMD.StaticAccess)
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $config = Configuration::fromInput($input);
        $config->setUpdateCheck(Checker::NEVER);
        $config->setDefaultIncludes([__DIR__ . '/../../studip_cli_env.inc.php']);

        $shell = new Shell($config);

        return $shell->run();
    }
}