GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (149)

src/Response/CsvResponse.php (5 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusReportPlugin\Response;
6
7
use Odiseo\SyliusReportPlugin\DataFetcher\Data;
8
use Symfony\Component\HttpFoundation\Response;
9
10
class CsvResponse extends Response
11
{
12
13
    protected ?string $data = null;
14
    protected string $filename = 'export.csv';
15
16
    public function __construct(?Data $data = null, int $status = 200, array $headers = [])
17
    {
18
        parent::__construct('', $status, $headers);
19
        $this->setData($data);
0 ignored issues
show
It seems like $data can also be of type null; however, parameter $data of Odiseo\SyliusReportPlugi...\CsvResponse::setData() does only seem to accept Odiseo\SyliusReportPlugin\DataFetcher\Data, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

19
        $this->setData(/** @scrutinizer ignore-type */ $data);
Loading history...
20
    }
21
22
    public static function create(?Data $data = null, int $status = 200, array $headers = [])
23
    {
24
        return new static($labels, $data, $status, $headers);
0 ignored issues
show
The call to Odiseo\SyliusReportPlugi...Response::__construct() has too many arguments starting with $headers. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return /** @scrutinizer ignore-call */ new static($labels, $data, $status, $headers);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
$status of type integer is incompatible with the type array expected by parameter $headers of Odiseo\SyliusReportPlugi...Response::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

24
        return new static($labels, $data, /** @scrutinizer ignore-type */ $status, $headers);
Loading history...
$data of type Odiseo\SyliusReportPlugin\DataFetcher\Data|null is incompatible with the type integer expected by parameter $status of Odiseo\SyliusReportPlugi...Response::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

24
        return new static($labels, /** @scrutinizer ignore-type */ $data, $status, $headers);
Loading history...
Comprehensibility Best Practice introduced by
The variable $labels seems to be never defined.
Loading history...
25
    }
26
27
    public function setData(Data $data): self
28
    {
29
        $output = fopen('php://temp', 'r+');
30
31
        if ($output === false) {
32
            throw new \RuntimeException('Could not create a buffer for CSV output.');
33
        }
34
35
        foreach ($data->getData() as $row) {
36
            fputcsv($output, $row);
37
        }
38
39
        rewind($output);
40
        $this->data = '';
41
42
        while ($line = fgets($output)) {
43
            $this->data .= $line;
44
        }
45
46
        $this->data .= fgets($output);
47
48
        return $this->update();
49
    }
50
51
    public function getFilename(): string
52
    {
53
        return $this->filename;
54
    }
55
56
    public function setFilename(string $filename): self
57
    {
58
        $this->filename = $filename;
59
60
        return $this->update();
61
    }
62
63
    protected function update(): self
64
    {
65
        $this->headers->set('Content-Disposition', sprintf('attachment; filename="%s"', $this->filename));
66
        if (!$this->headers->has('Content-Type')) {
67
            $this->headers->set('Content-Type', 'text/csv');
68
        }
69
70
        return $this->setContent($this->data);
71
    }
72
}
73