Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Revision 399 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 200
Zeile 1... Zeile 1...
1
<?php
1
<?php
Zeile 2... Zeile 2...
2
 
2
 
3
/*
3
/*
4
 * This file is part of Psy Shell.
4
 * This file is part of Psy Shell.
5
 *
5
 *
6
 * (c) 2012-2022 Justin Hileman
6
 * (c) 2012-2023 Justin Hileman
7
 *
7
 *
8
 * For the full copyright and license information, please view the LICENSE
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
9
 * file that was distributed with this source code.
Zeile 47... Zeile 47...
47
 *
47
 *
48
 * @author Justin Hileman <justin@justinhileman.info>
48
 * @author Justin Hileman <justin@justinhileman.info>
49
 */
49
 */
50
class Shell extends Application
50
class Shell extends Application
51
{
51
{
52
    const VERSION = 'v0.11.10';
52
    const VERSION = 'v0.11.11';
Zeile 53... Zeile 53...
53
 
53
 
54
    /** @deprecated */
54
    /** @deprecated */
55
    const PROMPT = '>>> ';
55
    const PROMPT = '>>> ';
56
    /** @deprecated */
56
    /** @deprecated */
Zeile 227... Zeile 227...
227
            new Command\ExitCommand(),
227
            new Command\ExitCommand(),
228
        ];
228
        ];
229
    }
229
    }
Zeile 230... Zeile 230...
230
 
230
 
231
    /**
231
    /**
232
     * @return array
232
     * @return Matcher\AbstractMatcher[]
233
     */
233
     */
234
    protected function getDefaultMatchers(): array
234
    protected function getDefaultMatchers(): array
235
    {
235
    {
236
        // Store the Commands Matcher for later. If more commands are added,
236
        // Store the Commands Matcher for later. If more commands are added,
Zeile 592... Zeile 592...
592
 
592
 
593
    /**
593
    /**
594
     * Run execution loop listeners on user input.
594
     * Run execution loop listeners on user input.
595
     *
595
     *
596
     * @param string $input
-
 
597
     *
-
 
598
     * @return string
596
     * @param string $input
599
     */
597
     */
600
    public function onInput(string $input): string
598
    public function onInput(string $input): string
601
    {
599
    {
602
        foreach ($this->loopListeners as $listeners) {
600
        foreach ($this->loopListeners as $listeners) {
Zeile 610... Zeile 608...
610
 
608
 
611
    /**
609
    /**
612
     * Run execution loop listeners on code to be executed.
610
     * Run execution loop listeners on code to be executed.
613
     *
611
     *
614
     * @param string $code
-
 
615
     *
-
 
616
     * @return string
612
     * @param string $code
617
     */
613
     */
618
    public function onExecute(string $code): string
614
    public function onExecute(string $code): string
619
    {
615
    {
Zeile 812... Zeile 808...
812
    }
808
    }
Zeile 813... Zeile 809...
813
 
809
 
814
    /**
810
    /**
815
     * Get PHP files to be parsed and executed before running the interactive shell.
811
     * Get PHP files to be parsed and executed before running the interactive shell.
816
     *
812
     *
817
     * @return array
813
     * @return string[]
818
     */
814
     */
819
    public function getIncludes(): array
815
    public function getIncludes(): array
820
    {
816
    {
821
        return \array_merge($this->config->getDefaultIncludes(), $this->includes);
817
        return \array_merge($this->config->getDefaultIncludes(), $this->includes);
Zeile 907... Zeile 903...
907
    /**
903
    /**
908
     * Get the current code buffer.
904
     * Get the current code buffer.
909
     *
905
     *
910
     * This is useful for commands which manipulate the buffer.
906
     * This is useful for commands which manipulate the buffer.
911
     *
907
     *
912
     * @return array
908
     * @return string[]
913
     */
909
     */
914
    public function getCodeBuffer(): array
910
    public function getCodeBuffer(): array
915
    {
911
    {
916
        return $this->codeBuffer;
912
        return $this->codeBuffer;
917
    }
913
    }
Zeile 1205... Zeile 1201...
1205
 
1201
 
1206
    /**
1202
    /**
1207
     * Check whether the last exec was successful.
1203
     * Check whether the last exec was successful.
1208
     *
1204
     *
1209
     * Returns true if a return value was logged rather than an exception.
-
 
1210
     *
-
 
1211
     * @return bool
1205
     * Returns true if a return value was logged rather than an exception.
1212
     */
1206
     */
1213
    public function getLastExecSuccess(): bool
1207
    public function getLastExecSuccess(): bool
1214
    {
1208
    {
1215
        return $this->lastExecSuccess;
1209
        return $this->lastExecSuccess;
Zeile 1219... Zeile 1213...
1219
     * Helper for formatting an exception or error for writeException().
1213
     * Helper for formatting an exception or error for writeException().
1220
     *
1214
     *
1221
     * @todo extract this to somewhere it makes more sense
1215
     * @todo extract this to somewhere it makes more sense
1222
     *
1216
     *
1223
     * @param \Throwable $e
1217
     * @param \Throwable $e
1224
     *
-
 
1225
     * @return string
-
 
1226
     */
1218
     */
1227
    public function formatException(\Throwable $e): string
1219
    public function formatException(\Throwable $e): string
1228
    {
1220
    {
1229
        $indent = $this->config->theme()->compact() ? '' : '  ';
1221
        $indent = $this->config->theme()->compact() ? '' : '  ';
Zeile 1265... Zeile 1257...
1265
 
1257
 
1266
    /**
1258
    /**
1267
     * Helper for getting an output style for the given ErrorException's level.
1259
     * Helper for getting an output style for the given ErrorException's level.
1268
     *
1260
     *
1269
     * @param \ErrorException $e
-
 
1270
     *
-
 
1271
     * @return string
1261
     * @param \ErrorException $e
1272
     */
1262
     */
1273
    protected function getSeverity(\ErrorException $e): string
1263
    protected function getSeverity(\ErrorException $e): string
1274
    {
1264
    {
1275
        $severity = $e->getSeverity();
1265
        $severity = $e->getSeverity();
Zeile 1297... Zeile 1287...
1297
 
1287
 
1298
    /**
1288
    /**
1299
     * Helper for getting an output style for the given ErrorException's level.
1289
     * Helper for getting an output style for the given ErrorException's level.
1300
     *
1290
     *
1301
     * @param \Throwable $e
-
 
1302
     *
-
 
1303
     * @return string
1291
     * @param \Throwable $e
1304
     */
1292
     */
1305
    protected function getMessageLabel(\Throwable $e): string
1293
    protected function getMessageLabel(\Throwable $e): string
1306
    {
1294
    {
1307
        if ($e instanceof \ErrorException) {
1295
        if ($e instanceof \ErrorException) {
Zeile 1517... Zeile 1505...
1517
        return $line;
1505
        return $line;
1518
    }
1506
    }
Zeile 1519... Zeile 1507...
1519
 
1507
 
1520
    /**
1508
    /**
1521
     * Get the shell output header.
-
 
1522
     *
-
 
1523
     * @return string
1509
     * Get the shell output header.
1524
     */
1510
     */
1525
    protected function getHeader(): string
1511
    protected function getHeader(): string
1526
    {
1512
    {
1527
        return \sprintf('<whisper>%s by Justin Hileman</whisper>', $this->getVersion());
1513
        return \sprintf('<whisper>%s by Justin Hileman</whisper>', $this->getVersion());
Zeile 1528... Zeile 1514...
1528
    }
1514
    }
1529
 
1515
 
1530
    /**
1516
    /**
1531
     * Get the current version of Psy Shell.
1517
     * Get the current version of Psy Shell.
1532
     *
-
 
1533
     * @deprecated call self::getVersionHeader instead
-
 
1534
     *
1518
     *
1535
     * @return string
1519
     * @deprecated call self::getVersionHeader instead
1536
     */
1520
     */
1537
    public function getVersion(): string
1521
    public function getVersion(): string
1538
    {
1522
    {
Zeile 1539... Zeile 1523...
1539
        return self::getVersionHeader($this->config->useUnicode());
1523
        return self::getVersionHeader($this->config->useUnicode());
1540
    }
1524
    }
1541
 
1525
 
1542
    /**
1526
    /**
1543
     * Get a pretty header including the current version of Psy Shell.
-
 
1544
     *
-
 
1545
     * @param bool $useUnicode
1527
     * Get a pretty header including the current version of Psy Shell.
1546
     *
1528
     *
1547
     * @return string
1529
     * @param bool $useUnicode
1548
     */
1530
     */