Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 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 | } |