FiberCaster.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\VarDumper\Caster;
  11. use Symfony\Component\VarDumper\Cloner\Stub;
  12. /**
  13. * Casts Fiber related classes to array representation.
  14. *
  15. * @author Grégoire Pineau <lyrixx@lyrixx.info>
  16. */
  17. final class FiberCaster
  18. {
  19. public static function castFiber(\Fiber $fiber, array $a, Stub $stub, bool $isNested, int $filter = 0)
  20. {
  21. $prefix = Caster::PREFIX_VIRTUAL;
  22. if ($fiber->isTerminated()) {
  23. $status = 'terminated';
  24. } elseif ($fiber->isRunning()) {
  25. $status = 'running';
  26. } elseif ($fiber->isSuspended()) {
  27. $status = 'suspended';
  28. } elseif ($fiber->isStarted()) {
  29. $status = 'started';
  30. } else {
  31. $status = 'not started';
  32. }
  33. $a[$prefix.'status'] = $status;
  34. return $a;
  35. }
  36. }