blob: b8161e86a2e3ac2f7730fca0491333ce5b2cec96 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
namespace Studip\Cli\Commands\Base;
use Illuminate\Support\Collection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Psy\Configuration;
use Psy\Shell;
use Psy\VersionUpdater\Checker;
use SimpleCollection;
use SimpleORMap;
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']);
$config->addCasters([
Collection::class => TinkerCaster::class . '::castCollection',
SimpleCollection::class => TinkerCaster::class . '::castSimpleCollection',
SimpleORMap::class => TinkerCaster::class . '::castModel',
]);
$shell = new Shell($config);
return $shell->run();
}
}
|