src/Composer/Command/ConfigCommand.php
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
    {
        $origK = $k;
        foreach ($contents as $key => $value) {
            if ($k === null && !in_array($key, array('config', 'repositories'))) {
                continue;
            }

            $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;

            if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
                $k .= preg_replace('{^config\.}', '', $key . '.');
                $this->listConfiguration($value, $rawVal, $output, $k);

                if (substr_count($k, '.') > 1) {
                    $k = str_split($k, strrpos($k, '.', -2));
                    $k = $k[0] . '.';
                } else {
                    $k = $origK;
                }

                continue;
            }

            if (is_array($value)) {
                $value = array_map(function ($val) {
                    return is_array($val) ? json_encode($val) : $val;
                }, $value);

                $value = '['.implode(', ', $value).']';
            }

            if (is_bool($value)) {
                $value = var_export($value, true);
            }

            if (is_string($rawVal) && $rawVal != $value) {
                $this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
            } else {
                $this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
            }
        }
    }
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
    {
        $origK = $k;
        foreach ($contents as $key => $value) {
            if ($k === null && !in_array($key, array('config', 'repositories'))) {
                continue;
            }

            $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;

            if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
                $k .= preg_replace('{^config\.}', '', $key . '.');
                $this->listConfiguration($value, $rawVal, $output, $k);

                if (substr_count($k, '.') > 1) {
                    $k = str_split($k, strrpos($k, '.', -2));
                    $k = $k[0] . '.';
                } else {
                    $k = $origK;
                }

                continue;
            }

            if (is_array($value)) {
                $value = array_map(function ($val) {
                    return is_array($val) ? json_encode($val) : $val;
                }, $value);

                $value = '['.implode(', ', $value).']';
            }

            if (is_bool($value)) {
                $value = var_export($value, true);
            }

            if (is_string($rawVal) && $rawVal != $value) {
                $this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
            } else {
                $this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
            }
        }
    }
protected function listConfiguration ( array $ contents , array $ rawContents , OutputInterface $ output , $ k = null ) { $ origK = $ k ; foreach ( $ contents as $ key => $ value ) { if ( $ k === null && ! in_array ( $ key , array ( 'config' , 'repositories' ) ) ) { continue ; } $ rawVal = isset ( $ rawContents [ $ key ] ) ? $ rawContents [ $ key ] : null ; if ( is_array ( $ value ) && ( ! is_numeric ( key ( $ value ) ) || ( $ key === 'repositories' && null === $ k ) ) ) { $ k .= preg_replace ( '{^config\.}' , '' , $ key . '.' ) ; $ this -> listConfiguration ( $ value , $ rawVal , $ output , $ k ) ; if ( substr_count ( $ k , '.' ) > 1 ) { $ k = str_split ( $ k , strrpos ( $ k , '.' , - 2 ) ) ; $ k = $ k [ 0 ] . '.' ; } else { $ k = $ origK ; } continue ; } if ( is_array ( $ value ) ) { $ value = array_map ( function ( $ val ) { return is_array ( $ val ) ? json_encode ( $ val ) : $ val ; } , $ value ) ; $ value = '[' . implode ( ', ' , $ value ) . ']' ; } if ( is_bool ( $ value ) ) { $ value = var_export ( $ value , true ) ; } if ( is_string ( $ rawVal ) && $ rawVal != $ value ) { $ this -> getIO ( ) -> write ( '[<comment>' . $ k . $ key . '</comment>] <info>' . $ rawVal . ' (' . $ value . ')</info>' ) ; } else { $ this -> getIO ( ) -> write ( '[<comment>' . $ k . $ key . '</comment>] <info>' . $ value . '</info>' ) ; } } }
Display the contents of the file in a pretty formatted way

@param array           $contents
@param array           $rawContents
@param OutputInterface $output
@param string|null     $k
Display the contents of the file in a pretty formatted way