Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e769d1

Browse files
Add return types - batch 3/n
1 parent 9004e35 commit 7e769d1

File tree

103 files changed

+439
-615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+439
-615
lines changed

src/Symfony/Component/HttpFoundation/AcceptHeader.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(array $items)
4949
*
5050
* @return self
5151
*/
52-
public static function fromString(?string $headerValue)
52+
public static function fromString(?string $headerValue): self
5353
{
5454
$index = 0;
5555

@@ -76,20 +76,16 @@ public function __toString(): string
7676

7777
/**
7878
* Tests if header has given value.
79-
*
80-
* @return bool
8179
*/
82-
public function has(string $value)
80+
public function has(string $value): bool
8381
{
8482
return isset($this->items[$value]);
8583
}
8684

8785
/**
8886
* Returns given value's item, if exists.
89-
*
90-
* @return AcceptHeaderItem|null
9187
*/
92-
public function get(string $value)
88+
public function get(string $value): ?AcceptHeaderItem
9389
{
9490
return $this->items[$value] ?? $this->items[explode('/', $value)[0].'/*'] ?? $this->items['*/*'] ?? $this->items['*'] ?? null;
9591
}
@@ -99,7 +95,7 @@ public function get(string $value)
9995
*
10096
* @return $this
10197
*/
102-
public function add(AcceptHeaderItem $item)
98+
public function add(AcceptHeaderItem $item): static
10399
{
104100
$this->items[$item->getValue()] = $item;
105101
$this->sorted = false;
@@ -112,7 +108,7 @@ public function add(AcceptHeaderItem $item)
112108
*
113109
* @return AcceptHeaderItem[]
114110
*/
115-
public function all()
111+
public function all(): array
116112
{
117113
$this->sort();
118114

@@ -124,7 +120,7 @@ public function all()
124120
*
125121
* @return self
126122
*/
127-
public function filter(string $pattern)
123+
public function filter(string $pattern): self
128124
{
129125
return new self(array_filter($this->items, function (AcceptHeaderItem $item) use ($pattern) {
130126
return preg_match($pattern, $item->getValue());
@@ -133,10 +129,8 @@ public function filter(string $pattern)
133129

134130
/**
135131
* Returns first item.
136-
*
137-
* @return AcceptHeaderItem|null
138132
*/
139-
public function first()
133+
public function first(): ?AcceptHeaderItem
140134
{
141135
$this->sort();
142136

src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(string $value, array $attributes = [])
3636
*
3737
* @return self
3838
*/
39-
public static function fromString(?string $itemValue)
39+
public static function fromString(?string $itemValue): self
4040
{
4141
$parts = HeaderUtils::split($itemValue ?? '', ';=');
4242

@@ -64,7 +64,7 @@ public function __toString(): string
6464
*
6565
* @return $this
6666
*/
67-
public function setValue(string $value)
67+
public function setValue(string $value): static
6868
{
6969
$this->value = $value;
7070

@@ -73,10 +73,8 @@ public function setValue(string $value)
7373

7474
/**
7575
* Returns the item value.
76-
*
77-
* @return string
7876
*/
79-
public function getValue()
77+
public function getValue(): string
8078
{
8179
return $this->value;
8280
}
@@ -86,7 +84,7 @@ public function getValue()
8684
*
8785
* @return $this
8886
*/
89-
public function setQuality(float $quality)
87+
public function setQuality(float $quality): static
9088
{
9189
$this->quality = $quality;
9290

@@ -95,10 +93,8 @@ public function setQuality(float $quality)
9593

9694
/**
9795
* Returns the item quality.
98-
*
99-
* @return float
10096
*/
101-
public function getQuality()
97+
public function getQuality(): float
10298
{
10399
return $this->quality;
104100
}
@@ -108,7 +104,7 @@ public function getQuality()
108104
*
109105
* @return $this
110106
*/
111-
public function setIndex(int $index)
107+
public function setIndex(int $index): static
112108
{
113109
$this->index = $index;
114110

@@ -117,40 +113,32 @@ public function setIndex(int $index)
117113

118114
/**
119115
* Returns the item index.
120-
*
121-
* @return int
122116
*/
123-
public function getIndex()
117+
public function getIndex(): int
124118
{
125119
return $this->index;
126120
}
127121

128122
/**
129123
* Tests if an attribute exists.
130-
*
131-
* @return bool
132124
*/
133-
public function hasAttribute(string $name)
125+
public function hasAttribute(string $name): bool
134126
{
135127
return isset($this->attributes[$name]);
136128
}
137129

138130
/**
139131
* Returns an attribute by its name.
140-
*
141-
* @return mixed
142132
*/
143-
public function getAttribute(string $name, mixed $default = null)
133+
public function getAttribute(string $name, mixed $default = null): mixed
144134
{
145135
return $this->attributes[$name] ?? $default;
146136
}
147137

148138
/**
149139
* Returns all attributes.
150-
*
151-
* @return array
152140
*/
153-
public function getAttributes()
141+
public function getAttributes(): array
154142
{
155143
return $this->attributes;
156144
}
@@ -160,7 +148,7 @@ public function getAttributes()
160148
*
161149
* @return $this
162150
*/
163-
public function setAttribute(string $name, string $value)
151+
public function setAttribute(string $name, string $value): static
164152
{
165153
if ('q' === $name) {
166154
$this->quality = (float) $value;

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(\SplFileInfo|string $file, int $status = 200, array
6262
*
6363
* @throws FileException
6464
*/
65-
public function setFile(\SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
65+
public function setFile(\SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): static
6666
{
6767
if (!$file instanceof File) {
6868
if ($file instanceof \SplFileInfo) {
@@ -98,7 +98,7 @@ public function setFile(\SplFileInfo|string $file, string $contentDisposition =
9898
*
9999
* @return File The file to stream
100100
*/
101-
public function getFile()
101+
public function getFile(): File
102102
{
103103
return $this->file;
104104
}
@@ -132,7 +132,7 @@ public function setAutoEtag()
132132
*
133133
* @return $this
134134
*/
135-
public function setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = '')
135+
public function setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = ''): static
136136
{
137137
if ('' === $filename) {
138138
$filename = $this->file->getFilename();
@@ -161,7 +161,7 @@ public function setContentDisposition(string $disposition, string $filename = ''
161161
/**
162162
* {@inheritdoc}
163163
*/
164-
public function prepare(Request $request)
164+
public function prepare(Request $request): static
165165
{
166166
if (!$this->headers->has('Content-Type')) {
167167
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
@@ -269,7 +269,7 @@ private function hasValidIfRangeHeader(?string $header): bool
269269
*
270270
* {@inheritdoc}
271271
*/
272-
public function sendContent()
272+
public function sendContent(): static
273273
{
274274
if (!$this->isSuccessful()) {
275275
return parent::sendContent();
@@ -299,7 +299,7 @@ public function sendContent()
299299
*
300300
* @throws \LogicException when the content is not null
301301
*/
302-
public function setContent(?string $content)
302+
public function setContent(?string $content): static
303303
{
304304
if (null !== $content) {
305305
throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.');
@@ -311,7 +311,7 @@ public function setContent(?string $content)
311311
/**
312312
* {@inheritdoc}
313313
*/
314-
public function getContent()
314+
public function getContent(): string|false
315315
{
316316
return false;
317317
}
@@ -330,7 +330,7 @@ public static function trustXSendfileTypeHeader()
330330
*
331331
* @return $this
332332
*/
333-
public function deleteFileAfterSend(bool $shouldDelete = true)
333+
public function deleteFileAfterSend(bool $shouldDelete = true): static
334334
{
335335
$this->deleteFileAfterSend = $shouldDelete;
336336

0 commit comments

Comments
 (0)