2020#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD )]
2121class Route
2222{
23- private ?string $ path = null ;
24- private array $ localizedPaths = [];
25- private array $ methods ;
2623 /** @var string[] */
27- private array $ env ;
28- private array $ schemes ;
29- /**
30- * @var (string|DeprecatedAlias)[]
31- */
32- private array $ aliases = [];
24+ public array $ methods ;
25+
26+ /** @var string[] */
27+ public array $ envs ;
28+
29+ /** @var string[] */
30+ public array $ schemes ;
31+
32+ /** @var (string|DeprecatedAlias)[] */
33+ public array $ aliases = [];
3334
3435 /**
3536 * @param string|array<string,string>|null $path The route path (i.e. "/user/login")
@@ -50,32 +51,28 @@ class Route
5051 * @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $alias The list of aliases for this route
5152 */
5253 public function __construct (
53- string |array |null $ path = null ,
54- private ?string $ name = null ,
55- private array $ requirements = [],
56- private array $ options = [],
57- private array $ defaults = [],
58- private ?string $ host = null ,
54+ public string |array |null $ path = null ,
55+ public ?string $ name = null ,
56+ public array $ requirements = [],
57+ public array $ options = [],
58+ public array $ defaults = [],
59+ public ?string $ host = null ,
5960 array |string $ methods = [],
6061 array |string $ schemes = [],
61- private ?string $ condition = null ,
62- private ?int $ priority = null ,
62+ public ?string $ condition = null ,
63+ public ?int $ priority = null ,
6364 ?string $ locale = null ,
6465 ?string $ format = null ,
6566 ?bool $ utf8 = null ,
6667 ?bool $ stateless = null ,
6768 string |array |null $ env = null ,
6869 string |DeprecatedAlias |array $ alias = [],
6970 ) {
70- if (\is_array ($ path )) {
71- $ this ->localizedPaths = $ path ;
72- } else {
73- $ this ->path = $ path ;
74- }
75- $ this ->setMethods ($ methods );
76- $ this ->setSchemes ($ schemes );
77- $ this ->setAliases ($ alias );
78- $ this ->setEnvs ((array ) $ env );
71+ $ this ->path = $ path ;
72+ $ this ->methods = (array ) $ methods ;
73+ $ this ->schemes = (array ) $ schemes ;
74+ $ this ->envs = (array ) $ env ;
75+ $ this ->aliases = \is_array ($ alias ) ? $ alias : [$ alias ];
7976
8077 if (null !== $ locale ) {
8178 $ this ->defaults ['_locale ' ] = $ locale ;
@@ -94,154 +91,161 @@ public function __construct(
9491 }
9592 }
9693
94+ #[\Deprecated('Use the "path" property instead ' , 'symfony/routing:7.4 ' )]
9795 public function setPath (string $ path ): void
9896 {
9997 $ this ->path = $ path ;
10098 }
10199
100+ #[\Deprecated('Use the "path" property instead ' , 'symfony/routing:7.4 ' )]
102101 public function getPath (): ?string
103102 {
104- return $ this ->path ;
103+ return \is_array ( $ this -> path ) ? null : $ this ->path ;
105104 }
106105
106+ #[\Deprecated('Use the "path" property instead ' , 'symfony/routing:7.4 ' )]
107107 public function setLocalizedPaths (array $ localizedPaths ): void
108108 {
109- $ this ->localizedPaths = $ localizedPaths ;
109+ $ this ->path = $ localizedPaths ;
110110 }
111111
112+ #[\Deprecated('Use the "path" property instead ' , 'symfony/routing:7.4 ' )]
112113 public function getLocalizedPaths (): array
113114 {
114- return $ this ->localizedPaths ;
115+ return \is_array ( $ this ->path ) ? $ this -> path : [] ;
115116 }
116117
118+ #[\Deprecated('Use the "host" property instead ' , 'symfony/routing:7.4 ' )]
117119 public function setHost (string $ pattern ): void
118120 {
119121 $ this ->host = $ pattern ;
120122 }
121123
124+ #[\Deprecated('Use the "host" property instead ' , 'symfony/routing:7.4 ' )]
122125 public function getHost (): ?string
123126 {
124127 return $ this ->host ;
125128 }
126129
130+ #[\Deprecated('Use the "name" property instead ' , 'symfony/routing:7.4 ' )]
127131 public function setName (string $ name ): void
128132 {
129133 $ this ->name = $ name ;
130134 }
131135
136+ #[\Deprecated('Use the "name" property instead ' , 'symfony/routing:7.4 ' )]
132137 public function getName (): ?string
133138 {
134139 return $ this ->name ;
135140 }
136141
142+ #[\Deprecated('Use the "requirements" property instead ' , 'symfony/routing:7.4 ' )]
137143 public function setRequirements (array $ requirements ): void
138144 {
139145 $ this ->requirements = $ requirements ;
140146 }
141147
148+ #[\Deprecated('Use the "requirements" property instead ' , 'symfony/routing:7.4 ' )]
142149 public function getRequirements (): array
143150 {
144151 return $ this ->requirements ;
145152 }
146153
154+ #[\Deprecated('Use the "options" property instead ' , 'symfony/routing:7.4 ' )]
147155 public function setOptions (array $ options ): void
148156 {
149157 $ this ->options = $ options ;
150158 }
151159
160+ #[\Deprecated('Use the "options" property instead ' , 'symfony/routing:7.4 ' )]
152161 public function getOptions (): array
153162 {
154163 return $ this ->options ;
155164 }
156165
166+ #[\Deprecated('Use the "defaults" property instead ' , 'symfony/routing:7.4 ' )]
157167 public function setDefaults (array $ defaults ): void
158168 {
159169 $ this ->defaults = $ defaults ;
160170 }
161171
172+ #[\Deprecated('Use the "defaults" property instead ' , 'symfony/routing:7.4 ' )]
162173 public function getDefaults (): array
163174 {
164175 return $ this ->defaults ;
165176 }
166177
178+ #[\Deprecated('Use the "schemes" property instead ' , 'symfony/routing:7.4 ' )]
167179 public function setSchemes (array |string $ schemes ): void
168180 {
169181 $ this ->schemes = (array ) $ schemes ;
170182 }
171183
184+ #[\Deprecated('Use the "schemes" property instead ' , 'symfony/routing:7.4 ' )]
172185 public function getSchemes (): array
173186 {
174187 return $ this ->schemes ;
175188 }
176189
190+ #[\Deprecated('Use the "methods" property instead ' , 'symfony/routing:7.4 ' )]
177191 public function setMethods (array |string $ methods ): void
178192 {
179193 $ this ->methods = (array ) $ methods ;
180194 }
181195
196+ #[\Deprecated('Use the "methods" property instead ' , 'symfony/routing:7.4 ' )]
182197 public function getMethods (): array
183198 {
184199 return $ this ->methods ;
185200 }
186201
202+ #[\Deprecated('Use the "condition" property instead ' , 'symfony/routing:7.4 ' )]
187203 public function setCondition (?string $ condition ): void
188204 {
189205 $ this ->condition = $ condition ;
190206 }
191207
208+ #[\Deprecated('Use the "condition" property instead ' , 'symfony/routing:7.4 ' )]
192209 public function getCondition (): ?string
193210 {
194211 return $ this ->condition ;
195212 }
196213
214+ #[\Deprecated('Use the "priority" property instead ' , 'symfony/routing:7.4 ' )]
197215 public function setPriority (int $ priority ): void
198216 {
199217 $ this ->priority = $ priority ;
200218 }
201219
220+ #[\Deprecated('Use the "priority" property instead ' , 'symfony/routing:7.4 ' )]
202221 public function getPriority (): ?int
203222 {
204223 return $ this ->priority ;
205224 }
206225
207- /**
208- * @deprecated since Symfony 7.4, use the {@see setEnvs()} method instead
209- */
226+ #[\Deprecated('Use the "envs" property instead ' , 'symfony/routing:7.4 ' )]
210227 public function setEnv (?string $ env ): void
211228 {
212- trigger_deprecation ('symfony/routing ' , '7.4 ' , 'The "%s()" method is deprecated, use "setEnvs()" instead. ' , __METHOD__ );
213- $ this ->env = (array ) $ env ;
229+ $ this ->envs = (array ) $ env ;
214230 }
215231
216- /**
217- * @deprecated since Symfony 7.4, use {@see getEnvs()} method instead
218- */
232+ #[\Deprecated('Use the "envs" property instead ' , 'symfony/routing:7.4 ' )]
219233 public function getEnv (): ?string
220234 {
221- trigger_deprecation ('symfony/routing ' , '7.4 ' , 'The "%s()" method is deprecated, use "getEnvs()" instead. ' , __METHOD__ );
222- if (!$ this ->env ) {
235+ if (!$ this ->envs ) {
223236 return null ;
224237 }
225- if (\count ($ this ->env ) > 1 ) {
226- throw new LogicException (\sprintf ('The "env" property has %d environments. Use "getEnvs()" to get all of them. ' , \count ($ this ->env )));
238+ if (\count ($ this ->envs ) > 1 ) {
239+ throw new LogicException (\sprintf ('The "env" property has %d environments. Use "getEnvs()" to get all of them. ' , \count ($ this ->envs )));
227240 }
228241
229- return $ this ->env [0 ];
230- }
231-
232- public function setEnvs (array |string $ env ): void
233- {
234- $ this ->env = (array ) $ env ;
235- }
236-
237- public function getEnvs (): array
238- {
239- return $ this ->env ;
242+ return $ this ->envs [0 ];
240243 }
241244
242245 /**
243246 * @return (string|DeprecatedAlias)[]
244247 */
248+ #[\Deprecated('Use the "aliases" property instead ' , 'symfony/routing:7.4 ' )]
245249 public function getAliases (): array
246250 {
247251 return $ this ->aliases ;
@@ -250,6 +254,7 @@ public function getAliases(): array
250254 /**
251255 * @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $aliases
252256 */
257+ #[\Deprecated('Use the "aliases" property instead ' , 'symfony/routing:7.4 ' )]
253258 public function setAliases (string |DeprecatedAlias |array $ aliases ): void
254259 {
255260 $ this ->aliases = \is_array ($ aliases ) ? $ aliases : [$ aliases ];
0 commit comments