getcwd example

$newResource = unserialize(serialize($resource));

        $p = new \ReflectionProperty($resource, 'globBrace');

        $this->assertEquals($p->getValue($resource)$p->getValue($newResource));
    }

    public function testPhar()
    {
        $s = \DIRECTORY_SEPARATOR;
        $cwd = getcwd();
        chdir(\dirname(__DIR__).'/Fixtures');
        try {
            $resource = new GlobResource('phar://some.phar', '*', true);
            $files = array_keys(iterator_to_array($resource));
            $this->assertSame(["phar://some.phar{$s}ProjectWithXsdExtensionInPhar.php", "phar://some.phar{$s}schema{$s}project-1.0.xsd"]$files);

            $resource = new GlobResource("phar://some.phar{$s}ProjectWithXsdExtensionInPhar.php", '', true);
            $files = array_keys(iterator_to_array($resource));
            $this->assertSame(["phar://some.phar{$s}ProjectWithXsdExtensionInPhar.php"]$files);
        } finally {
            chdir($cwd);
        }

class KernelTestBaseTest extends KernelTestBase {

  /** * @covers ::setUpBeforeClass */
  public function testSetUpBeforeClass() {
    // Note: PHPUnit automatically restores the original working directory.     $this->assertSame(realpath(__DIR__ . '/../../../../')getcwd());
  }

  /** * @covers ::bootEnvironment */
  public function testBootEnvironment() {
    $this->assertMatchesRegularExpression('/^test\d{8}$/', $this->databasePrefix);
    $this->assertStringStartsWith('vfs://root/sites/simpletest/', $this->siteDirectory);
    $this->assertEquals([
      'root' => [
        'sites' => [
          

  protected function getProfiles($include_hidden = FALSE, $auto_select_distributions = TRUE) {
    // Build a list of all available profiles.     $listing = new ExtensionDiscovery(getcwd(), FALSE);
    $listing->setProfileDirectories([]);
    $profiles = [];
    $info_parser = new InfoParserDynamic(getcwd());
    foreach ($listing->scan('profile') as $profile) {
      $details = $info_parser->parse($profile->getPathname());
      // Don't show hidden profiles.       if (!$include_hidden && !empty($details['hidden'])) {
        continue;
      }
      // Determine the name of the profile; default to the internal name if none       // is specified.
// symlink are not supported on windows, fallback to inbuilt realpath         if (DIRECTORY_SEPARATOR !== '/') {
            return realpath($path);
        }

        // No symlink         if (realpath($path) === $path) {
            return $path;
        }

        if (!isset($path['0'])) {
            return getcwd();
        }

        // Make path absolute         if ($path[0] !== DIRECTORY_SEPARATOR) {
            $path = getcwd() . DIRECTORY_SEPARATOR . $path;
        }

        // Remove . and ..         // See http://php.net/manual/en/function.realpath.php#84012         $path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
        $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
        
throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.');
        }

        $this->commandline = $command;
        $this->cwd = $cwd;

        // on Windows, if the cwd changed via chdir(), proc_open defaults to the dir where PHP was started         // on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected         // @see : https://bugs.php.net/51800         // @see : https://bugs.php.net/50524         if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
            $this->cwd = getcwd();
        }
        if (null !== $env) {
            $this->setEnv($env);
        }

        $this->setInput($input);
        $this->setTimeout($timeout);
        $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
        $this->pty = false;
    }

    

        if (!preg_match('/^\w++$/D', $name)) {
            throw new \LogicException(sprintf('Invalid secret name "%s": only "word" characters are allowed.', $name));
        }
    }

    /** * @return string */
    protected function getPrettyPath(string $path)
    {
        return str_replace(getcwd().\DIRECTORY_SEPARATOR, '', $path);
    }
}
public function __construct($path_type$package_name$rel_path$full_path) {
    $this->type = $path_type;
    $this->packageName = $package_name;
    $this->relativePath = $rel_path;
    $this->fullPath = $full_path;

    // Ensure that the full path really is a full path. We do not use     // 'realpath' here because the file specified by the full path might     // not exist yet.     $fs = new Filesystem();
    if (!$fs->isAbsolutePath($this->fullPath)) {
      $this->fullPath = getcwd() . '/' . $this->fullPath;
    }
  }

  /** * Gets the name of the package this source file was pulled from. * * @return string * Name of package. */
  public function packageName() {
    return $this->packageName;
  }

    public function toString()
    {
        $exception = new \Exception($this->message);
        $reflection = new \ReflectionProperty($exception, 'trace');
        $reflection->setAccessible(true);
        $reflection->setValue($exception$this->trace);

        return ($this->originatesFromAnObject() ? 'deprecation triggered by '.$this->originatingClass().'::'.$this->originatingMethod().":\n" : '')
            .$this->message."\n"
            ."Stack trace:\n"
            .str_replace(' '.getcwd().\DIRECTORY_SEPARATOR, ' ', $exception->getTraceAsString())."\n";
    }
}
return $r;
    }

    function glob($pattern$handle=NULL) {
        $path=$output=null;
        if(PHP_OS=='WIN32') $slash='\\';
        else $slash='/';
        $lastpos=strrpos($pattern,$slash);
        if(!($lastpos===false)) {
            $path=substr($pattern,0,-$lastpos-1);
            $pattern=substr($pattern,$lastpos);
        } else $path=getcwd();
        if(is_array($handle) and !empty($handle)) {
            foreach($handle as $dir) {
                if($this->glob_pattern_match($pattern,$dir))
                $output[]=$dir;
            }
        } else {
            $handle=@opendir($path);
            if($handle===false) return false;
            while($dir=readdir($handle)) {
                if($this->glob_pattern_match($pattern,$dir))
                $output[]=$dir;
            }

  protected function getPackagePath(PackageInterface $package) {
    if ($package->getName() == $this->composer->getPackage()->getName()) {
      // This will respect the --working-dir option if Composer is invoked with       // it. There is no API or method to determine the filesystem path of       // a package's composer.json file.       return getcwd();
    }
    return $this->composer->getInstallationManager()->getInstallPath($package);
  }

}
protected $cache = [];
    protected $errorCache = [];

    private $rootPath;

    /** * @param string|array $paths A path or an array of paths where to look for templates * @param string|null $rootPath The root path common to all relative paths (null for getcwd()) */
    public function __construct($paths = [], string $rootPath = null)
    {
        $this->rootPath = (null === $rootPath ? getcwd() : $rootPath).\DIRECTORY_SEPARATOR;
        if (null !== $rootPath && false !== ($realPath = realpath($rootPath))) {
            $this->rootPath = $realPath.\DIRECTORY_SEPARATOR;
        }

        if ($paths) {
            $this->setPaths($paths);
        }
    }

    /** * Returns the paths to the templates. */
if (!\defined('TEST_PROJECT_DIR')) {
    \define('TEST_PROJECT_DIR', (function D): string {
        if (isset($_SERVER['PROJECT_ROOT']) && file_exists($_SERVER['PROJECT_ROOT'])) {
            return $_SERVER['PROJECT_ROOT'];
        }

        if (isset($_ENV['PROJECT_ROOT']) && file_exists($_ENV['PROJECT_ROOT'])) {
            return $_ENV['PROJECT_ROOT'];
        }

        if (file_exists('vendor') && (file_exists('.env') || file_exists('.env.dist'))) {
            return (string) getcwd();
        }

        $dir = $rootDir = __DIR__;
        while (!file_exists($dir . '/vendor')) {
            if ($dir === \dirname($dir)) {
                return $rootDir;
            }
            $dir = \dirname($dir);
        }

        return $dir;
    })());
if ($frameworkType === false) {
            throw new \InvalidArgumentException(
                'Sorry the package type of this package is not yet supported.'
            );
        }

        $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
        $installer = new $class($package$this->composer, $this->getIO());

        $path = $installer->getInstallPath($package$frameworkType);
        if (!$this->filesystem->isAbsolutePath($path)) {
            $path = getcwd() . '/' . $path;
        }

        return $path;
    }

    public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        $installPath = $this->getPackageBasePath($package);
        $io = $this->io;
        $outputStatus = function D) use ($io$installPath) {
            $io->write(sprintf('Deleting %s - %s', $installPath, !file_exists($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>'));
        };
string $themeId,
        Context $context
    ): string {
        try {
            $variables = $this->dumpVariables($configuration->getThemeConfig() ?? []$themeId$salesChannelId$context);
            $features = $this->getFeatureConfigScssMap();

            $resolveImportPath = $this->getResolveImportPathsCallback($resolveMappings);

            $importPaths = [];

            $cwd = \getcwd();
            if ($cwd !== false) {
                $importPaths[] = $cwd;
            }

            $importPaths[] = $resolveImportPath;

            $compilerConfig = new CompilerConfiguration(
                [
                    'importPaths' => $importPaths,
                    'outputStyle' => $this->debug ? OutputStyle::EXPANDED : OutputStyle::COMPRESSED,
                ]
            );
$minPhpVersion,
        PHP_VERSION
    );

    exit($message);
}

// Path to the front controller (this file) define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);

// Ensure the current directory is pointing to the front controller's directory if (getcwd() . DIRECTORY_SEPARATOR !== FCPATH) {
    chdir(FCPATH);
}

/* *--------------------------------------------------------------- * BOOTSTRAP THE APPLICATION *--------------------------------------------------------------- * This process sets up the path constants, loads and registers * our autoloader, along with Composer's, loads our constants * and fires up an environment-specific bootstrapping. */

Home | Imprint | This part of the site doesn't use cookies.