@@ -279,16 +279,16 @@ public function initialize(array $query = [], array $request = [], array $attrib
279
279
$ this ->headers = new HeaderBag ($ this ->server ->getHeaders ());
280
280
281
281
$ this ->content = $ content ;
282
- $ this ->languages = null ;
283
- $ this ->charsets = null ;
284
- $ this ->encodings = null ;
285
- $ this ->acceptableContentTypes = null ;
286
- $ this ->pathInfo = null ;
287
- $ this ->requestUri = null ;
288
- $ this ->baseUrl = null ;
289
- $ this ->basePath = null ;
290
- $ this ->method = null ;
291
- $ this ->format = null ;
282
+ unset( $ this ->languages ) ;
283
+ unset( $ this ->charsets ) ;
284
+ unset( $ this ->encodings ) ;
285
+ unset( $ this ->acceptableContentTypes ) ;
286
+ unset( $ this ->pathInfo ) ;
287
+ unset( $ this ->requestUri ) ;
288
+ unset( $ this ->baseUrl ) ;
289
+ unset( $ this ->basePath ) ;
290
+ unset( $ this ->method ) ;
291
+ unset( $ this ->format ) ;
292
292
}
293
293
294
294
/**
@@ -465,16 +465,16 @@ public function duplicate(array $query = null, array $request = null, array $att
465
465
$ dup ->server = new ServerBag ($ server );
466
466
$ dup ->headers = new HeaderBag ($ dup ->server ->getHeaders ());
467
467
}
468
- $ dup ->languages = null ;
469
- $ dup ->charsets = null ;
470
- $ dup ->encodings = null ;
471
- $ dup ->acceptableContentTypes = null ;
472
- $ dup ->pathInfo = null ;
473
- $ dup ->requestUri = null ;
474
- $ dup ->baseUrl = null ;
475
- $ dup ->basePath = null ;
476
- $ dup ->method = null ;
477
- $ dup ->format = null ;
468
+ unset( $ dup ->languages ) ;
469
+ unset( $ dup ->charsets ) ;
470
+ unset( $ dup ->encodings ) ;
471
+ unset( $ dup ->acceptableContentTypes ) ;
472
+ unset( $ dup ->pathInfo ) ;
473
+ unset( $ dup ->requestUri ) ;
474
+ unset( $ dup ->baseUrl ) ;
475
+ unset( $ dup ->basePath ) ;
476
+ unset( $ dup ->method ) ;
477
+ unset( $ dup ->format ) ;
478
478
479
479
if (!$ dup ->get ('_format ' ) && $ this ->get ('_format ' )) {
480
480
$ dup ->attributes ->set ('_format ' , $ this ->get ('_format ' ));
@@ -1179,7 +1179,7 @@ public function getHost(): string
1179
1179
*/
1180
1180
public function setMethod (string $ method )
1181
1181
{
1182
- $ this ->method = null ;
1182
+ unset( $ this ->method ) ;
1183
1183
$ this ->server ->set ('REQUEST_METHOD ' , $ method );
1184
1184
}
1185
1185
@@ -1198,7 +1198,7 @@ public function setMethod(string $method)
1198
1198
*/
1199
1199
public function getMethod (): string
1200
1200
{
1201
- if (null !== $ this ->method ) {
1201
+ if (isset ( $ this ->method ) ) {
1202
1202
return $ this ->method ;
1203
1203
}
1204
1204
@@ -1246,7 +1246,7 @@ public function getRealMethod(): string
1246
1246
*/
1247
1247
public function getMimeType (string $ format ): ?string
1248
1248
{
1249
- if (null === static ::$ formats ) {
1249
+ if (! isset ( static ::$ formats) ) {
1250
1250
static ::initializeFormats ();
1251
1251
}
1252
1252
@@ -1260,7 +1260,7 @@ public function getMimeType(string $format): ?string
1260
1260
*/
1261
1261
public static function getMimeTypes (string $ format ): array
1262
1262
{
1263
- if (null === static ::$ formats ) {
1263
+ if (! isset ( static ::$ formats) ) {
1264
1264
static ::initializeFormats ();
1265
1265
}
1266
1266
@@ -1277,7 +1277,7 @@ public function getFormat(?string $mimeType): ?string
1277
1277
$ canonicalMimeType = trim (substr ($ mimeType , 0 , $ pos ));
1278
1278
}
1279
1279
1280
- if (null === static ::$ formats ) {
1280
+ if (! isset ( static ::$ formats) ) {
1281
1281
static ::initializeFormats ();
1282
1282
}
1283
1283
@@ -1302,7 +1302,7 @@ public function getFormat(?string $mimeType): ?string
1302
1302
*/
1303
1303
public function setFormat (?string $ format , string |array $ mimeTypes )
1304
1304
{
1305
- if (null === static ::$ formats ) {
1305
+ if (! isset ( static ::$ formats) ) {
1306
1306
static ::initializeFormats ();
1307
1307
}
1308
1308
@@ -1583,13 +1583,13 @@ public function isNoCache(): bool
1583
1583
*/
1584
1584
public function getPreferredFormat (?string $ default = 'html ' ): ?string
1585
1585
{
1586
- if (null !== $ this ->preferredFormat || null !== $ this -> preferredFormat = $ this ->getRequestFormat (null )) {
1587
- return $ this ->preferredFormat ;
1586
+ if (isset ( $ this ->preferredFormat ) || null !== $ preferredFormat = $ this ->getRequestFormat (null )) {
1587
+ return $ this ->preferredFormat ??= $ preferredFormat ;
1588
1588
}
1589
1589
1590
1590
foreach ($ this ->getAcceptableContentTypes () as $ mimeType ) {
1591
- if ($ this -> preferredFormat = $ this ->getFormat ($ mimeType )) {
1592
- return $ this ->preferredFormat ;
1591
+ if ($ preferredFormat = $ this ->getFormat ($ mimeType )) {
1592
+ return $ this ->preferredFormat = $ preferredFormat ;
1593
1593
}
1594
1594
}
1595
1595
@@ -1636,7 +1636,7 @@ public function getPreferredLanguage(array $locales = null): ?string
1636
1636
*/
1637
1637
public function getLanguages (): array
1638
1638
{
1639
- if (null !== $ this ->languages ) {
1639
+ if (isset ( $ this ->languages ) ) {
1640
1640
return $ this ->languages ;
1641
1641
}
1642
1642
@@ -1677,11 +1677,7 @@ public function getLanguages(): array
1677
1677
*/
1678
1678
public function getCharsets (): array
1679
1679
{
1680
- if (null !== $ this ->charsets ) {
1681
- return $ this ->charsets ;
1682
- }
1683
-
1684
- return $ this ->charsets = array_map ('strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all ()));
1680
+ return $ this ->charsets ??= array_map ('strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Charset ' ))->all ()));
1685
1681
}
1686
1682
1687
1683
/**
@@ -1691,11 +1687,7 @@ public function getCharsets(): array
1691
1687
*/
1692
1688
public function getEncodings (): array
1693
1689
{
1694
- if (null !== $ this ->encodings ) {
1695
- return $ this ->encodings ;
1696
- }
1697
-
1698
- return $ this ->encodings = array_map ('strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all ()));
1690
+ return $ this ->encodings ??= array_map ('strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept-Encoding ' ))->all ()));
1699
1691
}
1700
1692
1701
1693
/**
@@ -1705,11 +1697,7 @@ public function getEncodings(): array
1705
1697
*/
1706
1698
public function getAcceptableContentTypes (): array
1707
1699
{
1708
- if (null !== $ this ->acceptableContentTypes ) {
1709
- return $ this ->acceptableContentTypes ;
1710
- }
1711
-
1712
- return $ this ->acceptableContentTypes = array_map ('strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all ()));
1700
+ return $ this ->acceptableContentTypes ??= array_map ('strval ' , array_keys (AcceptHeader::fromString ($ this ->headers ->get ('Accept ' ))->all ()));
1713
1701
}
1714
1702
1715
1703
/**
0 commit comments