本文整理汇总了PHP中Phing::__import方法的典型用法代码示例。如果您正苦于以下问题:PHP Phing::__import方法的具体用法?PHP Phing::__import怎么用?PHP Phing::__import使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phing
的用法示例。
在下文中一共展示了Phing::__import方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefinedClasses
/**
* @param string the filename
* @param Path optional classpath
* @return array list of classes defined in the file
*/
static function getDefinedClasses($filename, $classpath = NULL)
{
$filename = realpath($filename);
if (!file_exists($filename)) {
throw new Exception("File '" . $filename . "' does not exist");
}
if (isset(self::$definedClasses[$filename])) {
return self::$definedClasses[$filename];
}
Phing::__import($filename, $classpath);
$declaredClasses = get_declared_classes();
foreach ($declaredClasses as $classname) {
$reflect = new ReflectionClass($classname);
self::$definedClasses[$reflect->getFilename()][] = $classname;
if (is_array(self::$definedClasses[$reflect->getFilename()])) {
self::$definedClasses[$reflect->getFilename()] = array_unique(self::$definedClasses[$reflect->getFilename()]);
}
}
if (isset(self::$definedClasses[$filename])) {
return self::$definedClasses[$filename];
} else {
return array();
}
}
示例2: import
/**
* Import a path, supporting the following conventions:
* - PEAR style (@link http://pear.php.net/manual/en/standards.naming.php)
* - PSR-0 (@link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md)
* - dot-path
*
* @param string $dotPath Path
* @param mixed $classpath String or object supporting __toString()
*
* @return string The unqualified classname (which can be instantiated).
*
* @throws BuildException - if cannot find the specified file
*/
public static function import($dotPath, $classpath = null)
{
if (strpos($dotPath, '.') !== false) {
$classname = StringHelper::unqualify($dotPath);
} else {
$classname = $dotPath;
$dotPath = '';
$shortClassName = $classname;
if ($lastNsPos = strripos($shortClassName, '\\')) {
$namespace = substr($shortClassName, 0, $lastNsPos);
$shortClassName = substr($shortClassName, $lastNsPos + 1);
$dotPath = str_replace('\\', '.', $namespace) . '.';
}
$dotPath .= str_replace('_', '.', $shortClassName);
}
// first check to see that the class specified hasn't already been included.
// (this also handles case where this method is called w/ a classname rather than dotpath)
if (class_exists($classname)) {
return $classname;
}
$dotClassname = basename($dotPath);
$dotClassnamePos = strlen($dotPath) - strlen($dotClassname);
// 1- temporarily replace escaped '.' with another illegal char (#)
$tmp = str_replace('\\.', '##', $dotClassname);
// 2- swap out the remaining '.' with DIR_SEP
$tmp = strtr($tmp, '.', DIRECTORY_SEPARATOR);
// 3- swap back the escaped '.'
$tmp = str_replace('##', '.', $tmp);
$classFile = $tmp . ".php";
$path = substr_replace($dotPath, $classFile, $dotClassnamePos);
Phing::__import($path, $classpath);
return $classname;
}
示例3: import
/**
* Import a dot-path notation class path.
* @param string $dotPath
* @param mixed $classpath String or object supporting __toString()
* @return string The unqualified classname (which can be instantiated).
* @throws BuildException - if cannot find the specified file
*/
public static function import($dotPath, $classpath = null)
{
/// check if this is a PEAR-style path (@link http://pear.php.net/manual/en/standards.naming.php)
if (strpos($dotPath, '.') === false && strpos($dotPath, '_') !== false) {
$classname = $dotPath;
$dotPath = str_replace('_', '.', $dotPath);
} else {
$classname = StringHelper::unqualify($dotPath);
}
// first check to see that the class specified hasn't already been included.
// (this also handles case where this method is called w/ a classname rather than dotpath)
if (class_exists($classname)) {
return $classname;
}
$dotClassname = basename($dotPath);
$dotClassnamePos = strlen($dotPath) - strlen($dotClassname);
// 1- temporarily replace escaped '.' with another illegal char (#)
$tmp = str_replace('\\.', '##', $dotClassname);
// 2- swap out the remaining '.' with DIR_SEP
$tmp = strtr($tmp, '.', DIRECTORY_SEPARATOR);
// 3- swap back the escaped '.'
$tmp = str_replace('##', '.', $tmp);
$classFile = $tmp . ".php";
$path = substr_replace($dotPath, $classFile, $dotClassnamePos);
Phing::__import($path, $classpath);
return $classname;
}
示例4: main
function main()
{
$files = $this->getFilenames();
$this->log("Setting up coverage database for " . count($files) . " files");
$props = new Properties();
foreach ($files as $file) {
$fullname = $file['fullname'];
$filename = $file['key'];
$props->setProperty($filename, serialize(array('fullname' => $fullname, 'coverage' => array())));
}
$dbfile = new PhingFile($this->database);
$props->store($dbfile);
$this->project->setProperty('coverage.database', $dbfile->getAbsolutePath());
foreach ($files as $file) {
$fullname = $file['fullname'];
xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
Phing::__import($fullname, $this->classpath);
$coverage = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
CoverageMerger::merge($this->project, array($coverage));
}
}
示例5: import
/**
* Import a dot-path notation class path.
* @param string $dotPath
* @param mixed $classpath String or object supporting __toString()
* @return string The unqualified classname (which can be instantiated).
* @throws BuildException - if cannot find the specified file
*/
public static function import($dotPath, $classpath = null)
{
// first check to see that the class specified hasn't already been included.
// (this also handles case where this method is called w/ a classname rather than dotpath)
$classname = StringHelper::unqualify($dotPath);
if (class_exists($classname, false)) {
return $classname;
}
$dotClassname = basename($dotPath);
$dotClassnamePos = strlen($dotPath) - strlen($dotClassname);
$classFile = strtr($dotClassname, '.', DIRECTORY_SEPARATOR) . ".php";
$path = substr_replace($dotPath, $classFile, $dotClassnamePos);
Phing::__import($path, $classpath);
return $classname;
}