本文整理汇总了PHP中Webmozart\PathUtil\Path::canonicalize方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::canonicalize方法的具体用法?PHP Path::canonicalize怎么用?PHP Path::canonicalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\PathUtil\Path
的用法示例。
在下文中一共展示了Path::canonicalize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($baseDir = null, array $mappings = array(), UriRetrieverInterface $fallbackRetriever = null)
{
$this->baseDir = $baseDir ? Path::canonicalize($baseDir) : null;
$this->mappings = $mappings;
$this->filesystemRetriever = new FileGetContents();
$this->fallbackRetriever = $fallbackRetriever ?: $this->filesystemRetriever;
}
示例2: __construct
/**
* Creates the environment.
*
* @param string|null $homeDir The path to the home
* directory or `null` if
* none exists.
* @param string $rootDir The path to the project's
* root directory.
* @param Config $config The configuration.
* @param RootPackageFile $rootPackageFile The root package file.
* @param ConfigFile $configFile The configuration file or
* `null` if none exists.
* @param EventDispatcherInterface $dispatcher The event dispatcher.
*/
public function __construct($homeDir, $rootDir, Config $config, RootPackageFile $rootPackageFile, ConfigFile $configFile = null, EventDispatcherInterface $dispatcher = null)
{
Assert::directory($rootDir, 'The root directory %s is not a directory.');
parent::__construct($homeDir, $config, $configFile, $dispatcher);
$this->rootDir = Path::canonicalize($rootDir);
$this->rootPackageFile = $rootPackageFile;
}
示例3: __construct
/**
* Creates the context.
*
* @param string|null $homeDir The path to the home directory
* or `null` if none exists.
* @param Config $config The configuration.
* @param ConfigFile $configFile The configuration file or
* `null` if none exists.
* @param EventDispatcherInterface $dispatcher The event dispatcher.
*/
public function __construct($homeDir, Config $config, ConfigFile $configFile = null, EventDispatcherInterface $dispatcher = null)
{
Assert::nullOrDirectory($homeDir, 'The home directory %s is not a directory.');
$this->homeDir = $homeDir ? Path::canonicalize($homeDir) : null;
$this->config = $config;
$this->dispatcher = $dispatcher ?: new EventDispatcher();
$this->configFile = $configFile;
}
示例4: __construct
/**
* Creates the context.
*
* @param string|null $homeDir The path to the
* home directory or
* `null` if none
* exists.
* @param string $rootDir The path to the
* project's root
* directory.
* @param Config $config The configuration.
* @param RootModuleFile $rootModuleFile The root module
* file.
* @param ConfigFile|null $configFile The configuration
* file or `null` if
* none exists.
* @param EventDispatcherInterface|null $dispatcher The event
* dispatcher.
* @param string $env The environment
* that Puli is
* running in.
*/
public function __construct($homeDir, $rootDir, Config $config, RootModuleFile $rootModuleFile, ConfigFile $configFile = null, EventDispatcherInterface $dispatcher = null, $env = Environment::DEV)
{
Assert::directory($rootDir, 'The root directory %s is not a directory.');
Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
parent::__construct($homeDir, $config, $configFile, $dispatcher);
$this->rootDir = Path::canonicalize($rootDir);
$this->rootModuleFile = $rootModuleFile;
$this->env = $env;
}
示例5: resolvePath
/**
* Return the path with the basePath prefix
* if it has been set.
*
* @param string $path
*
* @return string
*/
protected function resolvePath($path)
{
Assert::stringNotEmpty($path, 'The path must be a non-empty string. Got: %s');
Assert::startsWith($path, '/', 'The path %s is not absolute.');
if ($this->basePath) {
$path = $this->basePath . $path;
}
$path = Path::canonicalize($path);
return $path;
}
示例6: toAssetPath
private function toAssetPath($filePath, $rootDirectory)
{
$canonicalRootDir = Path::canonicalize($rootDirectory);
$asset = str_replace($canonicalRootDir, "", $filePath);
// Strip leading slash
if (substr($asset, 0, 1) === "/") {
$asset = substr($asset, 1);
}
return $asset;
}
示例7: phpunitConfig
private function phpunitConfig(array $argv)
{
if (count($argv) > 0) {
$original = file_get_contents($argv[0]);
$fix = Path::canonicalize('../' . $this->fs->relativePath(dirname($argv[0])));
} else {
$original = '<phpunit />';
$fix = null;
}
return $this->phpunit_config_generator->generate($original, $fix);
}
示例8: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$container->setParameter('acme_php.domains_configurations', (array) $config['domains']);
$container->setParameter('acme_php.certificate_dir', Path::canonicalize($config['certificate_dir']));
$container->setParameter('acme_php.certificate_authority', $config['certificate_authority']);
$container->setParameter('acme_php.contact_email', $config['contact_email']);
}
示例9: execute
/**
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$logger = new ConsoleLogger($output);
$from = Path::canonicalize($input->getArgument('from'));
$to = Path::canonicalize($input->getArgument('to'));
$fromResult = $this->getResult($from, $logger);
$toResult = $this->getResult($to, $logger);
$logger->writeln("generate diff");
$diff = $this->calculator->diff($fromResult, $toResult);
$output->writeln($this->format($diff));
}
示例10: run
/**
* @param string $path
* @param array $config
* @param AbstractLogger $logger
* @return Result
*/
public function run($path, array $config, AbstractLogger $logger = null)
{
$path = Path::canonicalize($path);
$logger = $logger ?: new NullLogger();
$event = new ExecutorEvent($path, $config, $logger);
$this->eventDispatcher->dispatch(Events::PRE_EXECUTE, $event);
$config = $event->getConfig();
$result = $this->executeGadgets($path, $config, $logger);
$event = new ExecutorResultEvent($path, $config, $result, $logger);
$this->eventDispatcher->dispatch(Events::POST_EXECUTE, $event);
return $result;
}
示例11: decode
private function decode($json, $path = null)
{
$decoder = new JsonDecoder();
// We can't use realpath(), which doesn't work inside PHARs.
// However, we want to display nice paths if the file is not found.
$schema = $decoder->decodeFile(Path::canonicalize(__DIR__ . '/../../res/schema/package-schema-1.0.json'));
$configSchema = $schema->properties->config;
try {
return $decoder->decode($json, $configSchema);
} catch (ValidationFailedException $e) {
throw new InvalidConfigException(sprintf("The configuration%s is invalid:\n%s", $path ? ' in ' . $path : '', $e->getErrorsAsString()), 0, $e);
} catch (DecodingFailedException $e) {
throw new InvalidConfigException(sprintf("The configuration%s could not be decoded:\n%s", $path ? ' in ' . $path : '', $e->getMessage()), $e->getCode(), $e);
}
}
示例12: __construct
/**
* @param string $taskrc
* @param string $taskData
* @param array $rcOptions
* @param string $bin
* @throws TaskwarriorException
*/
public function __construct($taskrc = '~/.taskrc', $taskData = '~/.task', $rcOptions = [], $bin = 'task')
{
$this->bin = Path::canonicalize($bin);
$this->taskrc = Path::canonicalize($taskrc);
$this->taskData = Path::canonicalize($taskData);
$this->rcOptions = array_merge(array('rc:' . $this->taskrc, 'rc.data.location=' . $this->taskData, 'rc.json.array=true', 'rc.json.depends.array=true', 'rc.confirmation=no'), $rcOptions);
if (version_compare($this->version(), '2.5.0') < 0) {
throw new TaskwarriorException(sprintf("Taskwarrior version %s isn't supported", $this->version()));
}
try {
Assert::readable($this->taskrc);
Assert::readable($this->taskData);
Assert::writable($this->taskData);
} catch (\InvalidArgumentException $e) {
throw new TaskwarriorException($e->getMessage(), $e->getCode(), $e);
}
}
示例13: encodeFile
private function encodeFile($jsonData, $path)
{
if (!is_string($path) || !Path::isAbsolute($path)) {
throw new IOException(sprintf('Cannot write "%s": Expected an absolute path.', $path));
}
if (is_dir($path)) {
throw new IOException(sprintf('Cannot write %s: Is a directory.', $path));
}
$encoder = new JsonEncoder();
$encoder->setPrettyPrinting(true);
$encoder->setEscapeSlash(false);
$encoder->setTerminateWithLineFeed(true);
$decoder = new JsonDecoder();
// We can't use realpath(), which doesn't work inside PHARs.
// However, we want to display nice paths if the file is not found.
$schema = $decoder->decodeFile(Path::canonicalize(__DIR__ . '/../../res/schema/package-schema-1.0.json'));
$configSchema = $schema->properties->config;
if (!is_dir($dir = Path::getDirectory($path))) {
$filesystem = new Filesystem();
$filesystem->mkdir($dir);
}
$encoder->encodeFile($jsonData, $path, $configSchema);
}
示例14: loadConfigFile
private function loadConfigFile($homeDir, Config $baseConfig)
{
if (null === $homeDir) {
return null;
}
Assert::fileExists($homeDir, 'Could not load Puli context: The home directory %s does not exist.');
Assert::directory($homeDir, 'Could not load Puli context: The home directory %s is a file. Expected a directory.');
// Create a storage without the factory manager
$configStorage = new ConfigFileStorage($this->getStorage(), $this->getConfigFileSerializer());
$configPath = Path::canonicalize($homeDir) . '/config.json';
try {
return $configStorage->loadConfigFile($configPath, $baseConfig);
} catch (FileNotFoundException $e) {
// It's ok if no config.json exists. We'll work with
// DefaultConfig instead
return null;
}
}
示例15: testInsertFactoryClassIntoClassMap
public function testInsertFactoryClassIntoClassMap()
{
$listeners = $this->plugin->getSubscribedEvents();
$this->assertArrayHasKey(ScriptEvents::POST_AUTOLOAD_DUMP, $listeners);
$listener = $listeners[ScriptEvents::POST_AUTOLOAD_DUMP];
$event = new CommandEvent(ScriptEvents::POST_AUTOLOAD_DUMP, $this->composer, $this->io);
$this->io->expects($this->at(0))->method('write')->with('<info>Generating PULI_FACTORY_CLASS constant</info>');
$this->io->expects($this->at(1))->method('write')->with('<info>Registering Puli\\MyFactory with the class-map autoloader</info>');
$this->io->expects($this->never())->method('writeError');
$this->puliRunner->expects($this->at(0))->method('run')->with("config 'factory.in.class' --parsed")->willReturn("Puli\\MyFactory\n");
$this->puliRunner->expects($this->at(1))->method('run')->with("config 'factory.in.file' --parsed")->willReturn("My/Factory.php\n");
$this->plugin->{$listener}($event);
$this->assertFileExists($this->tempDir . '/the-vendor/composer/autoload_classmap.php');
$classMap = (require $this->tempDir . '/the-vendor/composer/autoload_classmap.php');
$this->assertInternalType('array', $classMap);
$this->assertArrayHasKey('Puli\\MyFactory', $classMap);
$this->assertSame($this->tempDir . '/My/Factory.php', Path::canonicalize($classMap['Puli\\MyFactory']));
}