for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace TKuni\PhpNormalizer\Helper;
use Closure;
class DotChainOperator
{
public static function update($arr, $key, $val)
$separatedKeys = explode('.', $key);
if (is_callable($val)) {
self::_v($arr, $separatedKeys, $val);
} else {
self::_v($arr, $separatedKeys, function($in) use ($val) {
$in
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
self::_v($arr, $separatedKeys, function(/** @scrutinizer ignore-unused */ $in) use ($val) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return $val;
});
}
return $arr;
private static function _v(&$arr, array $keys, Closure $filter, $i = 0)
if (empty($keys[$i])) {
$arr = $filter($arr);
return;
$currKey = $keys[$i];
if ($currKey === '*') {
self::_h($arr, $keys, $filter, $i);
self::_v($arr[$currKey], $keys, $filter, $i + 1);
private static function _h(&$arr, array $keys, Closure $filter, $i)
foreach ($arr as &$item) {
self::_v($item, $keys, $filter, $i + 1);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.