for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* This file is part of the Type package.
* For the full copyright information please view the LICENCE file that was
* distributed with this package.
*
* @copyright Simon Deeley 2017
*/
namespace simondeeley\Helpers;
use simondeeley\Exceptions\ImmutableMethodCallException;
* Helper trait to implement immutable arrays
* Implements two basic methods to prevent accidental or implicit modification
* of an arrays properties.
* @author Simon Deeley <[email protected]>
trait ImmutableArrayHelperMethods
{
* Prevent implicit setting of properties
* @see http://php.net/manual/en/arrayaccess.offsetset.php
* @param string $property - Property name to set
* @param mixed $value - Mixed value to set property to
* @return void
* @throws ImmutableMethodCallException - Always throws an exception
final public function offsetSet($property, $value)
$value
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
final public function offsetSet($property, /** @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.
$property
final public function offsetSet(/** @scrutinizer ignore-unused */ $property, $value)
throw new ImmutableMethodCallException;
}
* Prevent implicit unsetting of properties
* @see http://php.net/manual/en/arrayaccess.offsetunset.php
* @param string $property - Property name to unset
final public function offsetUnset($property)
final public function offsetUnset(/** @scrutinizer ignore-unused */ $property)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.