Skip to content

Commit 320ce68

Browse files
committed
Support deprecated prompt config option.
Fixes #755
1 parent cef2ebf commit 320ce68

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/Configuration.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class Configuration
127127
private $presenter;
128128
private $autoCompleter;
129129
private $checker;
130+
/** @deprecated */
130131
private $prompt;
131132
private $configPaths;
132133

@@ -1628,11 +1629,19 @@ public function getStartupMessage()
16281629
/**
16291630
* Set the prompt.
16301631
*
1631-
* @param string $prompt
1632+
* @deprecated The `prompt` configuration has been replaced by Themes and support will
1633+
* eventually be removed. In the meantime, prompt is applied first by the Theme, then overridden
1634+
* by any explicitly defined prompt.
1635+
*
1636+
* Note that providing a prompt but not a theme config will implicitly use the `classic` theme.
16321637
*/
16331638
public function setPrompt(string $prompt)
16341639
{
16351640
$this->prompt = $prompt;
1641+
1642+
if (isset($this->theme)) {
1643+
$this->theme->setPrompt($prompt);
1644+
}
16361645
}
16371646

16381647
/**
@@ -1676,6 +1685,10 @@ public function setTheme($theme)
16761685

16771686
$this->theme = $theme;
16781687

1688+
if (isset($this->prompt)) {
1689+
$this->theme->setPrompt($this->prompt);
1690+
}
1691+
16791692
if (isset($this->output)) {
16801693
$this->output->setTheme($theme);
16811694
$this->applyFormatterStyles();
@@ -1688,7 +1701,12 @@ public function setTheme($theme)
16881701
public function theme(): Theme
16891702
{
16901703
if (!isset($this->theme)) {
1691-
$this->theme = new Theme();
1704+
// If a prompt is explicitly set, and a theme is not, base it on the `classic` theme.
1705+
$this->theme = $this->prompt ? new Theme('classic') : new Theme();
1706+
}
1707+
1708+
if (isset($this->prompt)) {
1709+
$this->theme->setPrompt($this->prompt);
16921710
}
16931711

16941712
return $this->theme;

src/functions.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ function info(Configuration $config = null)
226226
'output decorated' => $config->getOutputDecorated(),
227227
'output verbosity' => $config->verbosity(),
228228
'output pager' => $config->getPager(),
229+
'theme' => $themeConfig,
230+
];
231+
232+
$theme = $config->theme();
233+
// TODO: show styles (but only if they're different than default?)
234+
$output['theme'] = [
235+
'compact' => $theme->compact(),
236+
'prompt' => $theme->prompt(),
237+
'bufferPrompt' => $theme->bufferPrompt(),
238+
'replayPrompt' => $theme->replayPrompt(),
239+
'returnValue' => $theme->returnValue(),
229240
];
230241

231242
$pcntl = [

test/ShellTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ public function testRenderingExceptions()
238238
$streamContents = \stream_get_contents($stream);
239239

240240
$expected = <<<EOF
241-
242-
PARSE ERROR PHP Parse error: message in test/ShellTest.php on line 224.
243-
241+
PARSE ERROR PHP Parse error: message in test/ShellTest.php on line 224.
244242
245243
EOF;
246244

0 commit comments

Comments
 (0)