@@ -122,31 +122,31 @@ class Request
122
122
protected $ content ;
123
123
124
124
/**
125
- * @var string[]
125
+ * @var string[]|null
126
126
*/
127
- protected array $ languages ;
127
+ protected ? array $ languages = null ;
128
128
129
129
/**
130
- * @var string[]
130
+ * @var string[]|null
131
131
*/
132
- protected array $ charsets ;
132
+ protected ? array $ charsets = null ;
133
133
134
134
/**
135
- * @var string[]
135
+ * @var string[]|null
136
136
*/
137
- protected array $ encodings ;
137
+ protected ? array $ encodings = null ;
138
138
139
139
/**
140
- * @var string[]
140
+ * @var string[]|null
141
141
*/
142
- protected array $ acceptableContentTypes ;
142
+ protected ? array $ acceptableContentTypes = null ;
143
143
144
- protected string $ pathInfo ;
145
- protected string $ requestUri ;
146
- protected string $ baseUrl ;
147
- protected string $ basePath ;
148
- protected string $ method ;
149
- protected ?string $ format ;
144
+ protected ? string $ pathInfo = null ;
145
+ protected ? string $ requestUri = null ;
146
+ protected ? string $ baseUrl = null ;
147
+ protected ? string $ basePath = null ;
148
+ protected ? string $ method = null ;
149
+ protected ?string $ format = null ;
150
150
protected SessionInterface |\Closure |null $ session = null ;
151
151
protected ?string $ locale = null ;
152
152
protected string $ defaultLocale = 'en ' ;
@@ -231,16 +231,16 @@ public function initialize(array $query = [], array $request = [], array $attrib
231
231
$ this ->headers = new HeaderBag ($ this ->server ->getHeaders ());
232
232
233
233
$ this ->content = $ content ;
234
- unset( $ this ->languages ) ;
235
- unset( $ this ->charsets ) ;
236
- unset( $ this ->encodings ) ;
237
- unset( $ this ->acceptableContentTypes ) ;
238
- unset( $ this ->pathInfo ) ;
239
- unset( $ this ->requestUri ) ;
240
- unset( $ this ->baseUrl ) ;
241
- unset( $ this ->basePath ) ;
242
- unset( $ this ->method ) ;
243
- unset( $ this ->format ) ;
234
+ $ this ->languages = null ;
235
+ $ this ->charsets = null ;
236
+ $ this ->encodings = null ;
237
+ $ this ->acceptableContentTypes = null ;
238
+ $ this ->pathInfo = null ;
239
+ $ this ->requestUri = null ;
240
+ $ this ->baseUrl = null ;
241
+ $ this ->basePath = null ;
242
+ $ this ->method = null ;
243
+ $ this ->format = null ;
244
244
}
245
245
246
246
/**
@@ -414,16 +414,16 @@ public function duplicate(array $query = null, array $request = null, array $att
414
414
$ dup ->server = new ServerBag ($ server );
415
415
$ dup ->headers = new HeaderBag ($ dup ->server ->getHeaders ());
416
416
}
417
- unset( $ dup ->languages ) ;
418
- unset( $ dup ->charsets ) ;
419
- unset( $ dup ->encodings ) ;
420
- unset( $ dup ->acceptableContentTypes ) ;
421
- unset( $ dup ->pathInfo ) ;
422
- unset( $ dup ->requestUri ) ;
423
- unset( $ dup ->baseUrl ) ;
424
- unset( $ dup ->basePath ) ;
425
- unset( $ dup ->method ) ;
426
- unset( $ dup ->format ) ;
417
+ $ dup ->languages = null ;
418
+ $ dup ->charsets = null ;
419
+ $ dup ->encodings = null ;
420
+ $ dup ->acceptableContentTypes = null ;
421
+ $ dup ->pathInfo = null ;
422
+ $ dup ->requestUri = null ;
423
+ $ dup ->baseUrl = null ;
424
+ $ dup ->basePath = null ;
425
+ $ dup ->method = null ;
426
+ $ dup ->format = null ;
427
427
428
428
if (!$ dup ->get ('_format ' ) && $ this ->get ('_format ' )) {
429
429
$ dup ->attributes ->set ('_format ' , $ this ->get ('_format ' ));
@@ -1115,7 +1115,7 @@ public function getHost(): string
1115
1115
*/
1116
1116
public function setMethod (string $ method ): void
1117
1117
{
1118
- unset( $ this ->method ) ;
1118
+ $ this ->method = null ;
1119
1119
$ this ->server ->set ('REQUEST_METHOD ' , $ method );
1120
1120
}
1121
1121
@@ -1134,7 +1134,7 @@ public function setMethod(string $method): void
1134
1134
*/
1135
1135
public function getMethod (): string
1136
1136
{
1137
- if (isset ( $ this ->method ) ) {
1137
+ if (null !== $ this ->method ) {
1138
1138
return $ this ->method ;
1139
1139
}
1140
1140
@@ -1182,7 +1182,7 @@ public function getRealMethod(): string
1182
1182
*/
1183
1183
public function getMimeType (string $ format ): ?string
1184
1184
{
1185
- if (! isset ( static ::$ formats) ) {
1185
+ if (null === static ::$ formats ) {
1186
1186
static ::initializeFormats ();
1187
1187
}
1188
1188
@@ -1196,7 +1196,7 @@ public function getMimeType(string $format): ?string
1196
1196
*/
1197
1197
public static function getMimeTypes (string $ format ): array
1198
1198
{
1199
- if (! isset ( static ::$ formats) ) {
1199
+ if (null === static ::$ formats ) {
1200
1200
static ::initializeFormats ();
1201
1201
}
1202
1202
@@ -1213,7 +1213,7 @@ public function getFormat(?string $mimeType): ?string
1213
1213
$ canonicalMimeType = trim (substr ($ mimeType , 0 , $ pos ));
1214
1214
}
1215
1215
1216
- if (! isset ( static ::$ formats) ) {
1216
+ if (null === static ::$ formats ) {
1217
1217
static ::initializeFormats ();
1218
1218
}
1219
1219
@@ -1236,7 +1236,7 @@ public function getFormat(?string $mimeType): ?string
1236
1236
*/
1237
1237
public function setFormat (?string $ format , string |array $ mimeTypes ): void
1238
1238
{
1239
- if (! isset ( static ::$ formats) ) {
1239
+ if (null === static ::$ formats ) {
1240
1240
static ::initializeFormats ();
1241
1241
}
1242
1242
@@ -1499,13 +1499,13 @@ public function isNoCache(): bool
1499
1499
*/
1500
1500
public function getPreferredFormat (?string $ default = 'html ' ): ?string
1501
1501
{
1502
- if (isset ( $ this ->preferredFormat ) || null !== $ preferredFormat = $ this ->getRequestFormat (null )) {
1503
- return $ this ->preferredFormat ??= $ preferredFormat ;
1502
+ if ($ this ->preferredFormat ?? = $ this ->getRequestFormat (null )) {
1503
+ return $ this ->preferredFormat ;
1504
1504
}
1505
1505
1506
1506
foreach ($ this ->getAcceptableContentTypes () as $ mimeType ) {
1507
- if ($ preferredFormat = $ this ->getFormat ($ mimeType )) {
1508
- return $ this ->preferredFormat = $ preferredFormat ;
1507
+ if ($ this -> preferredFormat = $ this ->getFormat ($ mimeType )) {
1508
+ return $ this ->preferredFormat ;
1509
1509
}
1510
1510
}
1511
1511
@@ -1552,7 +1552,7 @@ public function getPreferredLanguage(array $locales = null): ?string
1552
1552
*/
1553
1553
public function getLanguages (): array
1554
1554
{
1555
- if (isset ( $ this ->languages ) ) {
1555
+ if (null !== $ this ->languages ) {
1556
1556
return $ this ->languages ;
1557
1557
}
1558
1558
0 commit comments