1
1
<?php
2
2
/**
3
3
* @see https://github.com/zendframework/zend-http for the canonical source repository
4
- * @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http ://www.zend.com)
4
+ * @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (https ://www.zend.com)
5
5
* @license https://github.com/zendframework/zend-http/blob/master/LICENSE.md New BSD License
6
6
*/
7
7
@@ -190,15 +190,15 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
190
190
*
191
191
* @todo Add validation of each one of the parameters (legal domain, etc.)
192
192
*
193
- * @param string $name
194
- * @param string $value
195
- * @param int|string|DateTime $expires
196
- * @param string $path
197
- * @param string $domain
198
- * @param bool $secure
199
- * @param bool $httponly
200
- * @param string $maxAge
201
- * @param int $version
193
+ * @param string|null $name
194
+ * @param string|null $value
195
+ * @param int|string|DateTime|null $expires
196
+ * @param string|null $path
197
+ * @param string|null $domain
198
+ * @param bool $secure
199
+ * @param bool $httponly
200
+ * @param int|null $maxAge
201
+ * @param int|null $version
202
202
*/
203
203
public function __construct (
204
204
$ name = null ,
@@ -302,9 +302,9 @@ public function getFieldValue()
302
302
}
303
303
304
304
/**
305
- * @param string $name
305
+ * @param string|null $name
306
+ * @return $this
306
307
* @throws Exception\InvalidArgumentException
307
- * @return SetCookie
308
308
*/
309
309
public function setName ($ name )
310
310
{
@@ -314,16 +314,16 @@ public function setName($name)
314
314
}
315
315
316
316
/**
317
- * @return string
317
+ * @return string|null
318
318
*/
319
319
public function getName ()
320
320
{
321
321
return $ this ->name ;
322
322
}
323
323
324
324
/**
325
- * @param string $value
326
- * @return SetCookie
325
+ * @param string|null $value
326
+ * @return $this
327
327
*/
328
328
public function setValue ($ value )
329
329
{
@@ -332,19 +332,17 @@ public function setValue($value)
332
332
}
333
333
334
334
/**
335
- * @return string
335
+ * @return string|null
336
336
*/
337
337
public function getValue ()
338
338
{
339
339
return $ this ->value ;
340
340
}
341
341
342
342
/**
343
- * Set version
344
- *
345
- * @param int $version
343
+ * @param int|null $version
344
+ * @return $this
346
345
* @throws Exception\InvalidArgumentException
347
- * @return SetCookie
348
346
*/
349
347
public function setVersion ($ version )
350
348
{
@@ -356,20 +354,16 @@ public function setVersion($version)
356
354
}
357
355
358
356
/**
359
- * Get version
360
- *
361
- * @return int
357
+ * @return int|null
362
358
*/
363
359
public function getVersion ()
364
360
{
365
361
return $ this ->version ;
366
362
}
367
363
368
364
/**
369
- * Set Max-Age
370
- *
371
- * @param int $maxAge
372
- * @return SetCookie
365
+ * @param int $maxAge
366
+ * @return $this
373
367
*/
374
368
public function setMaxAge ($ maxAge )
375
369
{
@@ -382,22 +376,16 @@ public function setMaxAge($maxAge)
382
376
}
383
377
384
378
/**
385
- * Get Max-Age
386
- *
387
- * @return int
379
+ * @return int|null
388
380
*/
389
381
public function getMaxAge ()
390
382
{
391
383
return $ this ->maxAge ;
392
384
}
393
385
394
386
/**
395
- * Set Expires
396
- *
397
- * @param int|string|DateTime $expires
398
- *
399
- * @return self
400
- *
387
+ * @param int|string|DateTime|null $expires
388
+ * @return $this
401
389
* @throws Exception\InvalidArgumentException
402
390
*/
403
391
public function setExpires ($ expires )
@@ -435,13 +423,13 @@ public function setExpires($expires)
435
423
}
436
424
437
425
/**
438
- * @param bool $inSeconds
439
- * @return int|string
426
+ * @param bool $inSeconds
427
+ * @return int|string|null
440
428
*/
441
429
public function getExpires ($ inSeconds = false )
442
430
{
443
431
if ($ this ->expires === null ) {
444
- return ;
432
+ return null ;
445
433
}
446
434
if ($ inSeconds ) {
447
435
return $ this ->expires ;
@@ -450,8 +438,8 @@ public function getExpires($inSeconds = false)
450
438
}
451
439
452
440
/**
453
- * @param string $domain
454
- * @return SetCookie
441
+ * @param string|null $domain
442
+ * @return $this
455
443
*/
456
444
public function setDomain ($ domain )
457
445
{
@@ -461,16 +449,16 @@ public function setDomain($domain)
461
449
}
462
450
463
451
/**
464
- * @return string
452
+ * @return string|null
465
453
*/
466
454
public function getDomain ()
467
455
{
468
456
return $ this ->domain ;
469
457
}
470
458
471
459
/**
472
- * @param string $path
473
- * @return SetCookie
460
+ * @param string|null $path
461
+ * @return $this
474
462
*/
475
463
public function setPath ($ path )
476
464
{
@@ -480,16 +468,16 @@ public function setPath($path)
480
468
}
481
469
482
470
/**
483
- * @return string
471
+ * @return string|null
484
472
*/
485
473
public function getPath ()
486
474
{
487
475
return $ this ->path ;
488
476
}
489
477
490
478
/**
491
- * @param bool $secure
492
- * @return SetCookie
479
+ * @param bool|null $secure
480
+ * @return $this
493
481
*/
494
482
public function setSecure ($ secure )
495
483
{
@@ -504,7 +492,7 @@ public function setSecure($secure)
504
492
* Set whether the value for this cookie should be quoted
505
493
*
506
494
* @param bool $quotedValue
507
- * @return SetCookie
495
+ * @return $this
508
496
*/
509
497
public function setQuoteFieldValue ($ quotedValue )
510
498
{
@@ -513,16 +501,16 @@ public function setQuoteFieldValue($quotedValue)
513
501
}
514
502
515
503
/**
516
- * @return bool
504
+ * @return bool|null
517
505
*/
518
506
public function isSecure ()
519
507
{
520
508
return $ this ->secure ;
521
509
}
522
510
523
511
/**
524
- * @param bool $httponly
525
- * @return SetCookie
512
+ * @param bool|null $httponly
513
+ * @return $this
526
514
*/
527
515
public function setHttponly ($ httponly )
528
516
{
@@ -534,7 +522,7 @@ public function setHttponly($httponly)
534
522
}
535
523
536
524
/**
537
- * @return bool
525
+ * @return bool|null
538
526
*/
539
527
public function isHttponly ()
540
528
{
@@ -546,7 +534,7 @@ public function isHttponly()
546
534
*
547
535
* Always returns false if the cookie is a session cookie (has no expiry time)
548
536
*
549
- * @param int $now Timestamp to consider as "now"
537
+ * @param int|null $now Timestamp to consider as "now"
550
538
* @return bool
551
539
*/
552
540
public function isExpired ($ now = null )
@@ -582,6 +570,12 @@ public function hasQuoteFieldValue()
582
570
return $ this ->quoteFieldValue ;
583
571
}
584
572
573
+ /**
574
+ * @param string $requestDomain
575
+ * @param string $path
576
+ * @param bool $isSecure
577
+ * @return bool
578
+ */
585
579
public function isValidForRequest ($ requestDomain , $ path , $ isSecure = false )
586
580
{
587
581
if ($ this ->getDomain () && (strrpos ($ requestDomain , $ this ->getDomain ()) === false )) {
@@ -604,7 +598,7 @@ public function isValidForRequest($requestDomain, $path, $isSecure = false)
604
598
*
605
599
* @param string|\Zend\Uri\Uri $uri URI to check against (secure, domain, path)
606
600
* @param bool $matchSessionCookies Whether to send session cookies
607
- * @param int $now Override the current time when checking for expiry time
601
+ * @param int|null $now Override the current time when checking for expiry time
608
602
* @return bool
609
603
* @throws Exception\InvalidArgumentException If URI does not have HTTP or HTTPS scheme.
610
604
*/
@@ -651,7 +645,6 @@ public function match($uri, $matchSessionCookies = true, $now = null)
651
645
*
652
646
* @param string $cookieDomain
653
647
* @param string $host
654
- *
655
648
* @return bool
656
649
*/
657
650
public static function matchCookieDomain ($ cookieDomain , $ host )
@@ -677,11 +670,19 @@ public static function matchCookiePath($cookiePath, $path)
677
670
return (strpos ($ path , $ cookiePath ) === 0 );
678
671
}
679
672
673
+ /**
674
+ * @return string
675
+ */
680
676
public function toString ()
681
677
{
682
678
return 'Set-Cookie: ' . $ this ->getFieldValue ();
683
679
}
684
680
681
+ /**
682
+ * @param array $headers
683
+ * @return string
684
+ * @throws Exception\RuntimeException
685
+ */
685
686
public function toStringMultipleHeaders (array $ headers )
686
687
{
687
688
$ headerLine = $ this ->toString ();
0 commit comments