2
2
3
3
namespace Contributte \Codeception \Http ;
4
4
5
+ use DateTimeInterface ;
5
6
use Nette \Http \Helpers ;
6
7
use Nette \Http \IResponse ;
7
8
use Nette \Utils \DateTime ;
@@ -30,63 +31,51 @@ public function getCode(): int
30
31
}
31
32
32
33
/**
33
- * @param int $code
34
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
34
+ * @return static
35
35
*/
36
- public function setCode ($ code): self
36
+ public function setCode (int $ code, ? string $ reason = null )
37
37
{
38
38
$ this ->code = $ code ;
39
39
return $ this ;
40
40
}
41
41
42
42
/**
43
- * @param string $name
44
- * @param string $value
45
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
43
+ * @return static
46
44
*/
47
- public function setHeader ($ name , $ value ): self
45
+ public function setHeader (string $ name , string $ value )
48
46
{
49
47
$ this ->headers [$ name ] = $ value ;
50
48
return $ this ;
51
49
}
52
50
53
51
/**
54
- * @param string $name
55
- * @param string $value
56
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
52
+ * @return static
57
53
*/
58
- public function addHeader ($ name , $ value ): self
54
+ public function addHeader (string $ name , string $ value )
59
55
{
60
56
$ this ->headers [$ name ] = $ value ;
61
57
return $ this ;
62
58
}
63
59
64
60
/**
65
- * @param string $type
66
- * @param string|null $charset
67
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
61
+ * @return static
68
62
*/
69
- public function setContentType ($ type , $ charset = null ): self
63
+ public function setContentType (string $ type , ? string $ charset = null )
70
64
{
71
65
$ this ->setHeader ('Content-Type ' , $ type . ($ charset !== null ? '; charset= ' . $ charset : '' ));
72
66
return $ this ;
73
67
}
74
68
75
- /**
76
- * @param string $url
77
- * @param int $code
78
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
79
- */
80
- public function redirect ($ url , $ code = self ::S302_FOUND ): void
69
+ public function redirect (string $ url , int $ code = self ::S302_FOUND ): void
81
70
{
82
71
$ this ->setCode ($ code );
83
72
$ this ->setHeader ('Location ' , $ url );
84
73
}
85
74
86
75
/**
87
- * @param string|int|DateTime $time
76
+ * @return static
88
77
*/
89
- public function setExpiration ($ time ): self
78
+ public function setExpiration (? string $ time )
90
79
{
91
80
if (!$ time ) {
92
81
$ this ->setHeader ('Cache-Control ' , 's-maxage=0, max-age=0, must-revalidate ' );
@@ -107,14 +96,9 @@ public function isSent(): bool
107
96
return false ;
108
97
}
109
98
110
- /**
111
- * @param string $name
112
- * @param string|null $default
113
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
114
- */
115
- public function getHeader ($ name , $ default = null ): ?string
99
+ public function getHeader (string $ name ): ?string
116
100
{
117
- return $ this ->headers [$ name ] ?? $ default ;
101
+ return $ this ->headers [$ name ] ?? null ;
118
102
}
119
103
120
104
/**
@@ -126,29 +110,15 @@ public function getHeaders(): array
126
110
}
127
111
128
112
/**
129
- * @param string $name
130
- * @param string $value
131
- * @param string|int|DateTime $time
132
- * @param string|null $path
133
- * @param string|null $domain
134
- * @param bool|null $secure
135
- * @param bool|null $httpOnly
136
- * @param string|null $sameSite
137
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
113
+ * @param string|int|DateTimeInterface $time
114
+ * @return static
138
115
*/
139
- public function setCookie ($ name , $ value , $ time , $ path = null , $ domain = null , $ secure = null , $ httpOnly = null , $ sameSite = null ): self
116
+ public function setCookie (string $ name , string $ value , $ time , ? string $ path = null , ? string $ domain = null , ? bool $ secure = null , ? bool $ httpOnly = null , ? string $ sameSite = null )
140
117
{
141
118
return $ this ;
142
119
}
143
120
144
- /**
145
- * @param string $name
146
- * @param string|null $path
147
- * @param string|null $domain
148
- * @param bool|null $secure
149
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
150
- */
151
- public function deleteCookie ($ name , $ path = null , $ domain = null , $ secure = null ): void
121
+ public function deleteCookie (string $ name , ?string $ path = null , ?string $ domain = null , ?bool $ secure = null ): void
152
122
{
153
123
}
154
124
0 commit comments