20
20
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD )]
21
21
class Route
22
22
{
23
- private ?string $ path = null ;
24
- private array $ localizedPaths = [];
25
- private array $ methods ;
26
23
/** @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 = [];
33
34
34
35
/**
35
36
* @param string|array<string,string>|null $path The route path (i.e. "/user/login")
@@ -50,32 +51,28 @@ class Route
50
51
* @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $alias The list of aliases for this route
51
52
*/
52
53
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 ,
59
60
array |string $ methods = [],
60
61
array |string $ schemes = [],
61
- private ?string $ condition = null ,
62
- private ?int $ priority = null ,
62
+ public ?string $ condition = null ,
63
+ public ?int $ priority = null ,
63
64
?string $ locale = null ,
64
65
?string $ format = null ,
65
66
?bool $ utf8 = null ,
66
67
?bool $ stateless = null ,
67
68
string |array |null $ env = null ,
68
69
string |DeprecatedAlias |array $ alias = [],
69
70
) {
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 ];
79
76
80
77
if (null !== $ locale ) {
81
78
$ this ->defaults ['_locale ' ] = $ locale ;
@@ -94,154 +91,161 @@ public function __construct(
94
91
}
95
92
}
96
93
94
+ #[\Deprecated('Use the "path" property instead ' , 'symfony/routing:7.4 ' )]
97
95
public function setPath (string $ path ): void
98
96
{
99
97
$ this ->path = $ path ;
100
98
}
101
99
100
+ #[\Deprecated('Use the "path" property instead ' , 'symfony/routing:7.4 ' )]
102
101
public function getPath (): ?string
103
102
{
104
- return $ this ->path ;
103
+ return \is_array ( $ this -> path ) ? null : $ this ->path ;
105
104
}
106
105
106
+ #[\Deprecated('Use the "path" property instead ' , 'symfony/routing:7.4 ' )]
107
107
public function setLocalizedPaths (array $ localizedPaths ): void
108
108
{
109
- $ this ->localizedPaths = $ localizedPaths ;
109
+ $ this ->path = $ localizedPaths ;
110
110
}
111
111
112
+ #[\Deprecated('Use the "path" property instead ' , 'symfony/routing:7.4 ' )]
112
113
public function getLocalizedPaths (): array
113
114
{
114
- return $ this ->localizedPaths ;
115
+ return \is_array ( $ this ->path ) ? $ this -> path : [] ;
115
116
}
116
117
118
+ #[\Deprecated('Use the "host" property instead ' , 'symfony/routing:7.4 ' )]
117
119
public function setHost (string $ pattern ): void
118
120
{
119
121
$ this ->host = $ pattern ;
120
122
}
121
123
124
+ #[\Deprecated('Use the "host" property instead ' , 'symfony/routing:7.4 ' )]
122
125
public function getHost (): ?string
123
126
{
124
127
return $ this ->host ;
125
128
}
126
129
130
+ #[\Deprecated('Use the "name" property instead ' , 'symfony/routing:7.4 ' )]
127
131
public function setName (string $ name ): void
128
132
{
129
133
$ this ->name = $ name ;
130
134
}
131
135
136
+ #[\Deprecated('Use the "name" property instead ' , 'symfony/routing:7.4 ' )]
132
137
public function getName (): ?string
133
138
{
134
139
return $ this ->name ;
135
140
}
136
141
142
+ #[\Deprecated('Use the "requirements" property instead ' , 'symfony/routing:7.4 ' )]
137
143
public function setRequirements (array $ requirements ): void
138
144
{
139
145
$ this ->requirements = $ requirements ;
140
146
}
141
147
148
+ #[\Deprecated('Use the "requirements" property instead ' , 'symfony/routing:7.4 ' )]
142
149
public function getRequirements (): array
143
150
{
144
151
return $ this ->requirements ;
145
152
}
146
153
154
+ #[\Deprecated('Use the "options" property instead ' , 'symfony/routing:7.4 ' )]
147
155
public function setOptions (array $ options ): void
148
156
{
149
157
$ this ->options = $ options ;
150
158
}
151
159
160
+ #[\Deprecated('Use the "options" property instead ' , 'symfony/routing:7.4 ' )]
152
161
public function getOptions (): array
153
162
{
154
163
return $ this ->options ;
155
164
}
156
165
166
+ #[\Deprecated('Use the "defaults" property instead ' , 'symfony/routing:7.4 ' )]
157
167
public function setDefaults (array $ defaults ): void
158
168
{
159
169
$ this ->defaults = $ defaults ;
160
170
}
161
171
172
+ #[\Deprecated('Use the "defaults" property instead ' , 'symfony/routing:7.4 ' )]
162
173
public function getDefaults (): array
163
174
{
164
175
return $ this ->defaults ;
165
176
}
166
177
178
+ #[\Deprecated('Use the "schemes" property instead ' , 'symfony/routing:7.4 ' )]
167
179
public function setSchemes (array |string $ schemes ): void
168
180
{
169
181
$ this ->schemes = (array ) $ schemes ;
170
182
}
171
183
184
+ #[\Deprecated('Use the "schemes" property instead ' , 'symfony/routing:7.4 ' )]
172
185
public function getSchemes (): array
173
186
{
174
187
return $ this ->schemes ;
175
188
}
176
189
190
+ #[\Deprecated('Use the "methods" property instead ' , 'symfony/routing:7.4 ' )]
177
191
public function setMethods (array |string $ methods ): void
178
192
{
179
193
$ this ->methods = (array ) $ methods ;
180
194
}
181
195
196
+ #[\Deprecated('Use the "methods" property instead ' , 'symfony/routing:7.4 ' )]
182
197
public function getMethods (): array
183
198
{
184
199
return $ this ->methods ;
185
200
}
186
201
202
+ #[\Deprecated('Use the "condition" property instead ' , 'symfony/routing:7.4 ' )]
187
203
public function setCondition (?string $ condition ): void
188
204
{
189
205
$ this ->condition = $ condition ;
190
206
}
191
207
208
+ #[\Deprecated('Use the "condition" property instead ' , 'symfony/routing:7.4 ' )]
192
209
public function getCondition (): ?string
193
210
{
194
211
return $ this ->condition ;
195
212
}
196
213
214
+ #[\Deprecated('Use the "priority" property instead ' , 'symfony/routing:7.4 ' )]
197
215
public function setPriority (int $ priority ): void
198
216
{
199
217
$ this ->priority = $ priority ;
200
218
}
201
219
220
+ #[\Deprecated('Use the "priority" property instead ' , 'symfony/routing:7.4 ' )]
202
221
public function getPriority (): ?int
203
222
{
204
223
return $ this ->priority ;
205
224
}
206
225
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 ' )]
210
227
public function setEnv (?string $ env ): void
211
228
{
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 ;
214
230
}
215
231
216
- /**
217
- * @deprecated since Symfony 7.4, use {@see getEnvs()} method instead
218
- */
232
+ #[\Deprecated('Use the "envs" property instead ' , 'symfony/routing:7.4 ' )]
219
233
public function getEnv (): ?string
220
234
{
221
- trigger_deprecation ('symfony/routing ' , '7.4 ' , 'The "%s()" method is deprecated, use "getEnvs()" instead. ' , __METHOD__ );
222
- if (!$ this ->env ) {
235
+ if (!$ this ->envs ) {
223
236
return null ;
224
237
}
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 )));
227
240
}
228
241
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 ];
240
243
}
241
244
242
245
/**
243
246
* @return (string|DeprecatedAlias)[]
244
247
*/
248
+ #[\Deprecated('Use the "aliases" property instead ' , 'symfony/routing:7.4 ' )]
245
249
public function getAliases (): array
246
250
{
247
251
return $ this ->aliases ;
@@ -250,6 +254,7 @@ public function getAliases(): array
250
254
/**
251
255
* @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $aliases
252
256
*/
257
+ #[\Deprecated('Use the "aliases" property instead ' , 'symfony/routing:7.4 ' )]
253
258
public function setAliases (string |DeprecatedAlias |array $ aliases ): void
254
259
{
255
260
$ this ->aliases = \is_array ($ aliases ) ? $ aliases : [$ aliases ];
0 commit comments