jdel /
sspks
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\JsonOutput; |
||
| 6 | use \SSpkS\Output\UrlFixer; |
||
| 7 | use \SSpkS\Package\PackageFinder; |
||
| 8 | use \SSpkS\Package\PackageFilter; |
||
| 9 | |||
| 10 | /* |
||
| 11 | example data passed by a syno |
||
| 12 | |||
| 13 | language = enu |
||
| 14 | timezone = Brussels |
||
| 15 | unique = synology_cedarview_412 |
||
| 16 | arch = cedarview |
||
| 17 | major = 4 |
||
| 18 | minor = 1 |
||
| 19 | build = 2636 |
||
| 20 | package_update_channel = stable |
||
| 21 | |||
| 22 | [package_update_channel] => beta |
||
| 23 | [unique] => synology_avoton_415+ |
||
| 24 | [build] => 7393 |
||
| 25 | [language] => enu |
||
| 26 | [major] => 6 |
||
| 27 | [arch] => avoton |
||
| 28 | [minor] => 0 |
||
| 29 | [timezone] => Amsterdam |
||
| 30 | */ |
||
| 31 | |||
| 32 | // if (isset($_REQUEST['unique']) && substr($_REQUEST['unique'], 0, 8) == 'synology') { |
||
|
0 ignored issues
–
show
|
|||
| 33 | |||
| 34 | class SynologyHandler implements HandlerInterface |
||
| 35 | { |
||
| 36 | private $config; |
||
| 37 | |||
| 38 | public function __construct(\SSpkS\Config $config) |
||
| 39 | { |
||
| 40 | $this->config = $config; |
||
| 41 | } |
||
| 42 | |||
| 43 | public function handle() |
||
| 44 | { |
||
| 45 | // Synology request --> show JSON |
||
| 46 | $language = trim($_REQUEST['language']); |
||
|
0 ignored issues
–
show
$language is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 47 | $timezone = trim($_REQUEST['timezone']); |
||
|
0 ignored issues
–
show
$timezone is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 48 | $arch = trim($_REQUEST['arch']); |
||
| 49 | $major = trim($_REQUEST['major']); |
||
| 50 | $minor = trim($_REQUEST['minor']); |
||
| 51 | $build = trim($_REQUEST['build']); |
||
| 52 | $channel = trim($_REQUEST['package_update_channel']); |
||
| 53 | $unique = trim($_REQUEST['unique']); |
||
|
0 ignored issues
–
show
$unique is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 54 | |||
| 55 | if ($arch == '88f6282') { |
||
| 56 | $arch = '88f6281'; |
||
| 57 | } |
||
| 58 | |||
| 59 | // Make sure, that the "client" knows that output is sent in JSON format |
||
| 60 | header('Content-type: application/json'); |
||
| 61 | $fw_version = $major . '.' . $minor . '.' . $build; |
||
| 62 | $pkgs = new PackageFinder($this->config->paths['packages']); |
||
| 63 | $pkgf = new PackageFilter($pkgs->getAllPackages()); |
||
| 64 | $pkgf->setArchitectureFilter($arch); |
||
| 65 | $pkgf->setChannelFilter($channel); |
||
| 66 | $pkgf->setFirmwareVersionFilter($fw_version); |
||
| 67 | $pkgf->setOldVersionFilter(true); |
||
| 68 | $filteredPkgList = $pkgf->getFilteredPackageList(); |
||
| 69 | |||
| 70 | $uf = new UrlFixer($this->config->baseUrl); |
||
|
0 ignored issues
–
show
The property
baseUrl does not exist on object<SSpkS\Config>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 71 | $uf->fixPackageList($filteredPkgList); |
||
| 72 | |||
| 73 | $jo = new JsonOutput(); |
||
| 74 | $jo->setExcludedServices($this->config->excludedSynoServices); |
||
| 75 | $jo->outputPackages($filteredPkgList); |
||
| 76 | } |
||
| 77 | } |
||
| 78 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.