1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of the humbug/php-scoper package. |
||
7 | * |
||
8 | * Copyright (c) 2017 Théo FIDRY <[email protected]>, |
||
9 | * Pádraic Brady <[email protected]> |
||
10 | * |
||
11 | * For the full copyright and license information, please view the LICENSE |
||
12 | * file that was distributed with this source code. |
||
13 | */ |
||
14 | |||
15 | namespace Humbug\PhpScoper\Console; |
||
16 | |||
17 | use Fidry\Console\Application\Application as FidryApplication; |
||
18 | use Humbug\PhpScoper\Console\Command\AddPrefixCommand; |
||
19 | use Humbug\PhpScoper\Console\Command\InitCommand; |
||
20 | use Humbug\PhpScoper\Console\Command\InspectSymbolCommand; |
||
21 | use Humbug\PhpScoper\Container; |
||
22 | use Symfony\Component\Console\Helper\FormatterHelper; |
||
23 | use function Humbug\PhpScoper\get_php_scoper_version; |
||
24 | use function Safe\sprintf; |
||
25 | use function strpos; |
||
26 | use function trim; |
||
27 | |||
28 | /** |
||
29 | * @private |
||
30 | * @codeCoverageIgnore |
||
31 | */ |
||
32 | final class Application implements FidryApplication |
||
33 | { |
||
34 | private const LOGO = <<<'ASCII' |
||
35 | |||
36 | ____ __ ______ _____ |
||
37 | / __ \/ / / / __ \ / ___/_________ ____ ___ _____ |
||
38 | / /_/ / /_/ / /_/ / \__ \/ ___/ __ \/ __ \/ _ \/ ___/ |
||
39 | / ____/ __ / ____/ ___/ / /__/ /_/ / /_/ / __/ / |
||
40 | /_/ /_/ /_/_/ /____/\___/\____/ .___/\___/_/ |
||
41 | /_/ |
||
42 | |||
43 | |||
44 | ASCII; |
||
45 | |||
46 | private const RELEASE_DATE_PLACEHOLDER = '@release-date@'; |
||
47 | |||
48 | private Container $container; |
||
49 | private string $version; |
||
50 | private string $releaseDate; |
||
51 | private bool $isAutoExitEnabled; |
||
52 | private bool $areExceptionsCaught; |
||
53 | |||
54 | public static function create(): self |
||
55 | { |
||
56 | return new self( |
||
57 | new Container(), |
||
58 | get_php_scoper_version(), |
||
59 | false === strpos(self::RELEASE_DATE_PLACEHOLDER, '@') |
||
60 | ? self::RELEASE_DATE_PLACEHOLDER |
||
61 | : '', |
||
62 | true, |
||
63 | true, |
||
64 | ); |
||
65 | } |
||
66 | |||
67 | public function __construct( |
||
68 | Container $container, |
||
69 | string $version, |
||
70 | string $releaseDate, |
||
71 | bool $isAutoExitEnabled, |
||
72 | bool $areExceptionsCaught |
||
73 | ) { |
||
74 | $this->container = $container; |
||
75 | $this->version = $version; |
||
76 | $this->releaseDate = $releaseDate; |
||
77 | $this->isAutoExitEnabled = $isAutoExitEnabled; |
||
78 | $this->areExceptionsCaught = $areExceptionsCaught; |
||
79 | } |
||
80 | |||
81 | public function getName(): string |
||
82 | { |
||
83 | return 'PhpScoper'; |
||
84 | } |
||
85 | |||
86 | public function getVersion(): string |
||
87 | { |
||
88 | return $this->version; |
||
89 | } |
||
90 | |||
91 | public function getLongVersion(): string |
||
92 | { |
||
93 | return trim( |
||
94 | sprintf( |
||
0 ignored issues
–
show
|
|||
95 | '<info>%s</info> version <comment>%s</comment> %s', |
||
96 | $this->getName(), |
||
97 | $this->getVersion(), |
||
98 | $this->releaseDate, |
||
99 | ), |
||
100 | ); |
||
101 | } |
||
102 | |||
103 | public function getHelp(): string |
||
104 | { |
||
105 | return self::LOGO.$this->getLongVersion(); |
||
106 | } |
||
107 | |||
108 | public function getCommands(): array |
||
109 | { |
||
110 | return [ |
||
111 | new AddPrefixCommand( |
||
112 | $this->container->getFileSystem(), |
||
113 | $this->container->getScoperFactory(), |
||
114 | $this, |
||
115 | $this->container->getConfigurationFactory(), |
||
116 | ), |
||
117 | new InspectSymbolCommand( |
||
118 | $this->container->getFileSystem(), |
||
119 | $this->container->getConfigurationFactory(), |
||
120 | $this->container->getEnrichedReflectorFactory(), |
||
121 | ), |
||
122 | new InitCommand( |
||
123 | $this->container->getFileSystem(), |
||
124 | new FormatterHelper(), |
||
125 | ), |
||
126 | ]; |
||
127 | } |
||
128 | |||
129 | public function getDefaultCommand(): string |
||
130 | { |
||
131 | return 'list'; |
||
132 | } |
||
133 | |||
134 | public function isAutoExitEnabled(): bool |
||
135 | { |
||
136 | return $this->isAutoExitEnabled; |
||
137 | } |
||
138 | |||
139 | public function areExceptionsCaught(): bool |
||
140 | { |
||
141 | return $this->areExceptionsCaught; |
||
142 | } |
||
143 | } |
||
144 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.