Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | 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 16... Zeile 16...
16
use PhpParser\PrettyPrinter\Standard as Printer;
16
use PhpParser\PrettyPrinter\Standard as Printer;
17
use Psy\CodeCleaner\AbstractClassPass;
17
use Psy\CodeCleaner\AbstractClassPass;
18
use Psy\CodeCleaner\AssignThisVariablePass;
18
use Psy\CodeCleaner\AssignThisVariablePass;
19
use Psy\CodeCleaner\CalledClassPass;
19
use Psy\CodeCleaner\CalledClassPass;
20
use Psy\CodeCleaner\CallTimePassByReferencePass;
20
use Psy\CodeCleaner\CallTimePassByReferencePass;
-
 
21
use Psy\CodeCleaner\CodeCleanerPass;
21
use Psy\CodeCleaner\EmptyArrayDimFetchPass;
22
use Psy\CodeCleaner\EmptyArrayDimFetchPass;
22
use Psy\CodeCleaner\ExitPass;
23
use Psy\CodeCleaner\ExitPass;
23
use Psy\CodeCleaner\FinalClassPass;
24
use Psy\CodeCleaner\FinalClassPass;
24
use Psy\CodeCleaner\FunctionContextPass;
25
use Psy\CodeCleaner\FunctionContextPass;
25
use Psy\CodeCleaner\FunctionReturnInWriteContextPass;
26
use Psy\CodeCleaner\FunctionReturnInWriteContextPass;
Zeile 80... Zeile 81...
80
        }
81
        }
81
    }
82
    }
Zeile 82... Zeile 83...
82
 
83
 
83
    /**
84
    /**
84
     * Check whether this CodeCleaner is in YOLO mode.
-
 
85
     *
-
 
86
     * @return bool
85
     * Check whether this CodeCleaner is in YOLO mode.
87
     */
86
     */
88
    public function yolo(): bool
87
    public function yolo(): bool
89
    {
88
    {
90
        return $this->yolo;
89
        return $this->yolo;
Zeile 91... Zeile 90...
91
    }
90
    }
92
 
91
 
93
    /**
92
    /**
94
     * Get default CodeCleaner passes.
93
     * Get default CodeCleaner passes.
95
     *
94
     *
96
     * @return array
95
     * @return CodeCleanerPass[]
97
     */
96
     */
98
    private function getDefaultPasses(): array
97
    private function getDefaultPasses(): array
99
    {
98
    {
Zeile 148... Zeile 147...
148
     * only do minimal rewriting to make things work inside the REPL.
147
     * only do minimal rewriting to make things work inside the REPL.
149
     *
148
     *
150
     * This list should stay in sync with the "rewriting shenanigans" in
149
     * This list should stay in sync with the "rewriting shenanigans" in
151
     * getDefaultPasses above.
150
     * getDefaultPasses above.
152
     *
151
     *
153
     * @return array
152
     * @return CodeCleanerPass[]
154
     */
153
     */
155
    private function getYoloPasses(): array
154
    private function getYoloPasses(): array
156
    {
155
    {
157
        $useStatementPass = new UseStatementPass();
156
        $useStatementPass = new UseStatementPass();
158
        $namespacePass = new NamespacePass($this);
157
        $namespacePass = new NamespacePass($this);
Zeile 238... Zeile 237...
238
 
237
 
239
    /**
238
    /**
240
     * Check whether a given backtrace frame is a call to Psy\debug.
239
     * Check whether a given backtrace frame is a call to Psy\debug.
241
     *
240
     *
242
     * @param array $stackFrame
-
 
243
     *
-
 
244
     * @return bool
241
     * @param array $stackFrame
245
     */
242
     */
246
    private static function isDebugCall(array $stackFrame): bool
243
    private static function isDebugCall(array $stackFrame): bool
247
    {
244
    {
248
        $class = isset($stackFrame['class']) ? $stackFrame['class'] : null;
245
        $class = isset($stackFrame['class']) ? $stackFrame['class'] : null;
Zeile 286... Zeile 283...
286
 
283
 
287
    /**
284
    /**
288
     * Set the current local namespace.
285
     * Set the current local namespace.
289
     *
286
     *
290
     * @param array|null $namespace (default: null)
-
 
291
     *
-
 
292
     * @return array|null
287
     * @param array|null $namespace (default: null)
293
     */
288
     */
294
    public function setNamespace(array $namespace = null)
289
    public function setNamespace(array $namespace = null)
295
    {
290
    {
296
        $this->namespace = $namespace;
291
        $this->namespace = $namespace;
Zeile 367... Zeile 362...
367
     * their own special beautiful snowflake syntax error just for
362
     * their own special beautiful snowflake syntax error just for
368
     * themselves.
363
     * themselves.
369
     *
364
     *
370
     * @param \PhpParser\Error $e
365
     * @param \PhpParser\Error $e
371
     * @param string           $code
366
     * @param string           $code
372
     *
-
 
373
     * @return bool
-
 
374
     */
367
     */
375
    private function parseErrorIsUnclosedString(\PhpParser\Error $e, string $code): bool
368
    private function parseErrorIsUnclosedString(\PhpParser\Error $e, string $code): bool
376
    {
369
    {
377
        if ($e->getRawMessage() !== 'Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE') {
370
        if ($e->getRawMessage() !== 'Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE') {
378
            return false;
371
            return false;