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

SSpkS/Handler/BrowserAllPackagesListHandler.php (2 issues)

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\Package\PackageFinder;
7
8
class BrowserAllPackagesListHandler extends AbstractHandler
9
{
10
    public function canHandle()
11
    {
12
        return ($_SERVER['REQUEST_METHOD'] == 'GET' && array_key_exists('fulllist', $_GET) && !empty(trim($_GET['fulllist'])));
13
    }
14
15
    public function handle()
16
    {
17
        // No architecture, but full list of packages requested --> show simple list
18
        $output = new HtmlOutput($this->config);
19
20
        $pkgs = new PackageFinder($this->config);
21
        $packagesList = $pkgs->getAllPackageFiles();
22
23
        // Prepare data for template
24
        $packages = array();
25
        foreach ($packagesList as $spkFile) {
26
            $packages[basename($spkFile)] = array(
27
                'url'      => $this->config->baseUrl . $spkFile,
28
                'filename' => basename($spkFile),
29
            );
30
        }
31
        ksort($packages, SORT_NATURAL | SORT_FLAG_CASE);
32
        $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...
33
        $output->setVariable('fullList', true);
0 ignored issues
show
true is of type boolean, 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...
34
        $output->setTemplate('html_packagelist_all');
35
        $output->output();
36
    }
37
}
38