Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dbe0e37

Browse filesBrowse files
julien57azjezz
julien57
authored andcommitted
add type-hints
1 parent 547b9b8 commit dbe0e37
Copy full SHA for dbe0e37

38 files changed

+176
-272
lines changed

‎src/Symfony/Component/HttpFoundation/AcceptHeader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/AcceptHeader.php
+5-13Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@ public function __construct(array $items)
4444
/**
4545
* Builds an AcceptHeader instance from a string.
4646
*
47-
* @param string $headerValue
48-
*
4947
* @return self
5048
*/
51-
public static function fromString($headerValue)
49+
public static function fromString(string $headerValue)
5250
{
5351
$index = 0;
5452

55-
$parts = HeaderUtils::split((string) $headerValue, ',;=');
53+
$parts = HeaderUtils::split($headerValue, ',;=');
5654

5755
return new self(array_map(function ($subParts) use (&$index) {
5856
$part = array_shift($subParts);
@@ -78,23 +76,19 @@ public function __toString()
7876
/**
7977
* Tests if header has given value.
8078
*
81-
* @param string $value
82-
*
8379
* @return bool
8480
*/
85-
public function has($value)
81+
public function has(string $value)
8682
{
8783
return isset($this->items[$value]);
8884
}
8985

9086
/**
9187
* Returns given value's item, if exists.
9288
*
93-
* @param string $value
94-
*
9589
* @return AcceptHeaderItem|null
9690
*/
97-
public function get($value)
91+
public function get(string $value)
9892
{
9993
return $this->items[$value] ?? $this->items[explode('/', $value)[0].'/*'] ?? $this->items['*/*'] ?? $this->items['*'] ?? null;
10094
}
@@ -127,11 +121,9 @@ public function all()
127121
/**
128122
* Filters items on their value using given regex.
129123
*
130-
* @param string $pattern
131-
*
132124
* @return self
133125
*/
134-
public function filter($pattern)
126+
public function filter(string $pattern)
135127
{
136128
return new self(array_filter($this->items, function (AcceptHeaderItem $item) use ($pattern) {
137129
return preg_match($pattern, $item->getValue());

‎src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php
+7-18Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ public function __construct(string $value, array $attributes = [])
3434
/**
3535
* Builds an AcceptHeaderInstance instance from a string.
3636
*
37-
* @param string $itemValue
38-
*
3937
* @return self
4038
*/
41-
public static function fromString($itemValue)
39+
public static function fromString(string $itemValue)
4240
{
4341
$parts = HeaderUtils::split($itemValue, ';=');
4442

@@ -66,11 +64,9 @@ public function __toString()
6664
/**
6765
* Set the item value.
6866
*
69-
* @param string $value
70-
*
7167
* @return $this
7268
*/
73-
public function setValue($value)
69+
public function setValue(string $value)
7470
{
7571
$this->value = $value;
7672

@@ -90,11 +86,9 @@ public function getValue()
9086
/**
9187
* Set the item quality.
9288
*
93-
* @param float $quality
94-
*
9589
* @return $this
9690
*/
97-
public function setQuality($quality)
91+
public function setQuality(float $quality)
9892
{
9993
$this->quality = $quality;
10094

@@ -114,11 +108,9 @@ public function getQuality()
114108
/**
115109
* Set the item index.
116110
*
117-
* @param int $index
118-
*
119111
* @return $this
120112
*/
121-
public function setIndex($index)
113+
public function setIndex(int $index)
122114
{
123115
$this->index = $index;
124116

@@ -138,11 +130,9 @@ public function getIndex()
138130
/**
139131
* Tests if an attribute exists.
140132
*
141-
* @param string $name
142-
*
143133
* @return bool
144134
*/
145-
public function hasAttribute($name)
135+
public function hasAttribute(string $name)
146136
{
147137
return isset($this->attributes[$name]);
148138
}
@@ -155,7 +145,7 @@ public function hasAttribute($name)
155145
*
156146
* @return mixed
157147
*/
158-
public function getAttribute($name, $default = null)
148+
public function getAttribute(string $name, $default = null)
159149
{
160150
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
161151
}
@@ -173,12 +163,11 @@ public function getAttributes()
173163
/**
174164
* Set an attribute.
175165
*
176-
* @param string $name
177166
* @param string $value
178167
*
179168
* @return $this
180169
*/
181-
public function setAttribute($name, $value)
170+
public function setAttribute(string $name, $value)
182171
{
183172
if ('q' === $name) {
184173
$this->quality = (float) $value;

‎src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct($file, int $status = 200, array $headers = [], bool
6666
*
6767
* @return static
6868
*/
69-
public static function create($file = null, $status = 200, $headers = [], $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
69+
public static function create($file = null, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
7070
{
7171
return new static($file, $status, $headers, $public, $contentDisposition, $autoEtag, $autoLastModified);
7272
}
@@ -83,7 +83,7 @@ public static function create($file = null, $status = 200, $headers = [], $publi
8383
*
8484
* @throws FileException
8585
*/
86-
public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
86+
public function setFile($file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
8787
{
8888
if (!$file instanceof File) {
8989
if ($file instanceof \SplFileInfo) {
@@ -153,7 +153,7 @@ public function setAutoEtag()
153153
*
154154
* @return $this
155155
*/
156-
public function setContentDisposition($disposition, $filename = '', $filenameFallback = '')
156+
public function setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = '')
157157
{
158158
if ('' === $filename) {
159159
$filename = $this->file->getFilename();
@@ -346,11 +346,9 @@ public static function trustXSendfileTypeHeader()
346346
* If this is set to true, the file will be unlinked after the request is send
347347
* Note: If the X-Sendfile header is used, the deleteFileAfterSend setting will not be used.
348348
*
349-
* @param bool $shouldDelete
350-
*
351349
* @return $this
352350
*/
353-
public function deleteFileAfterSend($shouldDelete = true)
351+
public function deleteFileAfterSend(bool $shouldDelete = true)
354352
{
355353
$this->deleteFileAfterSend = $shouldDelete;
356354

‎src/Symfony/Component/HttpFoundation/Cookie.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Cookie.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ class Cookie
3636
/**
3737
* Creates cookie from raw header string.
3838
*
39-
* @param string $cookie
40-
* @param bool $decode
41-
*
4239
* @return static
4340
*/
44-
public static function fromString($cookie, $decode = false)
41+
public static function fromString(string $cookie, bool $decode = false)
4542
{
4643
$data = [
4744
'expires' => 0,

‎src/Symfony/Component/HttpFoundation/File/File.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/File/File.php
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,11 @@ public function getMimeType()
7676
/**
7777
* Moves the file to a new location.
7878
*
79-
* @param string $directory The destination folder
80-
* @param string $name The new file name
81-
*
8279
* @return self A File object representing the new file
8380
*
8481
* @throws FileException if the target file could not be created
8582
*/
86-
public function move($directory, $name = null)
83+
public function move(string $directory, string $name = null)
8784
{
8885
$target = $this->getTargetFile($directory, $name);
8986

@@ -121,7 +118,7 @@ protected function getTargetFile($directory, $name = null)
121118
*
122119
* @return string containing
123120
*/
124-
protected function getName($name)
121+
protected function getName(string $name)
125122
{
126123
$originalName = str_replace('\\', '/', $name);
127124
$pos = strrpos($originalName, '/');

‎src/Symfony/Component/HttpFoundation/File/UploadedFile.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/File/UploadedFile.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ public function isValid()
164164
/**
165165
* Moves the file to a new location.
166166
*
167-
* @param string $directory The destination folder
168-
* @param string $name The new file name
167+
* @param string $directory The destination folder
168+
* @param string|null $name The new file name
169169
*
170170
* @return File A File object representing the new file
171171
*
172172
* @throws FileException if, for any reason, the file could not have been moved
173173
*/
174-
public function move($directory, $name = null)
174+
public function move(string $directory, string $name = null)
175175
{
176176
if ($this->isValid()) {
177177
if ($this->test) {

‎src/Symfony/Component/HttpFoundation/FileBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/FileBag.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function replace(array $files = [])
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function set($key, $value)
46+
public function set(string $key, $value)
4747
{
4848
if (!\is_array($value) && !$value instanceof UploadedFile) {
4949
throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');

‎src/Symfony/Component/HttpFoundation/HeaderBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/HeaderBag.php
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function add(array $headers)
114114
*
115115
* @return string|null The first header value or default value
116116
*/
117-
public function get($key, $default = null)
117+
public function get(string $key, string $default = null)
118118
{
119119
$headers = $this->all((string) $key);
120120

@@ -128,7 +128,7 @@ public function get($key, $default = null)
128128
* @param string|string[] $values The value or an array of values
129129
* @param bool $replace Whether to replace the actual value or not (true by default)
130130
*/
131-
public function set($key, $values, $replace = true)
131+
public function set(string $key, $values, bool $replace = true)
132132
{
133133
$key = str_replace('_', '-', strtolower($key));
134134

@@ -160,7 +160,7 @@ public function set($key, $values, $replace = true)
160160
*
161161
* @return bool true if the parameter exists, false otherwise
162162
*/
163-
public function has($key)
163+
public function has(string $key)
164164
{
165165
return \array_key_exists(str_replace('_', '-', strtolower($key)), $this->all());
166166
}
@@ -173,7 +173,7 @@ public function has($key)
173173
*
174174
* @return bool true if the value is contained in the header, false otherwise
175175
*/
176-
public function contains($key, $value)
176+
public function contains(string $key, string $value)
177177
{
178178
return \in_array($value, $this->all((string) $key));
179179
}
@@ -183,7 +183,7 @@ public function contains($key, $value)
183183
*
184184
* @param string $key The HTTP header name
185185
*/
186-
public function remove($key)
186+
public function remove(string $key)
187187
{
188188
$key = str_replace('_', '-', strtolower($key));
189189

@@ -204,7 +204,7 @@ public function remove($key)
204204
*
205205
* @throws \RuntimeException When the HTTP header is not parseable
206206
*/
207-
public function getDate($key, \DateTime $default = null)
207+
public function getDate(string $key, \DateTime $default = null)
208208
{
209209
if (null === $value = $this->get($key)) {
210210
return $default;
@@ -223,7 +223,7 @@ public function getDate($key, \DateTime $default = null)
223223
* @param string $key The Cache-Control directive name
224224
* @param mixed $value The Cache-Control directive value
225225
*/
226-
public function addCacheControlDirective($key, $value = true)
226+
public function addCacheControlDirective(string $key, $value = true)
227227
{
228228
$this->cacheControl[$key] = $value;
229229

@@ -237,7 +237,7 @@ public function addCacheControlDirective($key, $value = true)
237237
*
238238
* @return bool true if the directive exists, false otherwise
239239
*/
240-
public function hasCacheControlDirective($key)
240+
public function hasCacheControlDirective(string $key)
241241
{
242242
return \array_key_exists($key, $this->cacheControl);
243243
}
@@ -249,7 +249,7 @@ public function hasCacheControlDirective($key)
249249
*
250250
* @return mixed|null The directive value if defined, null otherwise
251251
*/
252-
public function getCacheControlDirective($key)
252+
public function getCacheControlDirective(string $key)
253253
{
254254
return \array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null;
255255
}
@@ -259,7 +259,7 @@ public function getCacheControlDirective($key)
259259
*
260260
* @param string $key The Cache-Control directive
261261
*/
262-
public function removeCacheControlDirective($key)
262+
public function removeCacheControlDirective(string $key)
263263
{
264264
unset($this->cacheControl[$key]);
265265

@@ -300,7 +300,7 @@ protected function getCacheControlHeader()
300300
*
301301
* @return array An array representing the attribute values
302302
*/
303-
protected function parseCacheControl($header)
303+
protected function parseCacheControl(string $header)
304304
{
305305
$parts = HeaderUtils::split($header, ',=');
306306

‎src/Symfony/Component/HttpFoundation/IpUtils.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/IpUtils.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private function __construct()
3535
*
3636
* @return bool Whether the IP is valid
3737
*/
38-
public static function checkIp($requestIp, $ips)
38+
public static function checkIp(string $requestIp, $ips)
3939
{
4040
if (!\is_array($ips)) {
4141
$ips = [$ips];
@@ -61,7 +61,7 @@ public static function checkIp($requestIp, $ips)
6161
*
6262
* @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet
6363
*/
64-
public static function checkIp4($requestIp, $ip)
64+
public static function checkIp4(string $requestIp, string $ip)
6565
{
6666
$cacheKey = $requestIp.'-'.$ip;
6767
if (isset(self::$checkedIps[$cacheKey])) {
@@ -109,7 +109,7 @@ public static function checkIp4($requestIp, $ip)
109109
*
110110
* @throws \RuntimeException When IPV6 support is not enabled
111111
*/
112-
public static function checkIp6($requestIp, $ip)
112+
public static function checkIp6(string $requestIp, string $ip)
113113
{
114114
$cacheKey = $requestIp.'-'.$ip;
115115
if (isset(self::$checkedIps[$cacheKey])) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.