Skip to content

Commit e293296

Browse files
alongoszSteveb-p
andcommitted
Improved code quality
Co-Authored-By: Paweł Niedzielski <[email protected]>
1 parent 298aeab commit e293296

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/bundle/Core/Fragment/DecoratedFragmentRenderer.php

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
class DecoratedFragmentRenderer implements FragmentRendererInterface, SiteAccessAware
1919
{
20-
/** @var \Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface */
2120
private FragmentRendererInterface $innerRenderer;
2221

2322
private ?SiteAccess $siteAccess;

src/bundle/Core/Routing/DefaultRouter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class DefaultRouter extends Router implements SiteAccessAware
2626
{
27-
protected ?SiteAccess $siteAccess;
27+
protected ?SiteAccess $siteAccess = null;
2828

2929
/** @var string[] */
3030
protected array $nonSiteAccessAwareRoutes = [];
@@ -80,7 +80,7 @@ public function matchRequest(Request $request): array
8080
*/
8181
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
8282
{
83-
$siteAccess = $this->siteAccess ?? null;
83+
$siteAccess = $this->siteAccess;
8484
$originalContext = $context = $this->getContext();
8585
$isSiteAccessAware = $this->isSiteAccessAwareRoute($name);
8686

src/bundle/IO/BinaryStreamResponse.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function __construct(
5656

5757
/**
5858
* @phpstan-param \Symfony\Component\HttpFoundation\ResponseHeaderBag::DISPOSITION_*|null $contentDisposition
59+
*
60+
* @return $this
5961
*/
6062
public function setFile(BinaryFile $file, ?string $contentDisposition = null, bool $autoLastModified = true): static
6163
{
@@ -79,6 +81,8 @@ public function getFile(): BinaryFile
7981

8082
/**
8183
* Automatically sets the Last-Modified header according the file modification date.
84+
*
85+
* @return $this
8286
*/
8387
public function setAutoLastModified(): static
8488
{
@@ -94,6 +98,8 @@ public function setAutoLastModified(): static
9498
*
9599
* @param string $filename Optionally use this filename instead of the real name of the file
96100
* @param string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename
101+
*
102+
* @return $this
97103
*/
98104
public function setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = ''): BinaryStreamResponse
99105
{
@@ -111,6 +117,9 @@ public function setContentDisposition(string $disposition, string $filename = ''
111117
return $this;
112118
}
113119

120+
/**
121+
* @return $this
122+
*/
114123
public function prepare(Request $request): static
115124
{
116125
$this->headers->set('Content-Length', (string)$this->file->size);
@@ -144,6 +153,8 @@ public function prepare(Request $request): static
144153
* Sends the file.
145154
*
146155
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
156+
*
157+
* @return $this
147158
*/
148159
public function sendContent(): static
149160
{
@@ -170,6 +181,8 @@ public function sendContent(): static
170181

171182
/**
172183
* @throws \LogicException when the content is not null
184+
*
185+
* @return $this
173186
*/
174187
public function setContent(?string $content): static
175188
{
@@ -216,12 +229,12 @@ private function processRangeRequest(Request $request): void
216229
if ($start < 0 || $end > $fileSize - 1) {
217230
$this->setStatusCode(
218231
Response::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
219-
); // HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
232+
);
220233
} elseif ($start !== 0 || $end !== $fileSize - 1) {
221234
$this->maxlen = $end < $fileSize ? $end - $start + 1 : -1;
222235
$this->offset = $start;
223236

224-
$this->setStatusCode(Response::HTTP_PARTIAL_CONTENT); // HTTP_PARTIAL_CONTENT
237+
$this->setStatusCode(Response::HTTP_PARTIAL_CONTENT);
225238
$this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize));
226239
$this->headers->set('Content-Length', $end - $start + 1);
227240
}

0 commit comments

Comments
 (0)