for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
use html_go\exceptions\InternalException;
use html_go\model\Config;
require_once ADMIN_SYS_ROOT.DS.'functions.php';
function admin_route(string $uri, string $method = HTTP_GET): ?\stdClass {
$context = get_config()->getString(Config::KEY_ADMIN_CONTEXT);
if (\str_starts_with($uri, $context) === false) {
return null;
}
switch ($method) {
case HTTP_GET:
$content = admin_process_get_request($context, $uri);
break;
case HTTP_POST:
$content = admin_process_post_request($uri);
$content
admin_process_post_request($uri)
null
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
class A { function getObject() { return null; } } $a = new A(); $object = $a->getObject();
The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
default:
throw new InternalException("Unsupported HTTP Method [$method]");
return $content;
function admin_process_get_request(string $context, string $uri): ?\stdClass {
$resource = \substr($uri, \strlen($context));
$i18n = get_i18n();
$pageTitle = $i18n->getText('admin.title.prefix').$i18n->getText('admin.dashboard.title');
if ($resource === DASHBOARD_INDEX_KEY) {
$content = get_admin_content_object('dashboard.html', title: $pageTitle);
function admin_process_post_request(string $uri): ?\stdClass {
$uri
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
function admin_process_post_request(/** @scrutinizer ignore-unused */ string $uri): ?\stdClass {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.