MatchAllWithOffsetsResult.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of composer/pcre.
  4. *
  5. * (c) Composer <https://github.com/composer>
  6. *
  7. * For the full copyright and license information, please view
  8. * the LICENSE file that was distributed with this source code.
  9. */
  10. namespace Composer\Pcre;
  11. final class MatchAllWithOffsetsResult
  12. {
  13. /**
  14. * An array of match group => list of matches, every match being a pair of string matched + offset in bytes (or -1 if no match)
  15. *
  16. * @readonly
  17. * @var array<int|string, list<array{string|null, int}>>
  18. * @phpstan-var array<int|string, list<array{string|null, int<-1, max>}>>
  19. */
  20. public $matches;
  21. /**
  22. * @readonly
  23. * @var 0|positive-int
  24. */
  25. public $count;
  26. /**
  27. * @readonly
  28. * @var bool
  29. */
  30. public $matched;
  31. /**
  32. * @param 0|positive-int $count
  33. * @param array<int|string, list<array{string|null, int}>> $matches
  34. * @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
  35. */
  36. public function __construct(int $count, array $matches)
  37. {
  38. $this->matches = $matches;
  39. $this->matched = (bool) $count;
  40. $this->count = $count;
  41. }
  42. }