Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 55e683f

Browse filesBrowse files
committed
[VarDumper] Add support for Fiber
1 parent ff70bd1 commit 55e683f
Copy full SHA for 55e683f

File tree

3 files changed

+46
-0
lines changed
Filter options

3 files changed

+46
-0
lines changed

‎src/Symfony/Component/VarDumper/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Add ability to style integer and double values independently
88
* Add casters for Symfony's UUIDs and ULIDs
9+
* Add support for `Fiber`
910

1011
5.2.0
1112
-----
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
12+
namespace Symfony\Component\VarDumper\Caster;
13+
14+
use Symfony\Component\VarDumper\Cloner\Stub;
15+
16+
/**
17+
* Casts Fiber related classes to array representation.
18+
*
19+
* @author Grégoire Pineau <lyrixx@lyrixx.info>
20+
*/
21+
final class FiberCaster
22+
{
23+
public static function castFiber(\Fiber $fiber, array $a, Stub $stub, bool $isNested, int $filter = 0)
24+
{
25+
$prefix = Caster::PREFIX_VIRTUAL;
26+
27+
if ($fiber->isTerminated()) {
28+
$status = 'terminated';
29+
} elseif ($fiber->isRunning()) {
30+
$status = 'running';
31+
} elseif ($fiber->isSuspended()) {
32+
$status = 'suspended';
33+
} elseif ($fiber->isStarted()) {
34+
$status = 'started';
35+
} else {
36+
$status = 'not started';
37+
}
38+
39+
$a[$prefix.'status'] = $status;
40+
41+
return $a;
42+
}
43+
}

‎src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ abstract class AbstractCloner implements ClonerInterface
2929
'Symfony\Component\VarDumper\Caster\ConstStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castStub'],
3030
'Symfony\Component\VarDumper\Caster\EnumStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castEnum'],
3131

32+
'Fiber' => ['Symfony\Component\VarDumper\Caster\FiberCaster', 'castFiber'],
33+
3234
'Closure' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClosure'],
3335
'Generator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castGenerator'],
3436
'ReflectionType' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castType'],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.