function normalizeDep($dep)
    {
        $types = array(
            'pkg' => 'Package',
            'ext' => 'Extension',
            'os' => 'Os',
            'php' => 'Php'
        );

        if (!isset($types[$dep['type']])) {
            return array(false, false);
        }

        $type = $types[$dep['type']];

        $newdep = array();
        switch ($type) {
            case 'Package' :
                $newdep['channel'] = 'pear.php.net';
            case 'Extension' :
            case 'Os' :
                $newdep['name'] = $dep['name'];
            break;
        }

        $dep['rel'] = PEAR_Dependency2::signOperator($dep['rel']);
        switch ($dep['rel']) {
            case 'has' :
                return array($newdep, $type);
            break;
            case 'not' :
                $newdep['conflicts'] = true;
            break;
            case '>=' :
            case '>' :
                $newdep['min'] = $dep['version'];
                if ($dep['rel'] == '>') {
                    $newdep['exclude'] = $dep['version'];
                }
            break;
            case '<=' :
            case '<' :
                $newdep['max'] = $dep['version'];
                if ($dep['rel'] == '<') {
                    $newdep['exclude'] = $dep['version'];
                }
            break;
            case 'ne' :
            case '!=' :
                $newdep['min'] = '0';
                $newdep['max'] = '100000';
                $newdep['exclude'] = $dep['version'];
            break;
            case '==' :
                $newdep['min'] = $dep['version'];
                $newdep['max'] = $dep['version'];
            break;
        }
        if ($type == 'Php') {
            if (!isset($newdep['min'])) {
                $newdep['min'] = '4.4.0';
            }

            if (!isset($newdep['max'])) {
                $newdep['max'] = '6.0.0';
            }
        }
        return array($newdep, $type);
    }
function normalizeDep($dep)
    {
        $types = array(
            'pkg' => 'Package',
            'ext' => 'Extension',
            'os' => 'Os',
            'php' => 'Php'
        );

        if (!isset($types[$dep['type']])) {
            return array(false, false);
        }

        $type = $types[$dep['type']];

        $newdep = array();
        switch ($type) {
            case 'Package' :
                $newdep['channel'] = 'pear.php.net';
            case 'Extension' :
            case 'Os' :
                $newdep['name'] = $dep['name'];
            break;
        }

        $dep['rel'] = PEAR_Dependency2::signOperator($dep['rel']);
        switch ($dep['rel']) {
            case 'has' :
                return array($newdep, $type);
            break;
            case 'not' :
                $newdep['conflicts'] = true;
            break;
            case '>=' :
            case '>' :
                $newdep['min'] = $dep['version'];
                if ($dep['rel'] == '>') {
                    $newdep['exclude'] = $dep['version'];
                }
            break;
            case '<=' :
            case '<' :
                $newdep['max'] = $dep['version'];
                if ($dep['rel'] == '<') {
                    $newdep['exclude'] = $dep['version'];
                }
            break;
            case 'ne' :
            case '!=' :
                $newdep['min'] = '0';
                $newdep['max'] = '100000';
                $newdep['exclude'] = $dep['version'];
            break;
            case '==' :
                $newdep['min'] = $dep['version'];
                $newdep['max'] = $dep['version'];
            break;
        }
        if ($type == 'Php') {
            if (!isset($newdep['min'])) {
                $newdep['min'] = '4.4.0';
            }

            if (!isset($newdep['max'])) {
                $newdep['max'] = '6.0.0';
            }
        }
        return array($newdep, $type);
    }
function normalizeDep ( $ dep ) { $ types = array ( 'pkg' => 'Package' , 'ext' => 'Extension' , 'os' => 'Os' , 'php' => 'Php' ) ; if ( ! isset ( $ types [ $ dep [ 'type' ] ] ) ) { return array ( false , false ) ; } $ type = $ types [ $ dep [ 'type' ] ] ; $ newdep = array ( ) ; switch ( $ type ) { case 'Package' : $ newdep [ 'channel' ] = 'pear.php.net' ; case 'Extension' : case 'Os' : $ newdep [ 'name' ] = $ dep [ 'name' ] ; break ; } $ dep [ 'rel' ] = PEAR_Dependency2 :: signOperator ( $ dep [ 'rel' ] ) ; switch ( $ dep [ 'rel' ] ) { case 'has' : return array ( $ newdep , $ type ) ; break ; case 'not' : $ newdep [ 'conflicts' ] = true ; break ; case '>=' : case '>' : $ newdep [ 'min' ] = $ dep [ 'version' ] ; if ( $ dep [ 'rel' ] == '>' ) { $ newdep [ 'exclude' ] = $ dep [ 'version' ] ; } break ; case '<=' : case '<' : $ newdep [ 'max' ] = $ dep [ 'version' ] ; if ( $ dep [ 'rel' ] == '<' ) { $ newdep [ 'exclude' ] = $ dep [ 'version' ] ; } break ; case 'ne' : case '!=' : $ newdep [ 'min' ] = '0' ; $ newdep [ 'max' ] = '100000' ; $ newdep [ 'exclude' ] = $ dep [ 'version' ] ; break ; case '==' : $ newdep [ 'min' ] = $ dep [ 'version' ] ; $ newdep [ 'max' ] = $ dep [ 'version' ] ; break ; } if ( $ type == 'Php' ) { if ( ! isset ( $ newdep [ 'min' ] ) ) { $ newdep [ 'min' ] = '4.4.0' ; } if ( ! isset ( $ newdep [ 'max' ] ) ) { $ newdep [ 'max' ] = '6.0.0' ; } } return array ( $ newdep , $ type ) ; }
Convert a 1.0 dep into a 2.0 dep
Convert a 1 . 0 dep into a 2 . 0 dep