AmqpCaster.php
2 years ago
ArgsStub.php
1 year ago
Caster.php
1 year ago
ClassStub.php
1 year ago
ConstStub.php
2 years ago
CutArrayStub.php
2 years ago
CutStub.php
1 year ago
DOMCaster.php
1 year ago
DateCaster.php
2 years ago
DoctrineCaster.php
2 years ago
DsCaster.php
2 years ago
DsPairStub.php
2 years ago
EnumStub.php
1 year ago
ExceptionCaster.php
1 year ago
FiberCaster.php
2 years ago
FrameStub.php
1 year ago
GmpCaster.php
2 years ago
ImagineCaster.php
2 years ago
ImgStub.php
2 years ago
IntlCaster.php
2 years ago
LinkStub.php
1 year ago
MemcachedCaster.php
2 years ago
MysqliCaster.php
2 years ago
PdoCaster.php
2 years ago
PgSqlCaster.php
1 year ago
ProxyManagerCaster.php
2 years ago
RdKafkaCaster.php
1 year ago
RedisCaster.php
2 years ago
ReflectionCaster.php
1 year ago
ResourceCaster.php
1 year ago
SplCaster.php
1 year ago
StubCaster.php
2 years ago
SymfonyCaster.php
2 years ago
TraceStub.php
1 year ago
UuidCaster.php
2 years ago
XmlReaderCaster.php
1 year ago
XmlResourceCaster.php
2 years ago
CutStub.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace Matomo\Dependencies\Symfony\Component\VarDumper\Caster; |
| 12 | |
| 13 | use Matomo\Dependencies\Symfony\Component\VarDumper\Cloner\Stub; |
| 14 | /** |
| 15 | * Represents the main properties of a PHP variable, pre-casted by a caster. |
| 16 | * |
| 17 | * @author Nicolas Grekas <p@tchwork.com> |
| 18 | */ |
| 19 | class CutStub extends Stub |
| 20 | { |
| 21 | public function __construct($value) |
| 22 | { |
| 23 | $this->value = $value; |
| 24 | switch (\gettype($value)) { |
| 25 | case 'object': |
| 26 | $this->type = self::TYPE_OBJECT; |
| 27 | $this->class = \get_class($value); |
| 28 | if ($value instanceof \Closure) { |
| 29 | ReflectionCaster::castClosure($value, [], $this, \true, Caster::EXCLUDE_VERBOSE); |
| 30 | } |
| 31 | $this->cut = -1; |
| 32 | break; |
| 33 | case 'array': |
| 34 | $this->type = self::TYPE_ARRAY; |
| 35 | $this->class = self::ARRAY_ASSOC; |
| 36 | $this->cut = $this->value = \count($value); |
| 37 | break; |
| 38 | case 'resource': |
| 39 | case 'unknown type': |
| 40 | case 'resource (closed)': |
| 41 | $this->type = self::TYPE_RESOURCE; |
| 42 | $this->handle = (int) $value; |
| 43 | if ('Unknown' === ($this->class = @get_resource_type($value))) { |
| 44 | $this->class = 'Closed'; |
| 45 | } |
| 46 | $this->cut = -1; |
| 47 | break; |
| 48 | case 'string': |
| 49 | $this->type = self::TYPE_STRING; |
| 50 | $this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY; |
| 51 | $this->cut = self::STRING_BINARY === $this->class ? \strlen($value) : mb_strlen($value, 'UTF-8'); |
| 52 | $this->value = ''; |
| 53 | break; |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 |