Passed
Push — develop ( 9f153d...55c280 )
by Julien
03:02 queued 02:20
created

lib/SSpkS/Handler/BrowserPackageListHandler.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace SSpkS\Handler;
4
5
use \SSpkS\Output\HtmlOutput;
6
use \SSpkS\Output\UrlFixer;
7
use \SSpkS\Package\PackageFilter;
8
use \SSpkS\Package\PackageFinder;
9
10
class BrowserPackageListHandler extends AbstractHandler
11
{
12
    public function canHandle()
13
    {
14
        return ($_SERVER['REQUEST_METHOD'] == 'GET' && array_key_exists('arch', $_GET) && !empty(trim($_GET['arch'])));
15
    }
16
17
    public function handle()
18
    {
19
        // Architecture is set --> show packages for that arch
20
        $arch     = trim($_GET['arch']);
21
22
        $output = new HtmlOutput($this->config);
23
        $output->setVariable('arch', $arch);
24
25
        $pkgs = new PackageFinder($this->config);
26
        $pkgf = new PackageFilter($this->config, $pkgs->getAllPackages());
27
        $pkgf->setArchitectureFilter($arch);
28
        $pkgf->setFirmwareVersionFilter(false);
29
        $pkgf->setOldVersionFilter(true);
30
        $filteredPkgList = $pkgf->getFilteredPackageList();
31
32
        $uf = new UrlFixer($this->config->baseUrl);
33
        $uf->fixPackageList($filteredPkgList);
34
35
        $packages = array();
36
        foreach ($filteredPkgList as $pkg) {
37
            $pkgMeta = $pkg->getMetadata();
38
            $packages[$pkgMeta['displayname']] = $pkgMeta;
39
        }
40
41
        ksort($packages, SORT_NATURAL | SORT_FLAG_CASE);
42
43
        $output->setVariable('packagelist', array_values($packages));
0 ignored issues
show
array_values($packages) is of type array<integer,?>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44
        $output->setTemplate('html_packagelist');
45
        $output->output();
46
    }
47
}
48