Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | 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 116... Zeile 116...
116
    /** @var Theme */
116
    /** @var Theme */
117
    private $theme;
117
    private $theme;
Zeile 118... Zeile 118...
118
 
118
 
119
    // services
119
    // services
-
 
120
    private $readline;
120
    private $readline;
121
    /** @var ShellOutput */
121
    private $output;
122
    private $output;
122
    private $shell;
123
    private $shell;
123
    private $cleaner;
124
    private $cleaner;
124
    private $pager;
125
    private $pager;
Zeile 174... Zeile 175...
174
     * @see self::getInputOptions
175
     * @see self::getInputOptions
175
     *
176
     *
176
     * @throws \InvalidArgumentException
177
     * @throws \InvalidArgumentException
177
     *
178
     *
178
     * @param InputInterface $input
179
     * @param InputInterface $input
179
     *
-
 
180
     * @return self
-
 
181
     */
180
     */
182
    public static function fromInput(InputInterface $input): self
181
    public static function fromInput(InputInterface $input): self
183
    {
182
    {
184
        $config = new self(['configFile' => self::getConfigFileFromInput($input)]);
183
        $config = new self(['configFile' => self::getConfigFileFromInput($input)]);
Zeile 534... Zeile 533...
534
    }
533
    }
Zeile 535... Zeile 534...
535
 
534
 
536
    /**
535
    /**
537
     * Get files to be included by default at the start of each shell session.
536
     * Get files to be included by default at the start of each shell session.
538
     *
537
     *
539
     * @return array
538
     * @return string[]
540
     */
539
     */
541
    public function getDefaultIncludes(): array
540
    public function getDefaultIncludes(): array
542
    {
541
    {
543
        return $this->defaultIncludes ?: [];
542
        return $this->defaultIncludes ?: [];
Zeile 616... Zeile 615...
616
     *
615
     *
617
     * Defaults to  `/psysh` inside the system's temp dir unless explicitly
616
     * Defaults to  `/psysh` inside the system's temp dir unless explicitly
618
     * overridden.
617
     * overridden.
619
     *
618
     *
620
     * @throws RuntimeException if no temporary directory is set and it is not possible to create one
619
     * @throws RuntimeException if no temporary directory is set and it is not possible to create one
621
     *
-
 
622
     * @return string
-
 
623
     */
620
     */
624
    public function getRuntimeDir(): string
621
    public function getRuntimeDir(): string
625
    {
622
    {
626
        $runtimeDir = $this->configPaths->runtimeDir();
623
        $runtimeDir = $this->configPaths->runtimeDir();
Zeile 647... Zeile 644...
647
    /**
644
    /**
648
     * Get the readline history file path.
645
     * Get the readline history file path.
649
     *
646
     *
650
     * Defaults to `/history` inside the shell's base config dir unless
647
     * Defaults to `/history` inside the shell's base config dir unless
651
     * explicitly overridden.
648
     * explicitly overridden.
652
     *
-
 
653
     * @return string
-
 
654
     */
649
     */
655
    public function getHistoryFile(): string
650
    public function getHistoryFile(): string
656
    {
651
    {
657
        if (isset($this->historyFile)) {
652
        if (isset($this->historyFile)) {
658
            return $this->historyFile;
653
            return $this->historyFile;
Zeile 817... Zeile 812...
817
 
812
 
818
    /**
813
    /**
819
     * Get the appropriate Readline implementation class name.
814
     * Get the appropriate Readline implementation class name.
820
     *
815
     *
821
     * @see self::getReadline
-
 
822
     *
-
 
823
     * @return string
816
     * @see self::getReadline
824
     */
817
     */
825
    private function getReadlineClass(): string
818
    private function getReadlineClass(): string
826
    {
819
    {
827
        if ($this->useReadline()) {
820
        if ($this->useReadline()) {
Zeile 958... Zeile 951...
958
     * Check whether to require semicolons on all statements.
951
     * Check whether to require semicolons on all statements.
959
     *
952
     *
960
     * By default, PsySH will automatically insert semicolons at the end of
953
     * By default, PsySH will automatically insert semicolons at the end of
961
     * statements if they're missing. To strictly require semicolons, set
954
     * statements if they're missing. To strictly require semicolons, set
962
     * `requireSemicolons` to true.
955
     * `requireSemicolons` to true.
963
     *
-
 
964
     * @return bool
-
 
965
     */
956
     */
966
    public function requireSemicolons(): bool
957
    public function requireSemicolons(): bool
967
    {
958
    {
968
        return $this->requireSemicolons;
959
        return $this->requireSemicolons;
969
    }
960
    }
Zeile 984... Zeile 975...
984
    /**
975
    /**
985
     * Check whether to use Unicode in PsySH specific output.
976
     * Check whether to use Unicode in PsySH specific output.
986
     *
977
     *
987
     * Note that this does not disable Unicode output in general, it just makes
978
     * Note that this does not disable Unicode output in general, it just makes
988
     * it so PsySH won't output any itself.
979
     * it so PsySH won't output any itself.
989
     *
-
 
990
     * @return bool
-
 
991
     */
980
     */
992
    public function useUnicode(): bool
981
    public function useUnicode(): bool
993
    {
982
    {
994
        if (isset($this->useUnicode)) {
983
        if (isset($this->useUnicode)) {
995
            return $this->useUnicode;
984
            return $this->useUnicode;
Zeile 1020... Zeile 1009...
1020
     * Set `errorLoggingLevel` to 0 to prevent logging non-thrown errors. Set it
1009
     * Set `errorLoggingLevel` to 0 to prevent logging non-thrown errors. Set it
1021
     * to any valid error_reporting value to log only errors which match that
1010
     * to any valid error_reporting value to log only errors which match that
1022
     * level.
1011
     * level.
1023
     *
1012
     *
1024
     *     http://php.net/manual/en/function.error-reporting.php
1013
     *     http://php.net/manual/en/function.error-reporting.php
1025
     *
-
 
1026
     * @return int
-
 
1027
     */
1014
     */
1028
    public function errorLoggingLevel(): int
1015
    public function errorLoggingLevel(): int
1029
    {
1016
    {
1030
        return $this->errorLoggingLevel;
1017
        return $this->errorLoggingLevel;
1031
    }
1018
    }
Zeile 1042... Zeile 1029...
1042
 
1029
 
1043
    /**
1030
    /**
1044
     * Get a CodeCleaner service instance.
1031
     * Get a CodeCleaner service instance.
1045
     *
1032
     *
1046
     * If none has been explicitly defined, this will create a new instance.
-
 
1047
     *
-
 
1048
     * @return CodeCleaner
1033
     * If none has been explicitly defined, this will create a new instance.
1049
     */
1034
     */
1050
    public function getCodeCleaner(): CodeCleaner
1035
    public function getCodeCleaner(): CodeCleaner
1051
    {
1036
    {
1052
        if (!isset($this->cleaner)) {
1037
        if (!isset($this->cleaner)) {
Zeile 1107... Zeile 1092...
1107
        return isset($this->useTabCompletion) ? ($this->hasReadline && $this->useTabCompletion) : $this->hasReadline;
1092
        return isset($this->useTabCompletion) ? ($this->hasReadline && $this->useTabCompletion) : $this->hasReadline;
1108
    }
1093
    }
Zeile 1109... Zeile 1094...
1109
 
1094
 
1110
    /**
1095
    /**
1111
     * @deprecated Call `useTabCompletion` instead
-
 
1112
     *
-
 
1113
     * @return bool
1096
     * @deprecated Call `useTabCompletion` instead
1114
     */
1097
     */
1115
    public function getTabCompletion(): bool
1098
    public function getTabCompletion(): bool
1116
    {
1099
    {
1117
        return $this->useTabCompletion();
1100
        return $this->useTabCompletion();
Zeile 1140... Zeile 1123...
1140
     * If none has been explicitly provided, this will create a new instance
1123
     * If none has been explicitly provided, this will create a new instance
1141
     * with the configured verbosity and output pager supplied by self::getPager
1124
     * with the configured verbosity and output pager supplied by self::getPager
1142
     *
1125
     *
1143
     * @see self::verbosity
1126
     * @see self::verbosity
1144
     * @see self::getPager
1127
     * @see self::getPager
1145
     *
-
 
1146
     * @return ShellOutput
-
 
1147
     */
1128
     */
1148
    public function getOutput(): ShellOutput
1129
    public function getOutput(): ShellOutput
1149
    {
1130
    {
1150
        if (!isset($this->output)) {
1131
        if (!isset($this->output)) {
1151
            $this->setOutput(new ShellOutput(
1132
            $this->setOutput(new ShellOutput(
Zeile 1186... Zeile 1167...
1186
        }
1167
        }
1187
    }
1168
    }
Zeile 1188... Zeile 1169...
1188
 
1169
 
1189
    /**
1170
    /**
1190
     * Get the interactive setting for shell input.
-
 
1191
     *
-
 
1192
     * @return bool
1171
     * Get the interactive setting for shell input.
1193
     */
1172
     */
1194
    public function getInputInteractive(): bool
1173
    public function getInputInteractive(): bool
1195
    {
1174
    {
1196
        switch ($this->interactiveMode()) {
1175
        switch ($this->interactiveMode()) {
Zeile 1266... Zeile 1245...
1266
        $this->autoCompleter = $autoCompleter;
1245
        $this->autoCompleter = $autoCompleter;
1267
    }
1246
    }
Zeile 1268... Zeile 1247...
1268
 
1247
 
1269
    /**
1248
    /**
1270
     * Get an AutoCompleter service instance.
-
 
1271
     *
-
 
1272
     * @return AutoCompleter
1249
     * Get an AutoCompleter service instance.
1273
     */
1250
     */
1274
    public function getAutoCompleter(): AutoCompleter
1251
    public function getAutoCompleter(): AutoCompleter
1275
    {
1252
    {
1276
        if (!isset($this->autoCompleter)) {
1253
        if (!isset($this->autoCompleter)) {
Zeile 1280... Zeile 1257...
1280
        return $this->autoCompleter;
1257
        return $this->autoCompleter;
1281
    }
1258
    }
Zeile 1282... Zeile 1259...
1282
 
1259
 
1283
    /**
1260
    /**
1284
     * @deprecated Nothing should be using this anymore
-
 
1285
     *
-
 
1286
     * @return array
1261
     * @deprecated Nothing should be using this anymore
1287
     */
1262
     */
1288
    public function getTabCompletionMatchers(): array
1263
    public function getTabCompletionMatchers(): array
1289
    {
1264
    {
1290
        return [];
1265
        return [];
Zeile 1442... Zeile 1417...
1442
        $this->getPresenter()->addCasters($casters);
1417
        $this->getPresenter()->addCasters($casters);
1443
    }
1418
    }
Zeile 1444... Zeile 1419...
1444
 
1419
 
1445
    /**
1420
    /**
1446
     * Get the Presenter service.
-
 
1447
     *
-
 
1448
     * @return Presenter
1421
     * Get the Presenter service.
1449
     */
1422
     */
1450
    public function getPresenter(): Presenter
1423
    public function getPresenter(): Presenter
1451
    {
1424
    {
1452
        if (!isset($this->presenter)) {
1425
        if (!isset($this->presenter)) {
Zeile 1475... Zeile 1448...
1475
     * silently ignore all others. With this enabled, a warning will be emitted
1448
     * silently ignore all others. With this enabled, a warning will be emitted
1476
     * (but not an exception thrown) if multiple configuration or data files
1449
     * (but not an exception thrown) if multiple configuration or data files
1477
     * are found.
1450
     * are found.
1478
     *
1451
     *
1479
     * This will default to true in a future release, but is false for now.
1452
     * This will default to true in a future release, but is false for now.
1480
     *
-
 
1481
     * @return bool
-
 
1482
     */
1453
     */
1483
    public function warnOnMultipleConfigs(): bool
1454
    public function warnOnMultipleConfigs(): bool
1484
    {
1455
    {
1485
        return $this->warnOnMultipleConfigs;
1456
        return $this->warnOnMultipleConfigs;
1486
    }
1457
    }
Zeile 1487... Zeile 1458...
1487
 
1458
 
1488
    /**
1459
    /**
1489
     * Set the current color mode.
1460
     * Set the current color mode.
-
 
1461
     *
-
 
1462
     * @throws \InvalidArgumentException if the color mode isn't auto, forced or disabled
1490
     *
1463
     *
1491
     * @param string $colorMode
1464
     * @param string $colorMode
1492
     */
1465
     */
1493
    public function setColorMode(string $colorMode)
1466
    public function setColorMode(string $colorMode)
1494
    {
1467
    {
Zeile 1505... Zeile 1478...
1505
        $this->colorMode = $colorMode;
1478
        $this->colorMode = $colorMode;
1506
    }
1479
    }
Zeile 1507... Zeile 1480...
1507
 
1480
 
1508
    /**
1481
    /**
1509
     * Get the current color mode.
-
 
1510
     *
-
 
1511
     * @return string
1482
     * Get the current color mode.
1512
     */
1483
     */
1513
    public function colorMode(): string
1484
    public function colorMode(): string
1514
    {
1485
    {
1515
        return $this->colorMode;
1486
        return $this->colorMode;
Zeile 1537... Zeile 1508...
1537
        $this->interactiveMode = $interactiveMode;
1508
        $this->interactiveMode = $interactiveMode;
1538
    }
1509
    }
Zeile 1539... Zeile 1510...
1539
 
1510
 
1540
    /**
1511
    /**
1541
     * Get the current interactive mode.
-
 
1542
     *
-
 
1543
     * @return string
1512
     * Get the current interactive mode.
1544
     */
1513
     */
1545
    public function interactiveMode(): string
1514
    public function interactiveMode(): string
1546
    {
1515
    {
1547
        return $this->interactiveMode;
1516
        return $this->interactiveMode;
Zeile 1559... Zeile 1528...
1559
 
1528
 
1560
    /**
1529
    /**
1561
     * Get an update checker service instance.
1530
     * Get an update checker service instance.
1562
     *
1531
     *
1563
     * If none has been explicitly defined, this will create a new instance.
-
 
1564
     *
-
 
1565
     * @return Checker
1532
     * If none has been explicitly defined, this will create a new instance.
1566
     */
1533
     */
1567
    public function getChecker(): Checker
1534
    public function getChecker(): Checker
1568
    {
1535
    {
1569
        if (!isset($this->checker)) {
1536
        if (!isset($this->checker)) {
Zeile 1596... Zeile 1563...
1596
    /**
1563
    /**
1597
     * Get the current update check interval.
1564
     * Get the current update check interval.
1598
     *
1565
     *
1599
     * One of 'always', 'daily', 'weekly', 'monthly' or 'never'. If none is
1566
     * One of 'always', 'daily', 'weekly', 'monthly' or 'never'. If none is
1600
     * explicitly set, default to 'weekly'.
1567
     * explicitly set, default to 'weekly'.
1601
     *
-
 
1602
     * @return string
-
 
1603
     */
1568
     */
1604
    public function getUpdateCheck(): string
1569
    public function getUpdateCheck(): string
1605
    {
1570
    {
1606
        return isset($this->updateCheck) ? $this->updateCheck : Checker::WEEKLY;
1571
        return isset($this->updateCheck) ? $this->updateCheck : Checker::WEEKLY;
1607
    }
1572
    }
Zeile 1680... Zeile 1645...
1680
        return $this->prompt;
1645
        return $this->prompt;
1681
    }
1646
    }
Zeile 1682... Zeile 1647...
1682
 
1647
 
1683
    /**
1648
    /**
1684
     * Get the force array indexes.
-
 
1685
     *
-
 
1686
     * @return bool
1649
     * Get the force array indexes.
1687
     */
1650
     */
1688
    public function forceArrayIndexes(): bool
1651
    public function forceArrayIndexes(): bool
1689
    {
1652
    {
1690
        return $this->forceArrayIndexes;
1653
        return $this->forceArrayIndexes;
Zeile 1783... Zeile 1746...
1783
        }
1746
        }
1784
    }
1747
    }
Zeile 1785... Zeile 1748...
1785
 
1748
 
1786
    /**
1749
    /**
1787
     * Get the configured output verbosity.
-
 
1788
     *
-
 
1789
     * @return string
1750
     * Get the configured output verbosity.
1790
     */
1751
     */
1791
    public function verbosity(): string
1752
    public function verbosity(): string
1792
    {
1753
    {
1793
        return $this->verbosity;
1754
        return $this->verbosity;
Zeile 1847... Zeile 1808...
1847
 
1808
 
1848
    /**
1809
    /**
1849
     * Guess whether stdin is piped.
1810
     * Guess whether stdin is piped.
1850
     *
1811
     *
1851
     * This is mostly useful for deciding whether to use non-interactive mode.
-
 
1852
     *
-
 
1853
     * @return bool
1812
     * This is mostly useful for deciding whether to use non-interactive mode.
1854
     */
1813
     */
1855
    public function inputIsPiped(): bool
1814
    public function inputIsPiped(): bool
1856
    {
1815
    {
1857
        if ($this->pipedInput === null) {
1816
        if ($this->pipedInput === null) {
1858
            $this->pipedInput = \defined('STDIN') && static::looksLikeAPipe(\STDIN);
1817
            $this->pipedInput = \defined('STDIN') && self::looksLikeAPipe(\STDIN);
Zeile 1859... Zeile 1818...
1859
        }
1818
        }
1860
 
1819
 
Zeile 1861... Zeile 1820...
1861
        return $this->pipedInput;
1820
        return $this->pipedInput;
1862
    }
1821
    }
1863
 
1822
 
1864
    /**
1823
    /**
1865
     * Guess whether shell output is piped.
-
 
1866
     *
-
 
1867
     * This is mostly useful for deciding whether to use non-decorated output.
1824
     * Guess whether shell output is piped.
1868
     *
1825
     *
1869
     * @return bool
1826
     * This is mostly useful for deciding whether to use non-decorated output.
1870
     */
1827
     */
1871
    public function outputIsPiped(): bool
1828
    public function outputIsPiped(): bool
1872
    {
1829
    {
Zeile 1873... Zeile 1830...
1873
        if ($this->pipedOutput === null) {
1830
        if ($this->pipedOutput === null) {
1874
            $this->pipedOutput = static::looksLikeAPipe($this->getOutput()->getStream());
1831
            $this->pipedOutput = self::looksLikeAPipe($this->getOutput()->getStream());
Zeile 1875... Zeile 1832...
1875
        }
1832
        }
1876
 
1833
 
1877
        return $this->pipedOutput;
1834
        return $this->pipedOutput;
1878
    }
1835
    }
1879
 
-
 
1880
    /**
-
 
1881
     * Guess whether an input or output stream is piped.
1836
 
1882
     *
1837
    /**
1883
     * @param resource|int $stream
1838
     * Guess whether an input or output stream is piped.
1884
     *
1839
     *
1885
     * @return bool
1840
     * @param resource|int $stream