Mercurial > hg > cmmr2012-drupal-site
annotate vendor/symfony/var-dumper/Caster/CutStub.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 /* |
Chris@0 | 4 * This file is part of the Symfony package. |
Chris@0 | 5 * |
Chris@0 | 6 * (c) Fabien Potencier <fabien@symfony.com> |
Chris@0 | 7 * |
Chris@0 | 8 * For the full copyright and license information, please view the LICENSE |
Chris@0 | 9 * file that was distributed with this source code. |
Chris@0 | 10 */ |
Chris@0 | 11 |
Chris@0 | 12 namespace Symfony\Component\VarDumper\Caster; |
Chris@0 | 13 |
Chris@0 | 14 use Symfony\Component\VarDumper\Cloner\Stub; |
Chris@0 | 15 |
Chris@0 | 16 /** |
Chris@0 | 17 * Represents the main properties of a PHP variable, pre-casted by a caster. |
Chris@0 | 18 * |
Chris@0 | 19 * @author Nicolas Grekas <p@tchwork.com> |
Chris@0 | 20 */ |
Chris@0 | 21 class CutStub extends Stub |
Chris@0 | 22 { |
Chris@0 | 23 public function __construct($value) |
Chris@0 | 24 { |
Chris@0 | 25 $this->value = $value; |
Chris@0 | 26 |
Chris@4 | 27 switch (\gettype($value)) { |
Chris@0 | 28 case 'object': |
Chris@0 | 29 $this->type = self::TYPE_OBJECT; |
Chris@4 | 30 $this->class = \get_class($value); |
Chris@0 | 31 $this->cut = -1; |
Chris@0 | 32 break; |
Chris@0 | 33 |
Chris@0 | 34 case 'array': |
Chris@0 | 35 $this->type = self::TYPE_ARRAY; |
Chris@0 | 36 $this->class = self::ARRAY_ASSOC; |
Chris@4 | 37 $this->cut = $this->value = \count($value); |
Chris@0 | 38 break; |
Chris@0 | 39 |
Chris@0 | 40 case 'resource': |
Chris@0 | 41 case 'unknown type': |
Chris@0 | 42 case 'resource (closed)': |
Chris@0 | 43 $this->type = self::TYPE_RESOURCE; |
Chris@0 | 44 $this->handle = (int) $value; |
Chris@0 | 45 if ('Unknown' === $this->class = @get_resource_type($value)) { |
Chris@0 | 46 $this->class = 'Closed'; |
Chris@0 | 47 } |
Chris@0 | 48 $this->cut = -1; |
Chris@0 | 49 break; |
Chris@0 | 50 |
Chris@0 | 51 case 'string': |
Chris@0 | 52 $this->type = self::TYPE_STRING; |
Chris@0 | 53 $this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY; |
Chris@4 | 54 $this->cut = self::STRING_BINARY === $this->class ? \strlen($value) : mb_strlen($value, 'UTF-8'); |
Chris@0 | 55 $this->value = ''; |
Chris@0 | 56 break; |
Chris@0 | 57 } |
Chris@0 | 58 } |
Chris@0 | 59 } |