src/Mouf/MoufManager.php
private function walkConstructorLoop($instanceName, array $path) {
	    if(isset($path[$instanceName])) {
	        $instances = array_keys($path);
	        $instances = array_slice($instances, array_search($instanceName, $instances));
	        throw new MoufContainerException('A loop was detected on constructor arguments '.implode(' -> ', $instances).' -> '.$instanceName);
	    }
	    $path[$instanceName] = true;
	    $descriptor = $this->declaredInstances[$instanceName];
	    if(isset($descriptor['constructor'])) {
    	    foreach ($descriptor['constructor'] as $constructorArg) {
    	        if($constructorArg['parametertype'] == 'object') {
    	            if(is_array($constructorArg['value'])) {
    	                foreach ($constructorArg['value'] as $subInstanceName) {
    	                    if($subInstanceName !== null) {
    	                        $this->walkConstructorLoop($subInstanceName, $path);
    	                    }
    	                }
    	            }
    	            else {
    	            	if($constructorArg['value'] !== null) {
    	                    $this->walkConstructorLoop($constructorArg['value'], $path);
    	            	}
    	            }
    	        }
    	    }
	    }
	}
private function walkConstructorLoop($instanceName, array $path) {
	    if(isset($path[$instanceName])) {
	        $instances = array_keys($path);
	        $instances = array_slice($instances, array_search($instanceName, $instances));
	        throw new MoufContainerException('A loop was detected on constructor arguments '.implode(' -> ', $instances).' -> '.$instanceName);
	    }
	    $path[$instanceName] = true;
	    $descriptor = $this->declaredInstances[$instanceName];
	    if(isset($descriptor['constructor'])) {
    	    foreach ($descriptor['constructor'] as $constructorArg) {
    	        if($constructorArg['parametertype'] == 'object') {
    	            if(is_array($constructorArg['value'])) {
    	                foreach ($constructorArg['value'] as $subInstanceName) {
    	                    if($subInstanceName !== null) {
    	                        $this->walkConstructorLoop($subInstanceName, $path);
    	                    }
    	                }
    	            }
    	            else {
    	            	if($constructorArg['value'] !== null) {
    	                    $this->walkConstructorLoop($constructorArg['value'], $path);
    	            	}
    	            }
    	        }
    	    }
	    }
	}
private function walkConstructorLoop ( $ instanceName , array $ path ) { if ( isset ( $ path [ $ instanceName ] ) ) { $ instances = array_keys ( $ path ) ; $ instances = array_slice ( $ instances , array_search ( $ instanceName , $ instances ) ) ; throw new MoufContainerException ( 'A loop was detected on constructor arguments ' . implode ( ' -> ' , $ instances ) . ' -> ' . $ instanceName ) ; } $ path [ $ instanceName ] = true ; $ descriptor = $ this -> declaredInstances [ $ instanceName ] ; if ( isset ( $ descriptor [ 'constructor' ] ) ) { foreach ( $ descriptor [ 'constructor' ] as $ constructorArg ) { if ( $ constructorArg [ 'parametertype' ] == 'object' ) { if ( is_array ( $ constructorArg [ 'value' ] ) ) { foreach ( $ constructorArg [ 'value' ] as $ subInstanceName ) { if ( $ subInstanceName !== null ) { $ this -> walkConstructorLoop ( $ subInstanceName , $ path ) ; } } } else { if ( $ constructorArg [ 'value' ] !== null ) { $ this -> walkConstructorLoop ( $ constructorArg [ 'value' ] , $ path ) ; } } } } } }
This take a instance name and the path to access.
It throw an exception if a loop was detected

@param string $instanceName
@param array $path
@throws MoufContainerException
This take a instance name and the path to access . It throw an exception if a loop was detected