This repository was archived by the owner on Jun 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ final class Request extends Message
110110 */
111111 private string $ clientIp = '0.0.0.0 ' ;
112112
113+ /**
114+ * @var array<string, mixed>
115+ */
116+ private array $ attributes = [];
117+
113118 /**
114119 * Returns a Request object representing the current request.
115120 *
@@ -1179,6 +1184,42 @@ public function getAcceptLanguage() : array
11791184 return $ this ->parseQualityValues ($ this ->getHeader ('Accept-Language ' ));
11801185 }
11811186
1187+ /**
1188+ * @return array<string, mixed>
1189+ */
1190+ public function getAttributes (): array
1191+ {
1192+ return $ this ->attributes ;
1193+ }
1194+
1195+ public function getAttribute (string $ name , $ default = null )
1196+ {
1197+ if (array_key_exists ($ name , $ this ->attributes )) {
1198+ return $ this ->attributes [$ name ];
1199+ }
1200+
1201+ return $ default ;
1202+ }
1203+
1204+ /**
1205+ * Returns a copy of this request with the given attribute set.
1206+ *
1207+ * This instance is immutable and unaffected by this method call.
1208+ *
1209+ * @param string $name The attribute name.
1210+ * @param mixed $value The attribute value.
1211+ *
1212+ * @return Request The updated request.
1213+ */
1214+ public function withAttribute (string $ name , $ value ): Request
1215+ {
1216+ $ that = clone $ this ;
1217+
1218+ $ that ->attributes [$ name ] = $ value ;
1219+
1220+ return $ that ;
1221+ }
1222+
11821223 /**
11831224 * Parses quality values as defined per RFC 7231 § 5.3.1.
11841225 *
You can’t perform that action at this time.
0 commit comments