for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Router\Generator\Traits;
use Nip\Router\RequestContext;
/**
* Trait HasPreviousUrlTrait
* @package Nip\Router\Generator\Traits
* @method RequestContext getContext()
*/
trait HasPreviousUrlTrait
{
* Get the URL for the previous request.
*
* @param mixed $fallback
* @return string
public function previous($fallback = false)
$referrer = $this->getContext()->getHeaders()->get('referer');
$url = $referrer ? $this->to($referrer) : $this->getPreviousUrlFromSession();
$this->getPreviousUrlFromSession()
Nip\Router\Generator\Tra...reviousUrlFromSession()
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
to()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$url = $referrer ? $this->/** @scrutinizer ignore-call */ to($referrer) : $this->getPreviousUrlFromSession();
if ($url) {
return $url;
} elseif ($fallback) {
return $this->to($fallback);
} else {
return $this->to('/');
}
* Get the previous URL from the session if possible.
* @return string|null
protected function getPreviousUrlFromSession()
return null;
// $session = $this->getSession();
// return $session ? $session->previousUrl() : null;
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.