RoutesReference.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\Routing\Loader\Configurator;
  11. // For the phpdoc to remain compatible with the generation of per-app Routes class,
  12. // this file should have no "use" statements: all symbols referenced by
  13. // the phpdoc need to be in the current namespace or be root-scoped.
  14. /**
  15. * This class provides array-shapes for configuring the routes of an application.
  16. *
  17. * Example:
  18. *
  19. * ```php
  20. * // config/routes.php
  21. * namespace Symfony\Component\Routing\Loader\Configurator;
  22. *
  23. * return Routes::config([
  24. * 'controllers' => [
  25. * 'resource' => 'routing.controllers',
  26. * ],
  27. * ]);
  28. * ```
  29. *
  30. * @psalm-type RouteConfig = array{
  31. * path: string|array<string,string>,
  32. * controller?: string,
  33. * methods?: string|list<string>,
  34. * requirements?: array<string,string>,
  35. * defaults?: array<string,mixed>,
  36. * options?: array<string,mixed>,
  37. * host?: string|array<string,string>,
  38. * schemes?: string|list<string>,
  39. * condition?: string,
  40. * locale?: string,
  41. * format?: string,
  42. * utf8?: bool,
  43. * stateless?: bool,
  44. * }
  45. * @psalm-type ImportConfig = array{
  46. * resource: string,
  47. * type?: string,
  48. * exclude?: string|list<string>,
  49. * prefix?: string|array<string,string>,
  50. * name_prefix?: string,
  51. * trailing_slash_on_root?: bool,
  52. * controller?: string,
  53. * methods?: string|list<string>,
  54. * requirements?: array<string,string>,
  55. * defaults?: array<string,mixed>,
  56. * options?: array<string,mixed>,
  57. * host?: string|array<string,string>,
  58. * schemes?: string|list<string>,
  59. * condition?: string,
  60. * locale?: string,
  61. * format?: string,
  62. * utf8?: bool,
  63. * stateless?: bool,
  64. * }
  65. * @psalm-type AliasConfig = array{
  66. * alias: string,
  67. * deprecated?: array{package:string, version:string, message?:string},
  68. * }
  69. * @psalm-type RoutesConfig = array<string, RouteConfig|ImportConfig|AliasConfig|array<string, RouteConfig|ImportConfig|AliasConfig>>
  70. */
  71. class RoutesReference
  72. {
  73. /**
  74. * @param RoutesConfig $config
  75. *
  76. * @psalm-return RoutesConfig
  77. */
  78. public static function config(array $config): array
  79. {
  80. return $config;
  81. }
  82. }