Completed
Pull Request — master (#519)
by Julián
01:54
created

PrettyPageHandler::getExceptionPlainText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Whoops - php errors for cool kids
4
 * @author Filipe Dobreira <http://github.com/filp>
5
 */
6
7
namespace Whoops\Handler;
8
9
use InvalidArgumentException;
10
use RuntimeException;
11
use Symfony\Component\VarDumper\Cloner\AbstractCloner;
12
use Symfony\Component\VarDumper\Cloner\VarCloner;
13
use UnexpectedValueException;
14
use Whoops\Exception\Formatter;
15
use Whoops\Util\Misc;
16
use Whoops\Util\TemplateHelper;
17
18
class PrettyPageHandler extends Handler
19
{
20
    /**
21
     * Search paths to be scanned for resources, in the reverse
22
     * order they're declared.
23
     *
24
     * @var array
25
     */
26
    private $searchPaths = [];
27
28
    /**
29
     * Fast lookup cache for known resource locations.
30
     *
31
     * @var array
32
     */
33
    private $resourceCache = [];
34
35
    /**
36
     * The name of the custom css file.
37
     *
38
     * @var string
39
     */
40
    private $customCss = null;
41
42
    /**
43
     * @var array[]
44
     */
45
    private $extraTables = [];
46
47
    /**
48
     * @var bool
49
     */
50
    private $handleUnconditionally = false;
51
52
    /**
53
     * @var string
54
     */
55
    private $pageTitle = "Whoops! There was an error.";
56
57
    /**
58
     * @var array[]
59
     */
60
    private $applicationPaths;
61
62
    /**
63
     * @var array[]
64
     */
65
    private $blacklist = [
66
        '_GET' => [],
67
        '_POST' => [],
68
        '_FILES' => [],
69
        '_COOKIE' => [],
70
        '_SESSION' => [],
71
        '_SERVER' => [],
72
        '_ENV' => [],
73
    ];
74
75
    /**
76
     * A string identifier for a known IDE/text editor, or a closure
77
     * that resolves a string that can be used to open a given file
78
     * in an editor. If the string contains the special substrings
79
     * %file or %line, they will be replaced with the correct data.
80
     *
81
     * @example
82
     *  "txmt://open?url=%file&line=%line"
83
     * @var mixed $editor
84
     */
85
    protected $editor;
86
87
    /**
88
     * A list of known editor strings
89
     * @var array
90
     */
91
    protected $editors = [
92
        "sublime"  => "subl://open?url=file://%file&line=%line",
93
        "textmate" => "txmt://open?url=file://%file&line=%line",
94
        "emacs"    => "emacs://open?url=file://%file&line=%line",
95
        "macvim"   => "mvim://open/?url=file://%file&line=%line",
96
        "phpstorm" => "phpstorm://open?file=%file&line=%line",
97
        "idea"     => "idea://open?file=%file&line=%line",
98
        "vscode"   => "vscode://file/%file:%line",
99
    ];
100
101
    /**
102
     * @var TemplateHelper
103
     */
104
    private $templateHelper;
105
106
    /**
107
     * Constructor.
108
     */
109 1
    public function __construct()
110
    {
111 1
        if (ini_get('xdebug.file_link_format') || extension_loaded('xdebug')) {
112
            // Register editor using xdebug's file_link_format option.
113
            $this->editors['xdebug'] = function ($file, $line) {
114 1
                return str_replace(['%f', '%l'], [$file, $line], ini_get('xdebug.file_link_format'));
115
            };
116 1
        }
117
118
        // Add the default, local resource search path:
119 1
        $this->searchPaths[] = __DIR__ . "/../Resources";
120
121
        // blacklist php provided auth based values
122 1
        $this->blacklist('_SERVER', 'PHP_AUTH_PW');
123
124 1
        $this->templateHelper = new TemplateHelper();
125
126 1
        if (class_exists('Symfony\Component\VarDumper\Cloner\VarCloner')) {
127 1
            $cloner = new VarCloner();
128
            // Only dump object internals if a custom caster exists.
129
            $cloner->addCasters(['*' => function ($obj, $a, $stub, $isNested, $filter = 0) {
0 ignored issues
show
Unused Code introduced by
The parameter $isNested is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
130
                $class = $stub->class;
131
                $classes = [$class => $class] + class_parents($class) + class_implements($class);
132
133
                foreach ($classes as $class) {
134
                    if (isset(AbstractCloner::$defaultCasters[$class])) {
135
                        return $a;
136
                    }
137
                }
138
139
                // Remove all internals
140
                return [];
141 1
            }]);
142 1
            $this->templateHelper->setCloner($cloner);
143 1
        }
144 1
    }
145
146
    /**
147
     * @return int|null
148
     */
149 1
    public function handle()
150
    {
151 1
        if (!$this->handleUnconditionally()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->handleUnconditionally() of type boolean|null is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
152
            // Check conditions for outputting HTML:
153
            // @todo: Make this more robust
154 1
            if (PHP_SAPI === 'cli') {
155
                // Help users who have been relying on an internal test value
156
                // fix their code to the proper method
157 1
                if (isset($_ENV['whoops-test'])) {
158
                    throw new \Exception(
159
                        'Use handleUnconditionally instead of whoops-test'
160
                        .' environment variable'
161
                    );
162
                }
163
164 1
                return Handler::DONE;
165
            }
166
        }
167
168
        $templateFile = $this->getResource("views/layout.html.php");
169
        $cssFile      = $this->getResource("css/whoops.base.css");
170
        $zeptoFile    = $this->getResource("js/zepto.min.js");
171
        $clipboard    = $this->getResource("js/clipboard.min.js");
172
        $jsFile       = $this->getResource("js/whoops.base.js");
173
174
        if ($this->customCss) {
175
            $customCssFile = $this->getResource($this->customCss);
176
        }
177
178
        $inspector = $this->getInspector();
179
        $frames = $this->getExceptionFrames();
180
        $code = $this->getExceptionCode();
181
182
        $plainTextException = $this->getExceptionPlainText();
183
184
        // List of variables that will be passed to the layout template.
185
        $vars = [
186
            "page_title" => $this->getPageTitle(),
187
188
            // @todo: Asset compiler
189
            "stylesheet" => file_get_contents($cssFile),
190
            "zepto"      => file_get_contents($zeptoFile),
191
            "clipboard"  => file_get_contents($clipboard),
192
            "javascript" => file_get_contents($jsFile),
193
194
            // Template paths:
195
            "header"                     => $this->getResource("views/header.html.php"),
196
            "header_outer"               => $this->getResource("views/header_outer.html.php"),
197
            "frame_list"                 => $this->getResource("views/frame_list.html.php"),
198
            "frames_description"         => $this->getResource("views/frames_description.html.php"),
199
            "frames_container"           => $this->getResource("views/frames_container.html.php"),
200
            "panel_details"              => $this->getResource("views/panel_details.html.php"),
201
            "panel_details_outer"        => $this->getResource("views/panel_details_outer.html.php"),
202
            "panel_left"                 => $this->getResource("views/panel_left.html.php"),
203
            "panel_left_outer"           => $this->getResource("views/panel_left_outer.html.php"),
204
            "frame_code"                 => $this->getResource("views/frame_code.html.php"),
205
            "env_details"                => $this->getResource("views/env_details.html.php"),
206
207
            "preface"        => $this->templateHelper->escape($plainTextException),
208
            "title"          => $this->getPageTitle(),
209
            "name"           => explode("\\", $inspector->getExceptionName()),
210
            "message"        => $inspector->getExceptionMessage(),
211
            "docref_url"     => $inspector->getExceptionDocrefUrl(),
212
            "code"           => $code,
213
            "plain_exception" => $plainTextException,
214
            "frames"         => $frames,
215
            "has_frames"     => !!count($frames),
216
            "handler"        => $this,
217
            "handlers"       => $this->getRun()->getHandlers(),
218
219
            "active_frames_tab" => count($frames) && $frames->offsetGet(0)->isApplication() ?  'application' : 'all',
0 ignored issues
show
Bug introduced by
The method isApplication cannot be called on $frames->offsetGet(0) (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
220
            "has_frames_tabs"   => $this->getApplicationPaths(),
221
222
            "tables"      => [
223
                "GET Data"              => $this->masked($_GET, '_GET'),
224
                "POST Data"             => $this->masked($_POST, '_POST'),
225
                "Files"                 => isset($_FILES) ? $this->masked($_FILES, '_FILES') : [],
226
                "Cookies"               => $this->masked($_COOKIE, '_COOKIE'),
227
                "Session"               => isset($_SESSION) ? $this->masked($_SESSION, '_SESSION') :  [],
228
                "Server/Request Data"   => $this->masked($_SERVER, '_SERVER'),
229
                "Environment Variables" => $this->masked($_ENV, '_ENV'),
230
            ],
231
        ];
232
233
        if (isset($customCssFile)) {
234
            $vars["stylesheet"] .= file_get_contents($customCssFile);
235
        }
236
237
        // Add extra entries list of data tables:
238
        // @todo: Consolidate addDataTable and addDataTableCallback
239
        $extraTables = array_map(function ($table) use ($inspector) {
240
            return $table instanceof \Closure ? $table($inspector) : $table;
241
        }, $this->getDataTables());
242
        $vars["tables"] = array_merge($extraTables, $vars["tables"]);
243
244
        $this->templateHelper->setVariables($vars);
245
        $this->templateHelper->render($templateFile);
246
247
        return Handler::QUIT;
248
    }
249
250
    /**
251
     * Get the stack trace frames of the exception that is currently being handled.
252
     *
253
     * @return \Whoops\Exception\FrameCollection;
0 ignored issues
show
Documentation introduced by
The doc-type \Whoops\Exception\FrameCollection; could not be parsed: Expected "|" or "end of type", but got ";" at position 33. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
254
     */
255
    protected function getExceptionFrames()
256
    {
257
        $frames = $this->getInspector()->getFrames();
258
259
        if ($this->getApplicationPaths()) {
260
            foreach ($frames as $frame) {
261
                foreach ($this->getApplicationPaths() as $path) {
262
                    if (strpos($frame->getFile(), $path) === 0) {
263
                        $frame->setApplication(true);
264
                        break;
265
                    }
266
                }
267
            }
268
        }
269
270
        return $frames;
271
    }
272
273
    /**
274
     * Get the code of the exception that is currently being handled.
275
     *
276
     * @return string
277
     */
278
    protected function getExceptionCode()
279
    {
280
        $exception = $this->getException();
281
282
        $code = $exception->getCode();
283
        if ($exception instanceof \ErrorException) {
284
            // ErrorExceptions wrap the php-error types within the 'severity' property
285
            $code = Misc::translateErrorCode($exception->getSeverity());
286
        }
287
288
        return (string) $code;
289
    }
290
291
    /**
292
     * Get exception being handled as plain text.
293
     *
294
     * @return string
295
     */
296
    protected function getExceptionPlainText()
297
    {
298
        $plainTextHandler = new PlainTextHandler();
299
        $plainTextHandler->setException($this->getException());
300
        $plainTextHandler->setInspector($this->getInspector());
301
302
        return $plainTextHandler->generateResponse();
303
    }
304
305
    /**
306
     * @return string
307
     */
308
    public function contentType()
309
    {
310
        return 'text/html';
311
    }
312
313
    /**
314
     * Adds an entry to the list of tables displayed in the template.
315
     * The expected data is a simple associative array. Any nested arrays
316
     * will be flattened with print_r
317
     * @param string $label
318
     * @param array  $data
319
     */
320 1
    public function addDataTable($label, array $data)
321
    {
322 1
        $this->extraTables[$label] = $data;
323 1
    }
324
325
    /**
326
     * Lazily adds an entry to the list of tables displayed in the table.
327
     * The supplied callback argument will be called when the error is rendered,
328
     * it should produce a simple associative array. Any nested arrays will
329
     * be flattened with print_r.
330
     *
331
     * @throws InvalidArgumentException If $callback is not callable
332
     * @param  string                   $label
333
     * @param  callable                 $callback Callable returning an associative array
334
     */
335 1
    public function addDataTableCallback($label, /* callable */ $callback)
336
    {
337 1
        if (!is_callable($callback)) {
338
            throw new InvalidArgumentException('Expecting callback argument to be callable');
339
        }
340
341 1
        $this->extraTables[$label] = function (\Whoops\Exception\Inspector $inspector = null) use ($callback) {
342
            try {
343 1
                $result = call_user_func($callback, $inspector);
344
345
                // Only return the result if it can be iterated over by foreach().
346 1
                return is_array($result) || $result instanceof \Traversable ? $result : [];
347
            } catch (\Exception $e) {
348
                // Don't allow failure to break the rendering of the original exception.
349
                return [];
350
            }
351
        };
352 1
    }
353
354
    /**
355
     * Returns all the extra data tables registered with this handler.
356
     * Optionally accepts a 'label' parameter, to only return the data
357
     * table under that label.
358
     * @param  string|null      $label
359
     * @return array[]|callable
360
     */
361 2
    public function getDataTables($label = null)
362
    {
363 2
        if ($label !== null) {
364 2
            return isset($this->extraTables[$label]) ?
365 2
                   $this->extraTables[$label] : [];
366
        }
367
368 2
        return $this->extraTables;
369
    }
370
371
    /**
372
     * Allows to disable all attempts to dynamically decide whether to
373
     * handle or return prematurely.
374
     * Set this to ensure that the handler will perform no matter what.
375
     * @param  bool|null $value
376
     * @return bool|null
377
     */
378 1
    public function handleUnconditionally($value = null)
379
    {
380 1
        if (func_num_args() == 0) {
381 1
            return $this->handleUnconditionally;
382
        }
383
384
        $this->handleUnconditionally = (bool) $value;
385
    }
386
387
    /**
388
     * Adds an editor resolver, identified by a string
389
     * name, and that may be a string path, or a callable
390
     * resolver. If the callable returns a string, it will
391
     * be set as the file reference's href attribute.
392
     *
393
     * @example
394
     *  $run->addEditor('macvim', "mvim://open?url=file://%file&line=%line")
395
     * @example
396
     *   $run->addEditor('remove-it', function($file, $line) {
397
     *       unlink($file);
398
     *       return "http://stackoverflow.com";
399
     *   });
400
     * @param string $identifier
401
     * @param string $resolver
402
     */
403 1
    public function addEditor($identifier, $resolver)
404
    {
405 1
        $this->editors[$identifier] = $resolver;
406 1
    }
407
408
    /**
409
     * Set the editor to use to open referenced files, by a string
410
     * identifier, or a callable that will be executed for every
411
     * file reference, with a $file and $line argument, and should
412
     * return a string.
413
     *
414
     * @example
415
     *   $run->setEditor(function($file, $line) { return "file:///{$file}"; });
416
     * @example
417
     *   $run->setEditor('sublime');
418
     *
419
     * @throws InvalidArgumentException If invalid argument identifier provided
420
     * @param  string|callable          $editor
421
     */
422 4
    public function setEditor($editor)
423
    {
424 4
        if (!is_callable($editor) && !isset($this->editors[$editor])) {
425
            throw new InvalidArgumentException(
426
                "Unknown editor identifier: $editor. Known editors:" .
427
                implode(",", array_keys($this->editors))
428
            );
429
        }
430
431 4
        $this->editor = $editor;
432 4
    }
433
434
    /**
435
     * Given a string file path, and an integer file line,
436
     * executes the editor resolver and returns, if available,
437
     * a string that may be used as the href property for that
438
     * file reference.
439
     *
440
     * @throws InvalidArgumentException If editor resolver does not return a string
441
     * @param  string                   $filePath
442
     * @param  int                      $line
443
     * @return string|bool
444
     */
445 4
    public function getEditorHref($filePath, $line)
446
    {
447 4
        $editor = $this->getEditor($filePath, $line);
448
449 4
        if (empty($editor)) {
450
            return false;
451
        }
452
453
        // Check that the editor is a string, and replace the
454
        // %line and %file placeholders:
455 4
        if (!isset($editor['url']) || !is_string($editor['url'])) {
456
            throw new UnexpectedValueException(
457
                __METHOD__ . " should always resolve to a string or a valid editor array; got something else instead."
458
            );
459
        }
460
461 4
        $editor['url'] = str_replace("%line", rawurlencode($line), $editor['url']);
462 4
        $editor['url'] = str_replace("%file", rawurlencode($filePath), $editor['url']);
463
464 4
        return $editor['url'];
465
    }
466
467
    /**
468
     * Given a boolean if the editor link should
469
     * act as an Ajax request. The editor must be a
470
     * valid callable function/closure
471
     *
472
     * @throws UnexpectedValueException  If editor resolver does not return a boolean
473
     * @param  string                   $filePath
474
     * @param  int                      $line
475
     * @return bool
476
     */
477 1
    public function getEditorAjax($filePath, $line)
478
    {
479 1
        $editor = $this->getEditor($filePath, $line);
480
481
        // Check that the ajax is a bool
482 1
        if (!isset($editor['ajax']) || !is_bool($editor['ajax'])) {
483
            throw new UnexpectedValueException(
484
                __METHOD__ . " should always resolve to a bool; got something else instead."
485
            );
486
        }
487 1
        return $editor['ajax'];
488
    }
489
490
    /**
491
     * Given a boolean if the editor link should
492
     * act as an Ajax request. The editor must be a
493
     * valid callable function/closure
494
     *
495
     * @param  string $filePath
496
     * @param  int    $line
497
     * @return array
498
     */
499 1
    protected function getEditor($filePath, $line)
500
    {
501 1
        if (!$this->editor || (!is_string($this->editor) && !is_callable($this->editor))) {
502
            return [];
503
        }
504
505 1
        if (is_string($this->editor) && isset($this->editors[$this->editor]) && !is_callable($this->editors[$this->editor])) {
506
           return [
507
                'ajax' => false,
508
                'url' => $this->editors[$this->editor],
509
            ];
510
        }
511
512 1
        if (is_callable($this->editor) || (isset($this->editors[$this->editor]) && is_callable($this->editors[$this->editor]))) {
513 1
            if (is_callable($this->editor)) {
514
                $callback = call_user_func($this->editor, $filePath, $line);
515
            } else {
516 1
                $callback = call_user_func($this->editors[$this->editor], $filePath, $line);
517
            }
518
519 1
            if (is_string($callback)) {
520
                return [
521 1
                    'ajax' => false,
522 1
                    'url' => $callback,
523 1
                ];
524
            }
525
526
            return [
527
                'ajax' => isset($callback['ajax']) ? $callback['ajax'] : false,
528
                'url' => isset($callback['url']) ? $callback['url'] : $callback,
529
            ];
530
        }
531
532
        return [];
533
    }
534
535
    /**
536
     * @param  string $title
537
     * @return void
538
     */
539 1
    public function setPageTitle($title)
540
    {
541 1
        $this->pageTitle = (string) $title;
542 1
    }
543
544
    /**
545
     * @return string
546
     */
547 1
    public function getPageTitle()
548
    {
549 1
        return $this->pageTitle;
550
    }
551
552
    /**
553
     * Adds a path to the list of paths to be searched for
554
     * resources.
555
     *
556
     * @throws InvalidArgumentException If $path is not a valid directory
557
     *
558
     * @param  string $path
559
     * @return void
560
     */
561 2
    public function addResourcePath($path)
562
    {
563 2
        if (!is_dir($path)) {
564 1
            throw new InvalidArgumentException(
565 1
                "'$path' is not a valid directory"
566 1
            );
567
        }
568
569 1
        array_unshift($this->searchPaths, $path);
570 1
    }
571
572
    /**
573
     * Adds a custom css file to be loaded.
574
     *
575
     * @param  string $name
576
     * @return void
577
     */
578
    public function addCustomCss($name)
579
    {
580
        $this->customCss = $name;
581
    }
582
583
    /**
584
     * @return array
585
     */
586 1
    public function getResourcePaths()
587
    {
588 1
        return $this->searchPaths;
589
    }
590
591
    /**
592
     * Finds a resource, by its relative path, in all available search paths.
593
     * The search is performed starting at the last search path, and all the
594
     * way back to the first, enabling a cascading-type system of overrides
595
     * for all resources.
596
     *
597
     * @throws RuntimeException If resource cannot be found in any of the available paths
598
     *
599
     * @param  string $resource
600
     * @return string
601
     */
602
    protected function getResource($resource)
603
    {
604
        // If the resource was found before, we can speed things up
605
        // by caching its absolute, resolved path:
606
        if (isset($this->resourceCache[$resource])) {
607
            return $this->resourceCache[$resource];
608
        }
609
610
        // Search through available search paths, until we find the
611
        // resource we're after:
612
        foreach ($this->searchPaths as $path) {
613
            $fullPath = $path . "/$resource";
614
615
            if (is_file($fullPath)) {
616
                // Cache the result:
617
                $this->resourceCache[$resource] = $fullPath;
618
                return $fullPath;
619
            }
620
        }
621
622
        // If we got this far, nothing was found.
623
        throw new RuntimeException(
624
            "Could not find resource '$resource' in any resource paths."
625
            . "(searched: " . join(", ", $this->searchPaths). ")"
626
        );
627
    }
628
629
    /**
630
     * @deprecated
631
     *
632
     * @return string
633
     */
634
    public function getResourcesPath()
635
    {
636
        $allPaths = $this->getResourcePaths();
637
638
        // Compat: return only the first path added
639
        return end($allPaths) ?: null;
640
    }
641
642
    /**
643
     * @deprecated
644
     *
645
     * @param  string $resourcesPath
646
     * @return void
647
     */
648
    public function setResourcesPath($resourcesPath)
649
    {
650
        $this->addResourcePath($resourcesPath);
651
    }
652
653
    /**
654
     * Return the application paths.
655
     *
656
     * @return array
657
     */
658
    public function getApplicationPaths()
659
    {
660
        return $this->applicationPaths;
661
    }
662
663
    /**
664
     * Set the application paths.
665
     *
666
     * @param array $applicationPaths
667
     */
668
    public function setApplicationPaths($applicationPaths)
669
    {
670
        $this->applicationPaths = $applicationPaths;
671
    }
672
673
    /**
674
     * Set the application root path.
675
     *
676
     * @param string $applicationRootPath
677
     */
678
    public function setApplicationRootPath($applicationRootPath)
679
    {
680
        $this->templateHelper->setApplicationRootPath($applicationRootPath);
681
    }
682
683
    /**
684
     * blacklist a sensitive value within one of the superglobal arrays.
685
     *
686
     * @param $superGlobalName string the name of the superglobal array, e.g. '_GET'
687
     * @param $key string the key within the superglobal
688
     */
689 1
    public function blacklist($superGlobalName, $key) {
690 1
        $this->blacklist[$superGlobalName][] = $key;
691 1
    }
692
693
    /**
694
     * Checks all values within the given superGlobal array.
695
     * Blacklisted values will be replaced by a equal length string cointaining only '*' characters.
696
     *
697
     * We intentionally dont rely on $GLOBALS as it depends on 'auto_globals_jit' php.ini setting.
698
     *
699
     * @param $superGlobal array One of the superglobal arrays
700
     * @param $superGlobalName string the name of the superglobal array, e.g. '_GET'
701
     * @return array $values without sensitive data
702
     */
703
    private function masked(array $superGlobal, $superGlobalName) {
704
        $blacklisted = $this->blacklist[$superGlobalName];
705
706
        $values = $superGlobal;
707
        foreach($blacklisted as $key) {
708
            if (isset($superGlobal[$key])) {
709
                $values[$key] = str_repeat('*', strlen($superGlobal[$key]));
710
            }
711
        }
712
        return $values;
713
    }
714
}
715