for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace TomPHP\ConfigServiceProvider;
use Iterator;
use RecursiveArrayIterator;
final class ConfigIterator implements Iterator
{
/**
* @var string[]
*/
private $path = [];
* @var RecursiveArrayIterator
private $stack = [];
private $current;
* @var string
private $separator;
* @param Config $config
public function __construct(Config $config)
$this->separator = $config->getSeparator();
$this->current = new RecursiveArrayIterator($config->asArray());
}
public function current()
return $this->current->current();
public function key()
return implode($this->separator, array_merge($this->path, [$this->current->key()]));
public function next()
if ($this->current->hasChildren()) {
$it = &$this->current;
array_push($this->stack, $it);
array_push($this->path, $it->key());
$this->current = $it->getChildren();
} else {
$this->current->next();
public function rewind()
if (!empty($this->stack)) {
$this->current = array_shift($this->stack);
$this->stack = [];
array()
array
object<RecursiveArrayIterator>
$stack
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
$this->path = [];
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
$this->current->rewind();
public function valid()
if ($this->current->valid()) {
return true;
if (empty($this->stack)) {
return false;
array_pop($this->path);
$this->current = array_pop($this->stack);
return $this->valid();
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..