| 
3 | 3 | namespace DebugBar\DataFormatter;  | 
4 | 4 | 
 
  | 
5 | 5 | use DebugBar\DataCollector\AssetProvider;  | 
6 |  | -use Symfony\Component\VarDumper\Caster\Caster;  | 
7 |  | -use Symfony\Component\VarDumper\Cloner\Cursor;  | 
 | 6 | +use DebugBar\DataFormatter\VarDumper\DebugBarHtmlDumper;  | 
 | 7 | +use DebugBar\DataFormatter\VarDumper\SeekingData;  | 
8 | 8 | use Symfony\Component\VarDumper\Cloner\Data;  | 
9 |  | -use Symfony\Component\VarDumper\Cloner\DumperInterface;  | 
10 |  | -use Symfony\Component\VarDumper\Cloner\Stub;  | 
11 | 9 | use Symfony\Component\VarDumper\Cloner\VarCloner;  | 
12 |  | -use Symfony\Component\VarDumper\Dumper\HtmlDumper;  | 
13 | 10 | 
 
  | 
14 | 11 | /**  | 
15 | 12 |  * Clones and renders variables in HTML format using the Symfony VarDumper component.  | 
@@ -48,7 +45,7 @@ class DebugBarVarDumper implements AssetProvider  | 
48 | 45 |     /** @var VarCloner */  | 
49 | 46 |     protected $cloner;  | 
50 | 47 | 
 
  | 
51 |  | -    /** @var DebugBarHtmlDumper */  | 
 | 48 | +    /** @var Debu */  | 
52 | 49 |     protected $dumper;  | 
53 | 50 | 
 
  | 
54 | 51 |     /**  | 
@@ -316,110 +313,3 @@ protected function dump(Data $data)  | 
316 | 313 |         return $result;  | 
317 | 314 |     }  | 
318 | 315 | }  | 
319 |  | - | 
320 |  | -/**  | 
321 |  | - * We have to extend the base HtmlDumper class in order to get access to the protected-only  | 
322 |  | - * getDumpHeader function.  | 
323 |  | - */  | 
324 |  | -class DebugBarHtmlDumper extends HtmlDumper  | 
325 |  | -{  | 
326 |  | -    public function getDumpHeaderByDebugBar() {  | 
327 |  | -        // getDumpHeader is protected:  | 
328 |  | -        return $this->getDumpHeader();  | 
329 |  | -    }  | 
330 |  | -}  | 
331 |  | - | 
332 |  | -/**  | 
333 |  | - * This class backports the seek() function from Symfony 3.2 to older versions - up to v2.6.  The  | 
334 |  | - * class should not be used with newer Symfony versions that provide the seek function, as it relies  | 
335 |  | - * on a lot of undocumented functionality.  | 
336 |  | - */  | 
337 |  | -class SeekingData extends Data  | 
338 |  | -{  | 
339 |  | -    // Because the class copies/pastes the seek() implementation from Symfony 3.2, we reproduce its  | 
340 |  | -    // copyright here; this class is subject to the following additional copyright:  | 
341 |  | - | 
342 |  | -    /*  | 
343 |  | -     * Copyright (c) 2014-2017 Fabien Potencier  | 
344 |  | -     *  | 
345 |  | -     * Permission is hereby granted, free of charge, to any person obtaining a copy  | 
346 |  | -     * of this software and associated documentation files (the "Software"), to deal  | 
347 |  | -     * in the Software without restriction, including without limitation the rights  | 
348 |  | -     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  | 
349 |  | -     * copies of the Software, and to permit persons to whom the Software is furnished  | 
350 |  | -     * to do so, subject to the following conditions:  | 
351 |  | -     *  | 
352 |  | -     * The above copyright notice and this permission notice shall be included in all  | 
353 |  | -     * copies or substantial portions of the Software.  | 
354 |  | -     *  | 
355 |  | -     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  | 
356 |  | -     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  | 
357 |  | -     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  | 
358 |  | -     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  | 
359 |  | -     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  | 
360 |  | -     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN  | 
361 |  | -     * THE SOFTWARE.  | 
362 |  | -     */  | 
363 |  | -    private $position = 0;  | 
364 |  | -    private $key = 0;  | 
365 |  | - | 
366 |  | -    /**  | 
367 |  | -     * Seeks to a specific key in nested data structures.  | 
368 |  | -     *  | 
369 |  | -     * @param string|int $key The key to seek to  | 
370 |  | -     *  | 
371 |  | -     * @return self|null A clone of $this of null if the key is not set  | 
372 |  | -     */  | 
373 |  | -    public function seek($key)  | 
374 |  | -    {  | 
375 |  | -        $thisData = $this->getRawData();  | 
376 |  | -        $item = $thisData[$this->position][$this->key];  | 
377 |  | - | 
378 |  | -        if (!$item instanceof Stub || !$item->position) {  | 
379 |  | -            return;  | 
380 |  | -        }  | 
381 |  | -        $keys = array($key);  | 
382 |  | - | 
383 |  | -        switch ($item->type) {  | 
384 |  | -            case Stub::TYPE_OBJECT:  | 
385 |  | -                $keys[] = "\0+\0".$key;  | 
386 |  | -                $keys[] = "\0*\0".$key;  | 
387 |  | -                $keys[] = "\0~\0".$key;  | 
388 |  | -                $keys[] = "\0$item->class\0$key";  | 
389 |  | -            case Stub::TYPE_ARRAY:  | 
390 |  | -            case Stub::TYPE_RESOURCE:  | 
391 |  | -                break;  | 
392 |  | -            default:  | 
393 |  | -                return;  | 
394 |  | -        }  | 
395 |  | - | 
396 |  | -        $data = null;  | 
397 |  | -        $children = $thisData[$item->position];  | 
398 |  | - | 
399 |  | -        foreach ($keys as $key) {  | 
400 |  | -            if (isset($children[$key]) || array_key_exists($key, $children)) {  | 
401 |  | -                $data = clone $this;  | 
402 |  | -                $data->key = $key;  | 
403 |  | -                $data->position = $item->position;  | 
404 |  | -                break;  | 
405 |  | -            }  | 
406 |  | -        }  | 
407 |  | - | 
408 |  | -        return $data;  | 
409 |  | -    }  | 
410 |  | - | 
411 |  | -    /**  | 
412 |  | -     * {@inheritdoc}  | 
413 |  | -     */  | 
414 |  | -    public function dump(DumperInterface $dumper)  | 
415 |  | -    {  | 
416 |  | -        // Override the base class dump to use the position and key  | 
417 |  | -        $refs = array(0);  | 
418 |  | -        $class = new \ReflectionClass($this);  | 
419 |  | -        $dumpItem = $class->getMethod('dumpItem');  | 
420 |  | -        $dumpItem->setAccessible(true);  | 
421 |  | -        $data = $this->getRawData();  | 
422 |  | -        $args = array($dumper, new Cursor(), &$refs, $data[$this->position][$this->key]);  | 
423 |  | -        $dumpItem->invokeArgs($this, $args);  | 
424 |  | -    }  | 
425 |  | -}  | 
0 commit comments