@@ -279,16 +279,16 @@ public function initialize(array $query = [], array $request = [], array $attrib
279279 $ this ->headers = new HeaderBag ($ this ->server ->getHeaders ());
280280
281281 $ 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 ) ;
292292 }
293293
294294 /**
@@ -465,16 +465,16 @@ public function duplicate(array $query = null, array $request = null, array $att
465465 $ dup ->server = new ServerBag ($ server );
466466 $ dup ->headers = new HeaderBag ($ dup ->server ->getHeaders ());
467467 }
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 ) ;
478478
479479 if (!$ dup ->get ('_format ' ) && $ this ->get ('_format ' )) {
480480 $ dup ->attributes ->set ('_format ' , $ this ->get ('_format ' ));
@@ -1179,7 +1179,7 @@ public function getHost(): string
11791179 */
11801180 public function setMethod (string $ method )
11811181 {
1182- $ this ->method = null ;
1182+ unset( $ this ->method ) ;
11831183 $ this ->server ->set ('REQUEST_METHOD ' , $ method );
11841184 }
11851185
@@ -1198,7 +1198,7 @@ public function setMethod(string $method)
11981198 */
11991199 public function getMethod (): string
12001200 {
1201- if (null !== $ this ->method ) {
1201+ if (isset ( $ this ->method ) ) {
12021202 return $ this ->method ;
12031203 }
12041204
@@ -1246,7 +1246,7 @@ public function getRealMethod(): string
12461246 */
12471247 public function getMimeType (string $ format ): ?string
12481248 {
1249- if (null === static ::$ formats ) {
1249+ if (! isset ( static ::$ formats) ) {
12501250 static ::initializeFormats ();
12511251 }
12521252
@@ -1260,7 +1260,7 @@ public function getMimeType(string $format): ?string
12601260 */
12611261 public static function getMimeTypes (string $ format ): array
12621262 {
1263- if (null === static ::$ formats ) {
1263+ if (! isset ( static ::$ formats) ) {
12641264 static ::initializeFormats ();
12651265 }
12661266
@@ -1277,7 +1277,7 @@ public function getFormat(?string $mimeType): ?string
12771277 $ canonicalMimeType = trim (substr ($ mimeType , 0 , $ pos ));
12781278 }
12791279
1280- if (null === static ::$ formats ) {
1280+ if (! isset ( static ::$ formats) ) {
12811281 static ::initializeFormats ();
12821282 }
12831283
@@ -1302,7 +1302,7 @@ public function getFormat(?string $mimeType): ?string
13021302 */
13031303 public function setFormat (?string $ format , string |array $ mimeTypes )
13041304 {
1305- if (null === static ::$ formats ) {
1305+ if (! isset ( static ::$ formats) ) {
13061306 static ::initializeFormats ();
13071307 }
13081308
@@ -1583,13 +1583,13 @@ public function isNoCache(): bool
15831583 */
15841584 public function getPreferredFormat (?string $ default = 'html ' ): ?string
15851585 {
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 ;
15881588 }
15891589
15901590 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 ;
15931593 }
15941594 }
15951595
@@ -1636,7 +1636,7 @@ public function getPreferredLanguage(array $locales = null): ?string
16361636 */
16371637 public function getLanguages (): array
16381638 {
1639- if (null !== $ this ->languages ) {
1639+ if (isset ( $ this ->languages ) ) {
16401640 return $ this ->languages ;
16411641 }
16421642
@@ -1677,11 +1677,7 @@ public function getLanguages(): array
16771677 */
16781678 public function getCharsets (): array
16791679 {
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 ()));
16851681 }
16861682
16871683 /**
@@ -1691,11 +1687,7 @@ public function getCharsets(): array
16911687 */
16921688 public function getEncodings (): array
16931689 {
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 ()));
16991691 }
17001692
17011693 /**
@@ -1705,11 +1697,7 @@ public function getEncodings(): array
17051697 */
17061698 public function getAcceptableContentTypes (): array
17071699 {
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 ()));
17131701 }
17141702
17151703 /**
0 commit comments