Skip to content

Commit 69fb08b

Browse files
committed
move withers up
1 parent c6e60e4 commit 69fb08b

File tree

1 file changed

+105
-105
lines changed

1 file changed

+105
-105
lines changed

src/Symfony/Component/HttpFoundation/Cookie.php

+105-105
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,6 @@ public function __toString()
158158
return $str;
159159
}
160160

161-
/**
162-
* Gets the name of the cookie.
163-
*
164-
* @return string
165-
*/
166-
public function getName()
167-
{
168-
return $this->name;
169-
}
170-
171-
/**
172-
* Gets the value of the cookie.
173-
*
174-
* @return string|null
175-
*/
176-
public function getValue()
177-
{
178-
return $this->value;
179-
}
180-
181161
/**
182162
* Creates a cookie copy with a new value.
183163
*
@@ -191,16 +171,6 @@ public function withValue(?string $value): self
191171
return $cookie;
192172
}
193173

194-
/**
195-
* Gets the domain that the cookie is available to.
196-
*
197-
* @return string|null
198-
*/
199-
public function getDomain()
200-
{
201-
return $this->domain;
202-
}
203-
204174
/**
205175
* Creates a cookie copy with a new domain that the cookie is available to.
206176
*
@@ -214,16 +184,6 @@ public function withDomain(?string $domain): self
214184
return $cookie;
215185
}
216186

217-
/**
218-
* Gets the time the cookie expires.
219-
*
220-
* @return int
221-
*/
222-
public function getExpiresTime()
223-
{
224-
return $this->expire;
225-
}
226-
227187
/**
228188
* Creates a cookie copy with a new time the cookie expires.
229189
*
@@ -251,154 +211,194 @@ public function withExpires($expire = 0): self
251211
}
252212

253213
/**
254-
* Gets the max-age attribute.
214+
* Creates a cookie copy with a new path on the server in which the cookie will be available on.
255215
*
256-
* @return int
216+
* @return static
257217
*/
258-
public function getMaxAge()
218+
public function withPath(string $path): self
259219
{
260-
$maxAge = $this->expire - time();
220+
$cookie = clone $this;
221+
$cookie->path = '' === $path ? '/' : $path;
261222

262-
return 0 >= $maxAge ? 0 : $maxAge;
223+
return $cookie;
263224
}
264225

265226
/**
266-
* Gets the path on the server in which the cookie will be available on.
227+
* Creates a cookie copy that only be transmitted over a secure HTTPS connection from the client.
267228
*
268-
* @return string
229+
* @return static
269230
*/
270-
public function getPath()
231+
public function withSecure(bool $secure = true): self
271232
{
272-
return $this->path;
233+
$cookie = clone $this;
234+
$cookie->secure = $secure;
235+
236+
return $cookie;
273237
}
274238

275239
/**
276-
* Creates a cookie copy with a new path on the server in which the cookie will be available on.
240+
* Creates a cookie copy that be accessible only through the HTTP protocol.
277241
*
278242
* @return static
279243
*/
280-
public function withPath(string $path): self
244+
public function withHttpOnly(bool $httpOnly = true): self
281245
{
282246
$cookie = clone $this;
283-
$cookie->path = '' === $path ? '/' : $path;
247+
$cookie->httpOnly = $httpOnly;
284248

285249
return $cookie;
286250
}
287251

288252
/**
289-
* Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
253+
* Creates a cookie copy that uses no url encoding.
290254
*
291-
* @return bool
255+
* @return static
292256
*/
293-
public function isSecure()
257+
public function withRaw(bool $raw = true): self
294258
{
295-
return $this->secure ?? $this->secureDefault;
259+
if ($raw && false !== strpbrk($this->name, self::$reservedCharsList)) {
260+
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $this->name));
261+
}
262+
263+
$cookie = clone $this;
264+
$cookie->raw = $raw;
265+
266+
return $cookie;
296267
}
297268

298269
/**
299-
* Creates a cookie copy that only be transmitted over a secure HTTPS connection from the client.
270+
* Creates a cookie copy with SameSite attribute.
300271
*
301272
* @return static
302273
*/
303-
public function withSecure(bool $secure = true): self
274+
public function withSameSite(?string $sameSite): self
304275
{
276+
if ('' === $sameSite) {
277+
$sameSite = null;
278+
} elseif (null !== $sameSite) {
279+
$sameSite = strtolower($sameSite);
280+
}
281+
282+
if (!\in_array($sameSite, [self::SAMESITE_LAX, self::SAMESITE_STRICT, self::SAMESITE_NONE, null], true)) {
283+
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
284+
}
285+
305286
$cookie = clone $this;
306-
$cookie->secure = $secure;
287+
$cookie->sameSite = $sameSite;
307288

308289
return $cookie;
309290
}
310291

311292
/**
312-
* Checks whether the cookie will be made accessible only through the HTTP protocol.
293+
* Gets the name of the cookie.
313294
*
314-
* @return bool
295+
* @return string
315296
*/
316-
public function isHttpOnly()
297+
public function getName()
317298
{
318-
return $this->httpOnly;
299+
return $this->name;
319300
}
320301

321302
/**
322-
* Creates a cookie copy that be accessible only through the HTTP protocol.
303+
* Gets the value of the cookie.
323304
*
324-
* @return static
305+
* @return string|null
325306
*/
326-
public function withHttpOnly(bool $httpOnly = true): self
307+
public function getValue()
327308
{
328-
$cookie = clone $this;
329-
$cookie->httpOnly = $httpOnly;
330-
331-
return $cookie;
309+
return $this->value;
332310
}
333311

334312
/**
335-
* Whether this cookie is about to be cleared.
313+
* Gets the domain that the cookie is available to.
336314
*
337-
* @return bool
315+
* @return string|null
338316
*/
339-
public function isCleared()
317+
public function getDomain()
340318
{
341-
return 0 !== $this->expire && $this->expire < time();
319+
return $this->domain;
342320
}
343321

344322
/**
345-
* Checks if the cookie value should be sent with no url encoding.
323+
* Gets the time the cookie expires.
346324
*
347-
* @return bool
325+
* @return int
348326
*/
349-
public function isRaw()
327+
public function getExpiresTime()
350328
{
351-
return $this->raw;
329+
return $this->expire;
352330
}
353331

354332
/**
355-
* Creates a cookie copy that uses no url encoding.
333+
* Gets the max-age attribute.
356334
*
357-
* @return static
335+
* @return int
358336
*/
359-
public function withRaw(bool $raw = true): self
337+
public function getMaxAge()
360338
{
361-
if ($raw && false !== strpbrk($this->name, self::$reservedCharsList)) {
362-
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $this->name));
363-
}
339+
$maxAge = $this->expire - time();
364340

365-
$cookie = clone $this;
366-
$cookie->raw = $raw;
341+
return 0 >= $maxAge ? 0 : $maxAge;
342+
}
367343

368-
return $cookie;
344+
/**
345+
* Gets the path on the server in which the cookie will be available on.
346+
*
347+
* @return string
348+
*/
349+
public function getPath()
350+
{
351+
return $this->path;
369352
}
370353

371354
/**
372-
* Gets the SameSite attribute.
355+
* Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
373356
*
374-
* @return string|null
357+
* @return bool
375358
*/
376-
public function getSameSite()
359+
public function isSecure()
377360
{
378-
return $this->sameSite;
361+
return $this->secure ?? $this->secureDefault;
379362
}
380363

381364
/**
382-
* Creates a cookie copy with SameSite attribute.
365+
* Checks whether the cookie will be made accessible only through the HTTP protocol.
383366
*
384-
* @return static
367+
* @return bool
385368
*/
386-
public function withSameSite(?string $sameSite): self
369+
public function isHttpOnly()
387370
{
388-
if ('' === $sameSite) {
389-
$sameSite = null;
390-
} elseif (null !== $sameSite) {
391-
$sameSite = strtolower($sameSite);
392-
}
371+
return $this->httpOnly;
372+
}
393373

394-
if (!\in_array($sameSite, [self::SAMESITE_LAX, self::SAMESITE_STRICT, self::SAMESITE_NONE, null], true)) {
395-
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
396-
}
374+
/**
375+
* Whether this cookie is about to be cleared.
376+
*
377+
* @return bool
378+
*/
379+
public function isCleared()
380+
{
381+
return 0 !== $this->expire && $this->expire < time();
382+
}
397383

398-
$cookie = clone $this;
399-
$cookie->sameSite = $sameSite;
384+
/**
385+
* Checks if the cookie value should be sent with no url encoding.
386+
*
387+
* @return bool
388+
*/
389+
public function isRaw()
390+
{
391+
return $this->raw;
392+
}
400393

401-
return $cookie;
394+
/**
395+
* Gets the SameSite attribute.
396+
*
397+
* @return string|null
398+
*/
399+
public function getSameSite()
400+
{
401+
return $this->sameSite;
402402
}
403403

404404
/**

0 commit comments

Comments
 (0)