Print out a list of all targets in the current buildfile

@param $project
554133
public function printTargets($project)
    {
        // find the target with the longest name
        $maxLength = 0;
        $targets = $project->getTargets();
        $targetName = null;
        $targetDescription = null;
        $currentTarget = null;

        // split the targets in top-level and sub-targets depending
        // on the presence of a description

        $subNames = [];
        $topNameDescMap = [];

        foreach ($targets as $currentTarget) {
            $targetName = $currentTarget->getName();
            $targetDescription = $currentTarget->getDescription();
            if ($currentTarget->isHidden()) {
                continue;
            }

            // subtargets are targets w/o descriptions
            if ($targetDescription === null) {
                $subNames[] = $targetName;
            } else {
                // topNames and topDescriptions are handled later
                // here we store in hash map (for sorting purposes)
                $topNameDescMap[$targetName] = $targetDescription;
                if (strlen($targetName) > $maxLength) {
                    $maxLength = strlen($targetName);
                }
            }
        }

        // Sort the arrays
        sort($subNames); // sort array values, resetting keys (which are numeric)
        ksort($topNameDescMap); // sort the keys (targetName) keeping key=>val associations

        $topNames = array_keys($topNameDescMap);
        $topDescriptions = array_values($topNameDescMap);

        $defaultTarget = $project->getDefaultTarget();

        if ($defaultTarget !== null && $defaultTarget !== "") {
            $defaultName = [];
            $defaultDesc = [];
            $defaultName[] = $defaultTarget;

            $indexOfDefDesc = array_search($defaultTarget, $topNames, true);
            if ($indexOfDefDesc !== false && $indexOfDefDesc >= 0) {
                $defaultDesc = [];
                $defaultDesc[] = $topDescriptions[$indexOfDefDesc];
            }

            $this->_printTargets($defaultName, $defaultDesc, "Default target:", $maxLength);
        }
        $this->_printTargets($topNames, $topDescriptions, "Main targets:", $maxLength);
        $this->_printTargets($subNames, null, "Subtargets:", 0);
    }
758324
public function main()
    {
        if ($this->list === null && $this->currPath === null && count($this->dirsets) === 0 && count($this->filesets) == 0 && count($this->filelists) == 0) {
            throw new BuildException("Need either list, path, nested dirset, nested fileset or nested filelist to iterate through");
        }
        if ($this->param === null) {
            throw new BuildException("You must supply a property name to set on each iteration in param");
        }
        if ($this->calleeTarget === null) {
            throw new BuildException("You must supply a target to perform");
        }

        $callee = $this->createCallTarget();
        $mapper = null;

        if ($this->mapperElement !== null) {
            $mapper = $this->mapperElement->getImplementation();
        }

        if ($this->list !== null) {
            $arr = explode($this->delimiter, $this->list);
            $total_entries = 0;

            foreach ($arr as $index => $value) {
                if ($this->trim) {
                    $value = trim($value);
                }
                $premapped = '';
                if ($mapper !== null) {
                    $premapped = $value;
                    $value = $mapper->main($value);
                    if ($value === null) {
                        continue;
                    }
                    $value = array_shift($value);
                }
                $this->log(
                    "Setting param '$this->param' to value '$value'" . ($premapped ? " (mapped from '$premapped')" : ''),
                    Project::MSG_VERBOSE
                );
                $prop = $callee->createProperty();
                $prop->setOverride(true);
                $prop->setName($this->param);
                $prop->setValue($value);
                $prop = $callee->createProperty();
                $prop->setOverride(true);
                $prop->setName($this->index);
                $prop->setValue($index);
                $callee->main();
                $total_entries++;
            }
        }

        if ($this->currPath !== null) {
            $pathElements = $this->currPath->listPaths();
            foreach ($pathElements as $pathElement) {
                $ds = new DirectoryScanner();
                $ds->setBasedir($pathElement);
                $ds->scan();
                $this->process($callee, new PhingFile($pathElement), $ds->getIncludedFiles(), array());
            }
        }

        // filelists
        foreach ($this->filelists as $fl) {
            $srcFiles = $fl->getFiles($this->project);

            $this->process($callee, $fl->getDir($this->project), $srcFiles, []);
        }

        // filesets
        foreach ($this->filesets as $fs) {
            $ds = $fs->getDirectoryScanner($this->project);
            $srcFiles = $ds->getIncludedFiles();
            $srcDirs = $ds->getIncludedDirectories();

            $this->process($callee, $fs->getDir($this->project), $srcFiles, $srcDirs);
        }

        foreach ($this->dirsets as $dirset) {
            $ds = $dirset->getDirectoryScanner($this->project);
            $srcDirs = $ds->getIncludedDirectories();

            $this->process($callee, $dirset->getDir($this->project), [], $srcDirs);
        }

        if ($this->list === null) {
            $this->log(
                "Processed {$this->total_dirs} directories and {$this->total_files} files",
                Project::MSG_VERBOSE
            );
        } else {
            $this->log(
                "Processed $total_entries entr" . ($total_entries > 1 ? 'ies' : 'y') . " in list",
                Project::MSG_VERBOSE
            );
        }
    }
494867
def main(output):
    

    client = Session().client('cloudresourcemanager', 'v1', 'projects')

    results = []
    for page in client.execute_paged_query('list', {}):
        for project in page.get('projects', []):

            if project['lifecycleState'] != 'ACTIVE':
                continue

            project_info = {
                'project_id': project['projectId'],
                'name': project['name'],
            }

            if 'labels' in project:
                project_info['tags'] = [
                    'label:%s:%s' % (k, v) for k, v in project.get('labels', {}).items()]
            results.append(project_info)

    output.write(
        yaml.safe_dump({'projects': results}, default_flow_style=False))
287766
protected function processAccessInformation(Project &$project)
    {
        $matches = array();
        $reference = $project->getReference();

        if ($project->getType() == 'gitlab') {
            $info = array();

            if (preg_match('`^(.+)@(.+):([0-9]*)\/?(.+)\.git`', $reference, $matches)) {
                $info['user'] = $matches[1];
                $info['domain'] = $matches[2];
                $info['port'] = $matches[3];

                $project->setReference($matches[4]);
            }

            $project->setAccessInformation($info);
        }
    }
717385
public function getEnvironmentPaths($project) {
		$baseDir = $this->getEnvironmentDir() . '/' . $project;

		$paths = array();
		if(!file_exists($baseDir)) {
			throw new Exception('Environment directory '.$baseDir.' doesn\'t exist. Create it first.');
		}
		// Search the directory for config files.
		foreach(scandir($baseDir) as $environmentFile) {
			if(preg_match('/\.rb$/', $environmentFile)) {
				// Config found, wrap it into an object.
				$paths[] = "$baseDir/$environmentFile";
			}
		}
		sort($paths);
		return array_values($paths);
	}
1265318
public function printDescription(Project $project)
    {
        if ($project->getDescription() !== null) {
            self::$out->write($project->getDescription() . PHP_EOL);
        }
    }
1374706
public function main()
    {

        $sec           = 0;
        $target        = $this->getOwningTarget();
        $targetName    = $target->getName();
        $subTargetName = $this->subTarget;
        $allTargets    = $this->project->getTargets();

        $usedTargets   = array_filter(
            $allTargets,
            function ($key) {
                return strrpos($key, ".".$targetName) > 0;
            },
            ARRAY_FILTER_USE_KEY
        );

        // If the target was redefined outside of the starterkit.
        if (!empty($usedTargets)) {
            $sec       = 10;
            $newTarget = $targetName;
            $buildFile = "build.project.xml";
            $target    = $allTargets[$subTargetName];
        } else {
            // If a deprecated target is called without redefinition.
            $sec       = 5;
            $newTarget = $subTargetName;
            $buildFile = $this->project->getProperty("phing.file");
        }

        // Inform user of the deprecated target.
        $this->log(
            "Target '".$targetName."' has been replaced by '".$subTargetName."'.",
            Project::MSG_WARN
        );
        $this->log(
            "A ".$sec." second penalty is assigned usage of this target.",
            Project::MSG_WARN
        );
        $this->log(
            "Please use '".$subTargetName."' instead to avoid the penalty.",
            Project::MSG_WARN
        );
        $this->log(
            "Running PhingCallTask for target '".$subTargetName."'",
            Project::MSG_DEBUG
        );
        sleep($sec);

        if ($this->_callee === null) {
            $this->init();
        }

        if ($this->subTarget === null) {
            throw new BuildException(
                "Attribute target is required.",
                $this->getLocation()
            );
        }

        $this->_callee->setPhingfile($buildFile);
        $this->_callee->setTarget($newTarget);
        $this->_callee->setOwningTarget($target);
        $this->_callee->setInheritAll($this->_inheritAll);
        $this->_callee->setInheritRefs($this->_inheritRefs);
        $this->_callee->main();

    }
810377
public function main()
    {
        if ($this->prefix != null && $this->regex != null) {
            throw new BuildException("Please specify either prefix or regex, but not both", $this->getLocation());
        }

        //copy the properties file
        $allProps = [];

        /* load properties from file if specified, otherwise use Phing's properties */
        if ($this->inFile == null) {
            // add phing properties
            $allProps = $this->getProject()->getProperties();
        } elseif ($this->inFile != null) {
            if ($this->inFile->exists() && $this->inFile->isDirectory()) {
                $message = "srcfile is a directory!";
                $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                return;
            }

            if ($this->inFile->exists() && !$this->inFile->canRead()) {
                $message = "Can not read from the specified srcfile!";
                $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                return;
            }

            try {
                $props = new Properties();
                $props->load(new PhingFile($this->inFile));
                $allProps = $props->getProperties();
            } catch (IOException $ioe) {
                $message = "Could not read file " . $this->inFile->getAbsolutePath();
                $this->failOnErrorAction($ioe, $message, Project::MSG_WARN);
                return;
            }
        }

        $os = null;
        try {
            if ($this->destfile == null) {
                $os = Phing::getOutputStream();
                $this->saveProperties($allProps, $os);
                $this->log($os, Project::MSG_INFO);
            } else {
                if ($this->destfile->exists() && $this->destfile->isDirectory()) {
                    $message = "destfile is a directory!";
                    $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                    return;
                }

                if ($this->destfile->exists() && !$this->destfile->canWrite()) {
                    $message = "Can not write to the specified destfile!";
                    $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                    return;
                }
                $os = new FileOutputStream($this->destfile);
                $this->saveProperties($allProps, $os);
            }
        } catch (IOException $ioe) {
            $this->failOnErrorAction($ioe);
        }
    }
992401
public function actionAllForRelease()
	{
		Output::line('Getting package info...');
		$collection = \App::$domain->vendor->info->allForRelease();
		if(!empty($collection)) {
			$flatCollection = ArrayHelper::map($collection, 'package', 'version');
			Output::line();
			Output::arr($flatCollection, 'Repository list for release');
		} else {
			Output::block('Empty list!', 'Message');
		}
	}
604571
protected function getSummaryHtml($projects)
    {
        $summaryBuilds = array();
        $successes     = array();
        $failures      = array();
        $counts        = array();

        foreach ($projects as $project) {
            $summaryBuilds[$project->getId()] = $this->buildStore->getLatestBuilds($project->getId());

            $count = $this->buildStore->getWhere(
                array('project_id' => $project->getId()),
                1,
                0,
                array(),
                array('id' => 'DESC')
            );
            $counts[$project->getId()] = $count['count'];

            $success = $this->buildStore->getLastBuildByStatus($project->getId(), Build::STATUS_SUCCESS);
            $failure = $this->buildStore->getLastBuildByStatus($project->getId(), Build::STATUS_FAILED);

            $successes[$project->getId()] = $success;
            $failures[$project->getId()] = $failure;
        }

        $summaryView = new b8\View('SummaryTable');
        $summaryView->projects   = $projects;
        $summaryView->builds     = $summaryBuilds;
        $summaryView->successful = $successes;
        $summaryView->failed     = $failures;
        $summaryView->counts     = $counts;

        return $summaryView->render();
    }
1366709
private function readFiles(Project $p)
    {
        if (!empty($this->includesFileList)) {
            foreach ($this->includesFileList as $ne) {
                $fileName = (string) $ne->evalName($p);
                if ($fileName !== null) {
                    $inclFile = $p->resolveFile($fileName);
                    if (!$inclFile->exists()) {
                        throw new BuildException("Includesfile " . $inclFile->getAbsolutePath() . " not found.");
                    }
                    $this->readPatterns($inclFile, $this->includeList, $p);
                }
            }
            $this->includesFileList = [];
        }

        if (!empty($this->excludesFileList)) {
            foreach ($this->excludesFileList as $ne) {
                $fileName = (string) $ne->evalName($p);
                if ($fileName !== null) {
                    $exclFile = $p->resolveFile($fileName);
                    if (!$exclFile->exists()) {
                        throw new BuildException("Excludesfile " . $exclFile->getAbsolutePath() . " not found.");
                    }
                    $this->readPatterns($exclFile, $this->excludeList, $p);
                }
            }
            $this->excludesFileList = [];
        }
    }
1049304
public function main()
  {
    // Get base info about project.
    $this->prepareProjectData();

    // Get all info about source files.
    $this->getInfoSourceFiles();

    // Get all info about resource files.
    $this->getInfoResourceFiles();

    // Prepare all place holders.
    $this->preparePlaceHolders();

    // Replace references to resource files with references to optimized/minimized resource files.
    $this->processingSourceFiles();

    // Compress and rename files with hash.
    $this->processResourceFiles();

    // Create pre-compressed versions of the optimized/minimized resource files.
    if ($this->gzipFlag) $this->gzipCompressOptimizedResourceFiles();

    // Remove original resource files that are optimized/minimized.
    $this->unlinkResourceFiles();
  }
1338330
public function processClones($clones, Project $project, $useFile = false, $outFile = null)
    {
        if (!$useFile || empty($outFile)) {
            throw new BuildException('Output filename required for this formatter');
        }

        if (get_class($clones) == 'PHPCPD_CloneMap') {
            $logger = new PHPCPD_Log_XML_PMD($outFile);
        } else {
            $logger = new \SebastianBergmann\PHPCPD\Log\PMD($outFile);
        }

        $logger->processClones($clones);
    }
1335496
protected function outputCustomFormat($report)
    {
        $files = $report['files'];
        foreach ($files as $file => $attributes) {
            $errors = $attributes['errors'];
            $warnings = $attributes['warnings'];
            $messages = $attributes['messages'];
            if ($errors > 0) {
                $this->log(
                    $file . ': ' . $errors . ' error' . ($errors > 1 ? 's' : '') . ' detected',
                    Project::MSG_ERR
                );
                $this->outputCustomFormatMessages($messages, 'ERROR');
            } else {
                $this->log($file . ': No syntax errors detected', Project::MSG_VERBOSE);
            }
            if ($warnings > 0) {
                $this->log(
                    $file . ': ' . $warnings . ' warning' . ($warnings > 1 ? 's' : '') . ' detected',
                    Project::MSG_WARN
                );
                $this->outputCustomFormatMessages($messages, 'WARNING');
            }
        }

        $totalErrors = $report['totals']['errors'];
        $totalWarnings = $report['totals']['warnings'];
        $this->log(count($files) . ' files were checked', Project::MSG_INFO);
        if ($totalErrors > 0) {
            $this->log($totalErrors . ' error' . ($totalErrors > 1 ? 's' : '') . ' detected', Project::MSG_ERR);
        } else {
            $this->log('No syntax errors detected', Project::MSG_INFO);
        }
        if ($totalWarnings > 0) {
            $this->log($totalWarnings . ' warning' . ($totalWarnings > 1 ? 's' : '') . ' detected', Project::MSG_INFO);
        }
    }
733650
public function main()
    {
        // check supplied attributes
        $this->checkReleasetype();
        $this->checkFile();
        $this->checkProperty();

        // read file (or use fallback value if file is empty)
        try {
            if ($this->propFile) {
                $properties = $this->loadProperties();
                $content = $properties->getProperty($this->property);
            } else {
                $content = trim($this->file->contents());
            }
            if (empty($content)) {
                $content = $this->startingVersion;
            }
        } catch (Exception $e) {
            throw new BuildException($e);
        }

        // get new version
        $this->log("Old version: $content", Project::MSG_INFO);
        $newVersion = $this->getVersion($content);
        $this->log("New version: $newVersion", Project::MSG_INFO);

        if ($this->propFile) {
            $properties->put($this->property, $newVersion);
            try {
                $header = "Build Number for PHING. Do not edit!";
                $properties->store($this->file, $header);
            } catch (IOException $ioe) {
                $message = "Error while writing " . $this->file;
                throw new BuildException($message, $ioe);
            }
        } else {
            // write new Version to file
            file_put_contents($this->file, $newVersion . $this->getProject()->getProperty('line.separator'));
        }

        //Finally set the property
        $this->getProject()->setNewProperty($this->property, $newVersion);
    }
288110
public function init()
    {
        if (empty($this->getOwningTarget()->getName())) {
            $project       = $this->getProject();
            $buildFileRoot = $project->getProperty('phing.file');
            $buildList     = $this->getBuildList($buildFileRoot);
            $targets       = array();

            foreach ($buildList as $buildFile => $info) {
                if (is_file($buildFile)) {
                    $target = new Target();
                    $target->setName('help-'.$info['name']);

                    $task = clone $this;
                    $task->setBuildFile($buildFile);
                    $task->setOwningTarget($target);

                    $target->addTask($task);
                    $this->project->addTarget('help-'.$info['name'], $target);

                    $targets[$buildFileRoot][] = array(
                        'name'        => $target->getName(),
                        'visibility'  => 'hidden',
                        'description' => $buildList[$buildFile]['description'],
                     );
                }

                if ($buildFile === $buildFileRoot) {
                    $project->setDefaultTarget($target->getName());
                }
            }//end foreach

            $this->project->helpTargets = $targets;
        }//end if

    }
420821
public function targetStarted(BuildEvent $event)
    {
        if (Project::MSG_INFO <= $this->msgOutputLevel
            && $event->getTarget()->getName() != ''
        ) {
            $showLongTargets = $event->getProject()->getProperty("phing.showlongtargets");
            $msg = PHP_EOL . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ($showLongTargets ? ' [' . $event->getTarget()->getDescription() . ']' : '') . ':' . PHP_EOL;
            $this->printMessage($msg, $this->out, $event->getPriority());
        }
    }