for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Webino™ (http://webino.sk)
*
* @link https://github.com/webino/request
* @copyright Copyright (c) 2019 Webino, s.r.o. (http://webino.sk)
* @author Peter Bačinský <[email protected]>
* @license BSD-3-Clause
*/
namespace Webino;
* Trait RequestContextTrait
* @package request
trait RequestContextTrait
{
* @var array
private $params;
* @return array
abstract protected function createParams(): array;
protected function getParams(): array
$this->params or $this->params = $this->createParams();
return $this->params;
}
* @param array $params
protected function setParams(array $params): void
$this->params = $params;
* @param string $offset
* @return bool
public function offsetExists($offset)
return array_key_exists((string) $offset, $this->getParams());
* @return mixed
public function offsetGet($offset)
return $this->offsetExists($offset) ? $this->getParams()[(string) $offset] : null;
* @param mixed $value
public function offsetSet($offset, $value)
$value
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function offsetSet($offset, /** @scrutinizer ignore-unused */ $value)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$offset
public function offsetSet(/** @scrutinizer ignore-unused */ $offset, $value)
// read-only
public function offsetUnset($offset)
public function offsetUnset(/** @scrutinizer ignore-unused */ $offset)
public function toArray(): array
return (array) $this->getParams();
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.