Skip to content

Commit 7272f3a

Browse files
author
Carlos Garcia
committed
Deprecate old get methods in Request class; update documentation for alternatives
1 parent f661fde commit 7272f3a

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

Core/Request.php

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public function __construct(array $data = [])
5858
$this->request = new SubRequest($data['request'] ?? []);
5959
}
6060

61+
/**
62+
* @deprecated use request->all() or query->all() instead
63+
*/
6164
public function all(string ...$key): array
6265
{
6366
if (empty($key)) {
@@ -122,7 +125,7 @@ public function fullUrl(): string
122125
}
123126

124127
/**
125-
* @deprecated use inputOrQuery() or queryOrInput() instead
128+
* @deprecated use input(), inputOrQuery(), query() or queryOrInput() instead
126129
*/
127130
public function get(string $key, $default = null): ?string
128131
{
@@ -134,7 +137,7 @@ public function get(string $key, $default = null): ?string
134137
}
135138

136139
/**
137-
* @deprecated use inputOrQuery() or queryOrInput() instead
140+
* @deprecated use request->getArray() or query->getArray() instead
138141
*/
139142
public function getArray(string $key, bool $allowNull = true): ?array
140143
{
@@ -146,7 +149,7 @@ public function getArray(string $key, bool $allowNull = true): ?array
146149
}
147150

148151
/**
149-
* @deprecated use inputOrQuery() or queryOrInput() instead
152+
* @deprecated use request->getAlnum() or query->getAlnum() instead
150153
*/
151154
public function getAlnum(string $key): string
152155
{
@@ -157,8 +160,15 @@ public function getAlnum(string $key): string
157160
return $this->query->getAlnum($key);
158161
}
159162

163+
public function getBasePath(): string
164+
{
165+
$url = $_SERVER['REQUEST_URI'];
166+
$base = parse_url($url, PHP_URL_PATH);
167+
return is_string($base) ? $base : '';
168+
}
169+
160170
/**
161-
* @deprecated use inputOrQuery() or queryOrInput() instead
171+
* @deprecated use request->getBool() or query->getBool() instead
162172
*/
163173
public function getBool(string $key, bool $allowNull = true): ?bool
164174
{
@@ -170,7 +180,7 @@ public function getBool(string $key, bool $allowNull = true): ?bool
170180
}
171181

172182
/**
173-
* @deprecated use inputOrQuery() or queryOrInput() instead
183+
* @deprecated use request->getBool() or query->getBool() instead
174184
*/
175185
public function getDate(string $key, bool $allowNull = true): ?string
176186
{
@@ -182,7 +192,7 @@ public function getDate(string $key, bool $allowNull = true): ?string
182192
}
183193

184194
/**
185-
* @deprecated use inputOrQuery() or queryOrInput() instead
195+
* @deprecated use request->getDateTime() or query->getDateTime() instead
186196
*/
187197
public function getDateTime(string $key, bool $allowNull = true): ?string
188198
{
@@ -194,7 +204,7 @@ public function getDateTime(string $key, bool $allowNull = true): ?string
194204
}
195205

196206
/**
197-
* @deprecated use inputOrQuery() or queryOrInput() instead
207+
* @deprecated use request->getEmail() or query->getEmail() instead
198208
*/
199209
public function getEmail(string $key, bool $allowNull = true): ?string
200210
{
@@ -206,7 +216,7 @@ public function getEmail(string $key, bool $allowNull = true): ?string
206216
}
207217

208218
/**
209-
* @deprecated use inputOrQuery() or queryOrInput() instead
219+
* @deprecated use request->getFloat() or query->getFloat() instead
210220
*/
211221
public function getFloat(string $key, bool $allowNull = true): ?float
212222
{
@@ -218,7 +228,7 @@ public function getFloat(string $key, bool $allowNull = true): ?float
218228
}
219229

220230
/**
221-
* @deprecated use inputOrQuery() or queryOrInput() instead
231+
* @deprecated use request->getHour() or query->getHour() instead
222232
*/
223233
public function getHour(string $key, bool $allowNull = true): ?string
224234
{
@@ -230,7 +240,7 @@ public function getHour(string $key, bool $allowNull = true): ?string
230240
}
231241

232242
/**
233-
* @deprecated use inputOrQuery() or queryOrInput() instead
243+
* @deprecated use request->getInt() or query->getInt() instead
234244
*/
235245
public function getInt(string $key, bool $allowNull = true): ?int
236246
{
@@ -251,7 +261,7 @@ public function getMethod(): string
251261
}
252262

253263
/**
254-
* @deprecated use inputOrQuery() or queryOrInput() instead
264+
* @deprecated use request->getOnly() or query->getOnly() instead
255265
*/
256266
public function getOnly(string $key, array $values): ?string
257267
{
@@ -263,7 +273,7 @@ public function getOnly(string $key, array $values): ?string
263273
}
264274

265275
/**
266-
* @deprecated use inputOrQuery() or queryOrInput() instead
276+
* @deprecated use request->getString() or query->getString() instead
267277
*/
268278
public function getString(string $key, bool $allowNull = true): ?string
269279
{
@@ -275,7 +285,7 @@ public function getString(string $key, bool $allowNull = true): ?string
275285
}
276286

277287
/**
278-
* @deprecated use inputOrQuery() or queryOrInput() instead
288+
* @deprecated use request->getUrl() or query->getUrl() instead
279289
*/
280290
public function getUrl(string $key, bool $allowNull = true): ?string
281291
{
@@ -286,13 +296,6 @@ public function getUrl(string $key, bool $allowNull = true): ?string
286296
return $this->query->getUrl($key, $allowNull);
287297
}
288298

289-
public function getBasePath(): string
290-
{
291-
$url = $_SERVER['REQUEST_URI'];
292-
$base = parse_url($url, PHP_URL_PATH);
293-
return is_string($base) ? $base : '';
294-
}
295-
296299
public function has(string ...$key): bool
297300
{
298301
$found = false;

0 commit comments

Comments
 (0)