protected function parseTargets()
    {
        $targetsArray      = array();
        $wrapperTargets    = array();
        $buildTargets      = array();
        $callbackTargets   = array();
        $deprecatedTargets = array();
        $helperTargets     = array();

        $buildList = $this->buildList;
        foreach ($buildList as $buildFile => $info) {
            $xml = simplexml_load_file($buildFile);

            foreach ($xml->xpath('//target') as $target) {
                $targetName        = (string) $target->attributes()->name;
                $targetVisibility  = (string) $target->attributes()->hidden == 'true' ? 'hidden' : 'visible';
                $targetDescription = (string) $target->attributes()->description;

                $targetArray = array(
                    'name'        => $targetName,
                    'description' => $targetDescription,
                    'visibility'  => $targetVisibility,
                    'buildfile'   => $buildFile,
                );

                if (strpos($targetName, "build-") === 0) {
                    $targetDependenciesString = (string) $target->xpath(
                        './@depends'
                    )[0];
                    $targetDependencies       = explode(
                        ',',
                        str_replace(
                            ' ',
                            '',
                            $targetDependenciesString
                        )
                    );
                    $targetDependencies = array_filter($targetDependencies);
                    sort($targetDependencies);
                    $callbackTargets = array_merge(
                        $callbackTargets,
                        array_values($targetDependencies)
                    );
                    $targetArray += array(
                        'dependencies' => $targetDependencies,
                        'type'         => 'build',
                    );
                    if (count($targetDependencies) > 1) {
                        $targetArray['type'] = 'build';
                        $buildTargets[]   = $targetName;
                    }
                }

                if (count($target->xpath('./replacedby')) == 1) {
                    $replacedBy = (string) $target->xpath(
                        './replacedby[1]/@target'
                    )[0];
                    $deprecatedTargets[] = $targetName;
                    $targetArray         = array_merge(
                        $targetArray,
                        array(
                            'type'        => 'deprecated',
                            'description' => $replacedBy,
                        )
                    );
                }

                $callbackTargets = array_unique($callbackTargets);
                $targetsArray[]  = $targetArray;
            }//end foreach
        }//end foreach

        foreach ($targetsArray as $key => $targetArray) {
            if (in_array($targetArray['name'], $callbackTargets)
                && !in_array($targetArray['name'], $buildTargets)
            ) {
                $targetsArray[$key]['type'] = 'callback';
            } elseif (!isset($targetArray['type'])) {
                $targetsArray[$key]['type'] = 'helper';
            }
        }
        sort($targetsArray);
        $this->targets = $targetsArray;
    }