PHPUnit_Util_Filesystem::fileExistsInIncludePath PHP Method

fileExistsInIncludePath() public static method

Implementation of stream_resolve_include_path() in PHP for version before PHP 5.3.2.
Author: Mattis Stordalen Flister ([email protected])
public static fileExistsInIncludePath ( string $file ) : mixed
$file string
return mixed
    public static function fileExistsInIncludePath($file)
    {
        if (function_exists('stream_resolve_include_path')) {
            return stream_resolve_include_path($file);
        }
        if (file_exists($file)) {
            return realpath($file);
        }
        $paths = explode(PATH_SEPARATOR, get_include_path());
        foreach ($paths as $path) {
            $fullpath = $path . DIRECTORY_SEPARATOR . $file;
            if (file_exists($fullpath)) {
                return realpath($fullpath);
            }
        }
        return FALSE;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param string $type      The type of concrete Log subclass to use.
  *                          Currently, valid values are 'console',
  *                          'syslog', 'sql', 'file', and 'mcal'.
  * @param string $name      The name of the actually log file, table, or
  *                          other specific store to use. Defaults to an
  *                          empty string, with which the subclass will
  *                          attempt to do something intelligent.
  * @param string $ident     The identity reported to the log system.
  * @param array  $conf      A hash containing any additional configuration
  *                          information that a subclass might need.
  * @param int $maxLevel     Maximum priority level at which to log.
  */
 public function __construct($type, $name = '', $ident = '', $conf = array(), $maxLevel = PEAR_LOG_DEBUG)
 {
     if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('Log.php')) {
         require_once 'Log.php';
     } else {
         throw new RuntimeException('Log is not available.');
     }
     $this->log = Log::factory($type, $name, $ident, $conf, $maxLevel);
 }
All Usage Examples Of PHPUnit_Util_Filesystem::fileExistsInIncludePath