QueryExtractMode.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * League.Uri (https://uri.thephpleague.com)
  4. *
  5. * (c) Ignace Nyamagana Butera <nyamsprod@gmail.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. declare(strict_types=1);
  11. namespace League\Uri;
  12. enum QueryExtractMode
  13. {
  14. /**
  15. * Parses the query string using parse_str algorithm.
  16. */
  17. case Native;
  18. /**
  19. * Parses the query string like parse_str without mangling result keys.
  20. *
  21. * The result is similar to PHP parse_str when used with its second argument,
  22. * with the difference that variable names are not mangled.
  23. *
  24. * Behavior details:
  25. * - Empty names are ignored
  26. * - If a name is duplicated, the last value overwrites the previous one
  27. * - If no "[" is detected, the value is added using the name as the array key
  28. * - If "[" is detected but no matching "]" exists, the value is added using the name as the array key
  29. * - If bracket usage is malformed, the remaining part is dropped
  30. * - "." and " " are NOT converted to "_"
  31. * - If no "]" exists, the first "[" is not converted to "_"
  32. * - No whitespace trimming is performed on keys
  33. *
  34. * @see https://www.php.net/parse_str
  35. * @see https://wiki.php.net/rfc/on_demand_name_mangling
  36. */
  37. case Unmangled;
  38. /**
  39. * Same as QueryParsingMode::Unmangled and additionally
  40. * preserves null values instead of converting them
  41. * to empty strings.
  42. */
  43. case LossLess;
  44. }