本文整理汇总了PHP中PhingFile::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP PhingFile::getPath方法的具体用法?PHP PhingFile::getPath怎么用?PHP PhingFile::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhingFile
的用法示例。
在下文中一共展示了PhingFile::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Load properties from a file.
*
* @param PhingFile $file
* @return void
* @throws IOException - if unable to read file.
*/
function load(PhingFile $file)
{
if ($file->canRead()) {
$this->parse($file->getPath(), false);
} else {
throw new IOException("Can not read file " . $file->getPath());
}
}
示例2: main
/**
* Executes PHPCPD against PhingFile or a FileSet
*
* @return void
*/
public function main()
{
if (!isset($this->_file) and count($this->_filesets) == 0) {
throw new BuildException("Missing either a nested fileset or attribute 'file' set");
}
if (count($this->_formatters) == 0) {
// turn legacy format attribute into formatter
$fmt = new PHPCPDFormatterElement($this);
$fmt->setType($this->_format);
$fmt->setUseFile(false);
$this->_formatters[] = $fmt;
}
$this->validateFormatters();
$filesToParse = array();
if ($this->_file instanceof PhingFile) {
$filesToParse[] = $this->_file->getPath();
} else {
// append any files in filesets
foreach ($this->_filesets as $fs) {
$files = $fs->getDirectoryScanner($this->project)->getIncludedFiles();
foreach ($files as $filename) {
$f = new PhingFile($fs->getDir($this->project), $filename);
$filesToParse[] = $f->getAbsolutePath();
}
}
}
$this->log('Processing files...');
$detector = new PHPCPD_Detector(new PHPCPD_Detector_Strategy_Default());
$clones = $detector->copyPasteDetection($filesToParse, $this->_minLines, $this->_minTokens);
$this->log('Finished copy/paste detection');
foreach ($this->_formatters as $fe) {
$formatter = $fe->getFormatter();
$formatter->processClones($clones, $this->project, $fe->getUseFile(), $fe->getOutfile());
}
}
示例3: main
/**
* @throws BuildException
*/
public function main()
{
if (!$this->getDatabaseName()) {
throw new BuildException("The databaseName attribute (defined in propel.project property) is required for schema reverse engineering", $this->getLocation());
}
//(not yet supported) $this->log("schema : " . $this->dbSchema);
//DocumentTypeImpl docType = new DocumentTypeImpl(null, "database", null,
// "http://jakarta.apache.org/turbine/dtd/database.dtd");
$this->doc = new DOMDocument('1.0', 'utf-8');
$this->doc->formatOutput = true;
// pretty printing
$this->doc->appendChild($this->doc->createComment("Autogenerated by " . get_class($this) . " class."));
try {
$database = $this->buildModel();
if ($this->validatorBits !== self::VALIDATORS_NONE) {
$this->addValidators($database);
}
$database->appendXml($this->doc);
$this->log("Writing XML to file: " . $this->xmlSchema->getPath());
$out = new FileWriter($this->xmlSchema);
$xmlstr = $this->doc->saveXML();
$out->write($xmlstr);
$out->close();
} catch (Exception $e) {
$this->log("There was an error building XML from metadata: " . $e->getMessage(), Project::MSG_ERR);
return false;
}
$this->log("Schema reverse engineering finished");
}
示例4: main
public function main()
{
if (empty($this->filesets)) {
throw new BuildException("You must specify a file or fileset(s).");
}
if (empty($this->_compilePath)) {
throw new BuildException("You must specify location for compiled templates.");
}
date_default_timezone_set("America/New_York");
$project = $this->getProject();
$this->_count = $this->_total = 0;
$smartyCompilePath = new PhingFile($this->_compilePath);
if (!$smartyCompilePath->exists()) {
$this->log("Compile directory does not exist, creating: " . $smartyCompilePath->getPath(), Project::MSG_VERBOSE);
if (!$smartyCompilePath->mkdirs()) {
throw new BuildException("Error creating compile path for Smarty in " . $this->_compilePath);
}
}
$this->_smarty = new Smarty();
$this->_smarty->use_sub_dirs = true;
$this->_smarty->compile_dir = $smartyCompilePath;
$this->_smarty->plugins_dir[] = $this->_pluginsPath;
$this->_smarty->force_compile = $this->_forceCompile;
// process filesets
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($project);
$fromDir = $fs->getDir($project);
$srcFiles = $ds->getIncludedFiles();
$this->_compile($fromDir, $srcFiles);
}
$this->log("Compiled " . $this->_count . " out of " . $this->_total . " Smarty templates");
}
示例5: getFilesToParse
/**
* Return the list of files to parse
*
* @return string[] list of absolute files to parse
*/
protected function getFilesToParse()
{
$filesToParse = array();
if ($this->file instanceof PhingFile) {
$filesToParse[] = $this->file->getPath();
} else {
// append any files in filesets
foreach ($this->filesets as $fs) {
$dir = $fs->getDir($this->project)->getAbsolutePath();
foreach ($fs->getDirectoryScanner($this->project)->getIncludedFiles() as $filename) {
$fileAbsolutePath = $dir . DIRECTORY_SEPARATOR . $filename;
if ($this->cache) {
$lastMTime = $this->cache->get($fileAbsolutePath);
$currentMTime = filemtime($fileAbsolutePath);
if ($lastMTime >= $currentMTime) {
continue;
} else {
$this->cache->put($fileAbsolutePath, $currentMTime);
}
}
$filesToParse[] = $fileAbsolutePath;
}
}
}
return $filesToParse;
}
示例6: main
/**
* @throws BuildException
*/
public function main()
{
$this->checkPreconditions();
try {
$this->log('Building package: ' . $this->destinationFile->__toString(), Project::MSG_INFO);
/*
* Delete old package, if exists.
*/
if ($this->destinationFile->exists()) {
/*
* TODO Check operation for errors...
*/
$this->destinationFile->delete();
}
$phar = $this->buildPhar();
$phar->startBuffering();
$baseDirectory = realpath($this->baseDirectory->getPath());
foreach ($this->filesets as $fileset) {
$this->log('Adding specified files in ' . $fileset->getDir($this->project) . ' to package', Project::MSG_VERBOSE);
$phar->buildFromIterator($fileset, $baseDirectory);
}
$phar->stopBuffering();
/*
* File compression, if needed.
*/
if (Phar::NONE != $this->compression) {
$phar->compressFiles($this->compression);
}
} catch (Exception $e) {
throw new BuildException('Problem creating package: ' . $e->getMessage(), $e, $this->getLocation());
}
}
示例7: main
/**
* @throws BuildException
*/
public function main()
{
$this->checkPreconditions();
try {
$this->log('Building archive: ' . $this->destinationFile->__toString(), Project::MSG_INFO);
/**
* Delete old archive, if exists.
*/
if ($this->destinationFile->exists()) {
$isDeleted = $this->destinationFile->delete();
if (!$isDeleted) {
$this->log("Could not delete destination file {$this->destinationFile}", Project::MSG_WARN);
}
}
$pharData = new PharData($this->baseDirectory->getPath() . '/' . $this->destinationFile->getName());
foreach ($this->filesets as $fileset) {
$this->log('Adding specified files in ' . $fileset->getDir($this->project) . ' to archive', Project::MSG_VERBOSE);
$pharData->buildFromIterator($fileset->getIterator(), $fileset->getDir($this->project));
}
if ($this->compression !== PHAR::NONE && $pharData->canCompress($this->compression)) {
try {
$pharData->compress($this->compression);
} catch (UnexpectedValueException $uve) {
$pharData->compressFiles($this->compression);
}
unset($pharData);
}
} catch (Exception $e) {
throw new BuildException('Problem creating archive: ' . $e->getMessage(), $e, $this->getLocation());
}
}
示例8: initialize
/**
* Scans the parameters list for the "lines" parameter and uses
* it to set the number of lines to be returned in the filtered stream.
* also scan for skip parameter.
*
* @throws BuildException
*/
private function initialize()
{
// get parameters
$params = $this->getParameters();
if ($params !== null) {
/** @var Parameter $param */
foreach ($params as $param) {
if ('prepend' === $param->getName()) {
$this->setPrepend(new PhingFile($param->getValue()));
continue;
}
if ('append' === $param->getName()) {
$this->setAppend(new PhingFile($param->getValue()));
continue;
}
}
}
if ($this->prepend !== null) {
if (!$this->prepend->isAbsolute()) {
$this->prepend = new PhingFile($this->getProject()->getBasedir(), $this->prepend->getPath());
}
$this->prependReader = new BufferedReader(new FileReader($this->prepend));
}
if ($this->append !== null) {
if (!$this->append->isAbsolute()) {
$this->append = new PhingFile($this->getProject()->getBasedir(), $this->append->getPath());
}
$this->appendReader = new BufferedReader(new FileReader($this->append));
}
}
示例9: setOptions
private function setOptions($pkg)
{
$options['baseinstalldir'] = 'propel';
$options['packagedirectory'] = $this->dir->getAbsolutePath();
if (empty($this->filesets)) {
throw new BuildException("You must use a <fileset> tag to specify the files to include in the package.xml");
}
$options['filelistgenerator'] = 'Fileset';
// Some PHING-specific options needed by our Fileset reader
$options['phing_project'] = $this->getProject();
$options['phing_filesets'] = $this->filesets;
if ($this->packageFile !== null) {
// create one w/ full path
$f = new PhingFile($this->packageFile->getAbsolutePath());
$options['packagefile'] = $f->getName();
// must end in trailing slash
$options['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR;
$this->log("Creating package file: " . $f->getPath(), Project::MSG_INFO);
} else {
$this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO);
}
// add install exceptions
$options['installexceptions'] = array('pear/pear-propel-gen' => '/', 'pear/pear-propel-gen.bat' => '/', 'pear/pear-build.xml' => '/', 'pear/build.properties' => '/');
$options['dir_roles'] = array('projects' => 'data', 'test' => 'test', 'templates' => 'data', 'resources' => 'data');
$options['exceptions'] = array('pear/pear-propel-gen.bat' => 'script', 'pear/pear-propel-gen' => 'script', 'pear/pear-build.xml' => 'data', 'build.xml' => 'data', 'build-propel.xml' => 'data');
$pkg->setOptions($options);
}
示例10: main
/**
* Executes PHPMD against PhingFile or a FileSet
*
* @throws BuildException - if the phpmd classes can't be loaded.
*/
public function main()
{
/**
* Find PHPMD
*/
@(include_once 'PHP/PMD.php');
if (!class_exists('PHP_PMD')) {
throw new BuildException('PHPMDTask depends on PHPMD being installed and on include_path.', $this->getLocation());
}
require_once 'PHP/PMD/AbstractRule.php';
if (!$this->minimumPriority) {
$this->minimumPriority = PHP_PMD_AbstractRule::LOWEST_PRIORITY;
}
if (!isset($this->file) and count($this->filesets) == 0) {
throw new BuildException('Missing either a nested fileset or attribute "file" set');
}
if (count($this->formatters) == 0) {
// turn legacy format attribute into formatter
$fmt = new PHPMDFormatterElement();
$fmt->setType($this->format);
$fmt->setUseFile(false);
$this->formatters[] = $fmt;
}
$reportRenderers = array();
foreach ($this->formatters as $fe) {
if ($fe->getType() == '') {
throw new BuildException('Formatter missing required "type" attribute.');
}
if ($fe->getUsefile() && $fe->getOutfile() === null) {
throw new BuildException('Formatter requires "outfile" attribute when "useFile" is true.');
}
$reportRenderers[] = $fe->getRenderer();
}
// Create a rule set factory
$ruleSetFactory = new PHP_PMD_RuleSetFactory();
$ruleSetFactory->setMinimumPriority($this->minimumPriority);
$phpmd = new PHP_PMD();
$phpmd->setFileExtensions($this->allowedFileExtensions);
$phpmd->setIgnorePattern($this->ignorePatterns);
$filesToParse = array();
if ($this->file instanceof PhingFile) {
$filesToParse[] = $this->file->getPath();
} else {
// append any files in filesets
foreach ($this->filesets as $fs) {
foreach ($fs->getDirectoryScanner($this->project)->getIncludedFiles() as $filename) {
$f = new PhingFile($fs->getDir($this->project), $filename);
$filesToParse[] = $f->getAbsolutePath();
}
}
}
if (count($filesToParse) > 0) {
$inputPath = implode(',', $filesToParse);
$this->log('Processing files...');
$phpmd->processFiles($inputPath, $this->rulesets, $reportRenderers, $ruleSetFactory);
$this->log('Finished processing files');
} else {
$this->log('No files to process');
}
}
示例11: checkFileExists
public function checkFileExists()
{
//Get the correct path to asset
switch ($this->type) {
case Asset::ASSET_TYPE_CSS:
$this->assetFolder = $this->paths['css'];
break;
case Asset::ASSET_TYPE_JS:
$this->assetFolder = $this->paths['js'];
break;
case Asset::ASSET_TYPE_IMAGE:
$this->assetFolder = $this->paths['images'];
break;
default:
$folder = '';
}
//Path to file
$file = new PhingFile($this->assetsDir . '/' . $this->assetFolder . $this->file);
//Check file exists
if (!$file->exists()) {
throw new BuildException("Unable to find asset file: " . $file->getAbsolutePath());
}
//Check we can read it
if (!$file->canRead()) {
throw IOException("Unable to read asset file: " . $file->getPath());
}
return $file;
}
示例12: setOptions
private function setOptions($pkg)
{
$options['baseinstalldir'] = 'phing';
$options['packagedirectory'] = $this->dir->getAbsolutePath();
if (empty($this->filesets)) {
throw new BuildException("You must use a <fileset> tag to specify the files to include in the package.xml");
}
$options['filelistgenerator'] = 'Fileset';
// Some PHING-specific options needed by our Fileset reader
$options['phing_project'] = $this->getProject();
$options['phing_filesets'] = $this->filesets;
if ($this->packageFile !== null) {
// create one w/ full path
$f = new PhingFile($this->packageFile->getAbsolutePath());
$options['packagefile'] = $f->getName();
// must end in trailing slash
$options['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR;
$this->log("Creating package file: " . $f->getPath(), Project::MSG_INFO);
} else {
$this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO);
}
if ($this->mode == "docs") {
$options['dir_roles'] = array('phing_guide' => 'doc', 'api' => 'doc', 'example' => 'doc');
} else {
// add install exceptions
$options['installexceptions'] = array('bin/phing.php' => '/', 'bin/pear-phing' => '/', 'bin/pear-phing.bat' => '/');
$options['dir_roles'] = array('etc' => 'data');
$options['exceptions'] = array('bin/pear-phing.bat' => 'script', 'bin/pear-phing' => 'script', 'CREDITS' => 'doc', 'CHANGELOG' => 'doc', 'README' => 'doc', 'UPGRADE' => 'doc', 'TODO' => 'doc');
}
$pkg->setOptions($options);
}
示例13: main
/**
* @throws BuildException
*/
public function main()
{
$this->checkPreconditions();
try {
$this->log('Building package: ' . $this->destinationFile->__toString(), Project::MSG_INFO);
/*
* Delete old package, if exists.
*/
if ($this->destinationFile->exists()) {
/*
* TODO Check operation for errors...
*/
$this->destinationFile->delete();
}
$phar = $this->buildPhar();
$phar->startBuffering();
$baseDirectory = realpath($this->baseDirectory->getPath());
foreach ($this->filesets as $fileset) {
foreach ($fileset as $realFileName) {
/*
* Calculate local file name.
*/
$localFileName = $realFileName;
if (0 === strpos($realFileName, $baseDirectory)) {
$localFileName = substr($realFileName, strlen($baseDirectory));
}
$this->log('Adding ' . $realFileName . ' as ' . $localFileName . ' to package', Project::MSG_VERBOSE);
$phar->addFile($realFileName, $localFileName);
}
}
$phar->stopBuffering();
} catch (Exception $e) {
throw new BuildException('Problem creating package: ' . $e->getMessage(), $e, $this->getLocation());
}
}
示例14: main
/**
* Executes PHPMD against PhingFile or a FileSet
*
* @throws BuildException - if the phpmd classes can't be loaded.
*/
public function main()
{
$className = $this->loadDependencies();
if (!isset($this->file) and count($this->filesets) == 0) {
throw new BuildException('Missing either a nested fileset or attribute "file" set');
}
if (count($this->formatters) == 0) {
// turn legacy format attribute into formatter
$fmt = new PHPMDFormatterElement();
$fmt->setType($this->format);
$fmt->setUseFile(false);
$this->formatters[] = $fmt;
}
$reportRenderers = array();
foreach ($this->formatters as $fe) {
if ($fe->getType() == '') {
throw new BuildException('Formatter missing required "type" attribute.');
}
if ($fe->getUsefile() && $fe->getOutfile() === null) {
throw new BuildException('Formatter requires "outfile" attribute when "useFile" is true.');
}
$reportRenderers[] = $fe->getRenderer();
}
// Create a rule set factory
if ($this->newVersion) {
$ruleSetClass = '\\PHPMD\\RuleSetFactory';
$ruleSetFactory = new $ruleSetClass();
//php 5.2 parser compatability
} else {
if (!class_exists("PHP_PMD_RuleSetFactory")) {
@(include 'PHP/PMD/RuleSetFactory.php');
}
$ruleSetFactory = new PHP_PMD_RuleSetFactory();
}
$ruleSetFactory->setMinimumPriority($this->minimumPriority);
$phpmd = new $className();
$phpmd->setFileExtensions($this->allowedFileExtensions);
$phpmd->setIgnorePattern($this->ignorePatterns);
$filesToParse = array();
if ($this->file instanceof PhingFile) {
$filesToParse[] = $this->file->getPath();
} else {
// append any files in filesets
foreach ($this->filesets as $fs) {
foreach ($fs->getDirectoryScanner($this->project)->getIncludedFiles() as $filename) {
$f = new PhingFile($fs->getDir($this->project), $filename);
$filesToParse[] = $f->getAbsolutePath();
}
}
}
if (count($filesToParse) > 0) {
$inputPath = implode(',', $filesToParse);
$this->log('Processing files...');
$phpmd->processFiles($inputPath, $this->rulesets, $reportRenderers, $ruleSetFactory);
$this->log('Finished processing files');
} else {
$this->log('No files to process');
}
}
示例15: main
/**
* Executes PHPCPD against PhingFile or a FileSet
*
* @throws BuildException - if the phpcpd classes can't be loaded.
*/
public function main()
{
if (class_exists('Composer\\Autoload\\ClassLoader', false) && class_exists('\\SebastianBergmann\\PHPCPD\\Detector\\Strategy\\DefaultStrategy')) {
$oldVersion = false;
} elseif ($handler = @fopen('SebastianBergmann/PHPCPD/autoload.php', 'r', true)) {
fclose($handler);
@(include_once 'SebastianBergmann/PHPCPD/autoload.php');
if (version_compare(PHP_VERSION, '5.3.0') < 0) {
throw new BuildException('The PHPCPD task now requires PHP 5.3+');
}
$oldVersion = false;
} elseif ($handler = @fopen('PHPCPD/Autoload.php', 'r', true)) {
fclose($handler);
@(include_once 'PHPCPD/Autoload.php');
$oldVersion = true;
} else {
throw new BuildException('PHPCPDTask depends on PHPCPD being installed and on include_path.', $this->getLocation());
}
if (!isset($this->file) && count($this->filesets) == 0) {
throw new BuildException('Missing either a nested fileset or attribute "file" set');
}
if (count($this->formatters) == 0) {
// turn legacy format attribute into formatter
$fmt = new PHPCPDFormatterElement($this);
$fmt->setType($this->format);
$fmt->setUseFile(false);
$this->formatters[] = $fmt;
}
$this->validateFormatters();
$filesToParse = array();
if ($this->file instanceof PhingFile) {
$filesToParse[] = $this->file->getPath();
} else {
// append any files in filesets
foreach ($this->filesets as $fs) {
$files = $fs->getDirectoryScanner($this->project)->getIncludedFiles();
foreach ($files as $filename) {
$f = new PhingFile($fs->getDir($this->project), $filename);
$filesToParse[] = $f->getAbsolutePath();
}
}
}
$this->log('Processing files...');
if ($oldVersion) {
$detectorClass = 'PHPCPD_Detector';
$strategyClass = 'PHPCPD_Detector_Strategy_Default';
} else {
$detectorClass = '\\SebastianBergmann\\PHPCPD\\Detector\\Detector';
$strategyClass = '\\SebastianBergmann\\PHPCPD\\Detector\\Strategy\\DefaultStrategy';
}
$detector = new $detectorClass(new $strategyClass());
$clones = $detector->copyPasteDetection($filesToParse, $this->minLines, $this->minTokens);
$this->log('Finished copy/paste detection');
foreach ($this->formatters as $fe) {
$formatter = $fe->getFormatter();
$formatter->processClones($clones, $this->project, $fe->getUseFile(), $fe->getOutfile());
}
}