CursorState.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the league/commonmark package.
  5. *
  6. * (c) Colin O'Dell <colinodell@gmail.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 League\CommonMark\Parser;
  12. /**
  13. * Encapsulates the current state of a cursor in case you need to rollback later.
  14. *
  15. * WARNING: Do not attempt to use this class for ANYTHING except for
  16. * type hinting and passing this object back into restoreState().
  17. * The constructor, methods, and inner contents may change in any
  18. * future release without warning!
  19. *
  20. * @internal
  21. *
  22. * @psalm-immutable
  23. */
  24. final class CursorState
  25. {
  26. /**
  27. * @var array<int, mixed>
  28. *
  29. * @psalm-readonly
  30. */
  31. private array $state;
  32. /**
  33. * @internal
  34. *
  35. * @param array<int, mixed> $state
  36. */
  37. public function __construct(array $state)
  38. {
  39. $this->state = $state;
  40. }
  41. /**
  42. * @internal
  43. *
  44. * @return array<int, mixed>
  45. */
  46. public function toArray(): array
  47. {
  48. return $this->state;
  49. }
  50. }