本文整理汇总了PHP中Composer\IO\IOInterface::writeError方法的典型用法代码示例。如果您正苦于以下问题:PHP IOInterface::writeError方法的具体用法?PHP IOInterface::writeError怎么用?PHP IOInterface::writeError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\IO\IOInterface
的用法示例。
在下文中一共展示了IOInterface::writeError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createConfig
public static function createConfig(IOInterface $io = null, $cwd = null)
{
$cwd = $cwd ?: getcwd();
$home = self::getHomeDir();
$cacheDir = self::getCacheDir($home);
foreach (array($home, $cacheDir) as $dir) {
if (!file_exists($dir . '/.htaccess')) {
if (!is_dir($dir)) {
@mkdir($dir, 0777, true);
}
@file_put_contents($dir . '/.htaccess', 'Deny from all');
}
}
$config = new Config(true, $cwd);
$config->merge(array('config' => array('home' => $home, 'cache-dir' => $cacheDir)));
$file = new JsonFile($config->get('home') . '/config.json');
if ($file->exists()) {
if ($io && $io->isDebug()) {
$io->writeError('Loading config file ' . $file->getPath());
}
$config->merge($file->read());
}
$config->setConfigSource(new JsonConfigSource($file));
$file = new JsonFile($config->get('home') . '/auth.json');
if ($file->exists()) {
if ($io && $io->isDebug()) {
$io->writeError('Loading config file ' . $file->getPath());
}
$config->merge(array('config' => $file->read()));
}
$config->setAuthConfigSource(new JsonConfigSource($file, true));
return $config;
}
示例2: selectPackage
protected function selectPackage(IOInterface $io, $packageName, $version = null)
{
$io->writeError('<info>Searching for the specified package.</info>');
if ($composer = $this->getComposer(false)) {
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
$repos = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
} else {
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
$io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
$repos = new CompositeRepository($defaultRepos);
}
$pool = new Pool();
$pool->addRepository($repos);
$parser = new VersionParser();
$constraint = $version ? $parser->parseConstraints($version) : null;
$packages = $pool->whatProvides($packageName, $constraint, true);
if (count($packages) > 1) {
$package = reset($packages);
$io->writeError('<info>Found multiple matches, selected ' . $package->getPrettyString() . '.</info>');
$io->writeError('Alternatives were ' . implode(', ', array_map(function ($p) {
return $p->getPrettyString();
}, $packages)) . '.');
$io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
} elseif ($packages) {
$package = reset($packages);
$io->writeError('<info>Found an exact match ' . $package->getPrettyString() . '.</info>');
} else {
$io->writeError('<error>Could not find a package matching ' . $packageName . '.</error>');
return false;
}
return $package;
}
示例3: registerStudioPackages
/**
* Register all managed paths with Composer.
*
* This function configures Composer to treat all Studio-managed paths as local path repositories, so that packages
* therein will be symlinked directly.
*/
public function registerStudioPackages()
{
$repoManager = $this->composer->getRepositoryManager();
$composerConfig = $this->composer->getConfig();
foreach ($this->getManagedPaths() as $path) {
$this->io->writeError("[Studio] Loading path {$path}");
$repoManager->prependRepository(new PathRepository(['url' => $path], $this->io, $composerConfig));
}
}
示例4: log
/**
* Write a message
*
* @param string $message
*/
protected function log($message)
{
if (method_exists($this->inputOutput, 'writeError')) {
$this->inputOutput->writeError($message);
} else {
// @codeCoverageIgnoreStart
// Backwards compatiblity for Composer before cb336a5
$this->inputOutput->write($message);
// @codeCoverageIgnoreEnd
}
}
示例5: error
/**
* Print an error line.
*
* @param string $message
* @return bool Always false
*/
public function error($message)
{
if ($message && $this->verbosity > 0) {
$tag = 'bg=red;fg=white;option=bold>';
$lines = $this->ensureLength($message);
$this->io->write('');
foreach ($lines as $line) {
$this->io->writeError(" <{$tag} " . $line . " </{$tag}");
}
$this->io->write('');
}
return false;
}
示例6: debug
/**
* Log a debug message
*
* Messages will be output at the "verbose" logging level (eg `-v` needed
* on the Composer command).
*
* @param string $message
*/
public function debug($message)
{
if ($this->inputOutput->isVerbose()) {
$message = " <info>[{$this->name}]</info> {$message}";
if (method_exists($this->inputOutput, 'writeError')) {
$this->inputOutput->writeError($message);
} else {
// @codeCoverageIgnoreStart
// Backwards compatiblity for Composer before cb336a5
$this->inputOutput->write($message);
// @codeCoverageIgnoreEnd
}
}
}
示例7: process
public function process(Config\Template $tmpl)
{
/* process template if condition is not set or condition is valid */
if ($tmpl->getCondition() == null || $this->conditionValidator->isValid($tmpl->getCondition(), $this->vars)) {
/* load source file */
if (is_file($tmpl->getSource())) {
$content = file_get_contents($tmpl->getSource());
/* replace all vars by values */
if (is_array($this->vars)) {
foreach ($this->vars as $key => $value) {
$content = str_replace('${' . $key . '}', $value, $content);
}
}
/* save destination file */
if (is_file($tmpl->getDestination()) && !$tmpl->isCanRewrite()) {
$this->io->write(__CLASS__ . ": <comment>Destination file '{$tmpl->getDestination()}' is already exist and cannot be rewrote (rewrite = false).</comment>");
} else {
$this->fileSaver->save($tmpl->getDestination(), $content);
$this->io->write(__CLASS__ . ": <info>Destination file '{$tmpl->getDestination()}' is created from source template '{$tmpl->getSource()}'.</info>");
}
} else {
$this->io->writeError(__CLASS__ . ": <error>Cannot open source template ({$tmpl->getSource()}).</error>");
}
} else {
/* there is wrong condition for template */
$outSrc = $tmpl->getSource();
$cond = $tmpl->getCondition();
$outCond = '${' . $cond->getVar() . '}' . $cond->getOperation() . $cond->getValue();
$this->io->write(__CLASS__ . ": <comment>Skip processing of the template ({$outSrc}) because condition ({$outCond}) is 'false'.</comment>");
}
}
示例8: cleanPackage
/**
* Clean a package, based on its rules.
*
* @param BasePackage $package The package to clean
* @return bool True if cleaned
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function cleanPackage(BasePackage $package)
{
$vendorDir = $this->config->get('vendor-dir');
$targetDir = $package->getTargetDir();
$packageName = $package->getPrettyName();
$packageDir = $targetDir ? $packageName . '/' . $targetDir : $packageName;
$rules = isset($this->rules[$packageName]) ? $this->rules[$packageName] : null;
if (!$rules) {
$this->io->writeError('Rules not found: ' . $packageName);
return false;
}
$dir = $this->filesystem->normalizePath(realpath($vendorDir . '/' . $packageDir));
if (!is_dir($dir)) {
$this->io->writeError('Vendor dir not found: ' . $vendorDir . '/' . $packageDir);
return false;
}
//$this->io->write('Rules: ' . print_r($rules, true));
foreach ((array) $rules as $part) {
// Split patterns for single globs (should be max 260 chars)
$patterns = (array) $part;
foreach ($patterns as $pattern) {
try {
foreach (glob($dir . '/' . $pattern) as $file) {
$this->filesystem->remove($file);
//$this->io->write('File removed: ' . $file);
}
} catch (\Exception $e) {
$this->io->write("Could not parse {$packageDir} ({$pattern}): " . $e->getMessage());
}
}
}
return true;
}
示例9: solve
/**
* @param Request $request
* @param bool $ignorePlatformReqs
* @return array
*/
public function solve(Request $request, $ignorePlatformReqs = false)
{
$this->jobs = $request->getJobs();
$this->setupInstalledMap();
$this->rules = $this->ruleSetGenerator->getRulesFor($this->jobs, $this->installedMap, $ignorePlatformReqs);
$this->checkForRootRequireProblems($ignorePlatformReqs);
$this->decisions = new Decisions($this->pool);
$this->watchGraph = new RuleWatchGraph();
foreach ($this->rules as $rule) {
$this->watchGraph->insert(new RuleWatchNode($rule));
}
/* make decisions based on job/update assertions */
$this->makeAssertionRuleDecisions();
$this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
$before = microtime(true);
$this->runSat(true);
$this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
// decide to remove everything that's installed and undecided
foreach ($this->installedMap as $packageId => $void) {
if ($this->decisions->undecided($packageId)) {
$this->decisions->decide(-$packageId, 1, null);
}
}
if ($this->problems) {
throw new SolverProblemsException($this->problems, $this->installedMap);
}
$transaction = new Transaction($this->policy, $this->pool, $this->installedMap, $this->decisions);
return $transaction->getOperations();
}
示例10: createLoader
/**
* Registers an autoloader based on an autoload map returned by parseAutoloads
*
* @param array $autoloads see parseAutoloads return value
* @return ClassLoader
*/
public function createLoader(array $autoloads)
{
$loader = new ClassLoader();
if (isset($autoloads['psr-0'])) {
foreach ($autoloads['psr-0'] as $namespace => $path) {
$loader->add($namespace, $path);
}
}
if (isset($autoloads['psr-4'])) {
foreach ($autoloads['psr-4'] as $namespace => $path) {
$loader->addPsr4($namespace, $path);
}
}
if (isset($autoloads['classmap'])) {
foreach ($autoloads['classmap'] as $dir) {
try {
$loader->addClassMap($this->generateClassMap($dir, null, null, false));
} catch (\RuntimeException $e) {
$this->io->writeError('<warning>'.$e->getMessage().'</warning>');
}
}
}
return $loader;
}
示例11: setFilePermissions
/**
* Set permissions for files using extra->chmod from composer.json
*
* @return void
*/
private function setFilePermissions()
{
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
$message = 'Check "chmod" section in composer.json of %s package.';
foreach ($packages as $package) {
$extra = $package->getExtra();
if (!isset($extra['chmod']) || !is_array($extra['chmod'])) {
continue;
}
$error = false;
foreach ($extra['chmod'] as $chmod) {
if (!isset($chmod['mask']) || !isset($chmod['path']) || strpos($chmod['path'], '..') !== false) {
$error = true;
continue;
}
$file = $this->installer->getTargetDir() . '/' . $chmod['path'];
if (file_exists($file)) {
chmod($file, octdec($chmod['mask']));
} else {
$this->io->writeError(['File doesn\'t exist: ' . $chmod['path'], sprintf($message, $package->getName())]);
}
}
if ($error) {
$this->io->writeError(['Incorrect mask or file path.', sprintf($message, $package->getName())]);
}
}
}
示例12: handleDeprecatedConfigurationInPackage
/**
* Ensures backwards compatibility for packages which used helhum/class-alias-loader
*
* @param PackageInterface $package
* @return array
*/
protected function handleDeprecatedConfigurationInPackage(PackageInterface $package)
{
$extraConfig = $package->getExtra();
$messages = array();
if (!isset($extraConfig['typo3/class-alias-loader'])) {
if (isset($extraConfig['helhum/class-alias-loader'])) {
$extraConfig['typo3/class-alias-loader'] = $extraConfig['helhum/class-alias-loader'];
$messages[] = sprintf('<warning>The package "%s" uses "helhum/class-alias-loader" section to define class alias maps, which is deprecated. Please use "typo3/class-alias-loader" instead!</warning>', $package->getName());
} else {
$extraConfig['typo3/class-alias-loader'] = array();
if (isset($extraConfig['class-alias-maps'])) {
$extraConfig['typo3/class-alias-loader']['class-alias-maps'] = $extraConfig['class-alias-maps'];
$messages[] = sprintf('<warning>The package "%s" uses "class-alias-maps" section on top level, which is deprecated. Please move this config below the top level key "typo3/class-alias-loader" instead!</warning>', $package->getName());
}
if (isset($extraConfig['autoload-case-sensitivity'])) {
$extraConfig['typo3/class-alias-loader']['autoload-case-sensitivity'] = $extraConfig['autoload-case-sensitivity'];
$messages[] = sprintf('<warning>The package "%s" uses "autoload-case-sensitivity" section on top level, which is deprecated. Please move this config below the top level key "typo3/class-alias-loader" instead!</warning>', $package->getName());
}
}
}
if (!empty($messages)) {
$this->IO->writeError($messages);
}
return $extraConfig;
}
示例13: fetch
/**
* @return string[]
*/
private function fetch()
{
$this->io->write(sprintf(' - Updating <info>%s</info> tag list', $this->package));
if (isset($_ENV['HRDNS_PHANTOMJS_VERSION']) && !empty($_ENV['HRDNS_PHANTOMJS_VERSION'])) {
$this->cache = [$_ENV['HRDNS_PHANTOMJS_VERSION']];
}
if ($this->cache === null) {
$this->cache = [];
$this->io->writeError(" Downloading: <comment>Connecting...</comment>", false);
$repo = new VcsRepository(['url' => $this->url, 'type' => $this->type], $this->io, $this->config);
$this->cache = array_keys($repo->getDriver()->getTags());
$this->io->overwriteError('', false);
$this->io->overwriteError(sprintf("\r Found <comment>%d</comment> versions\n", count($this->cache)));
}
return $this->cache;
}
开发者ID:sgc-fireball,项目名称:selenium-server-standalone-installer,代码行数:19,代码来源:PhantomJSVersionRepository.php
示例14: createMap
/**
* Iterate over all files in the given directory searching for classes
*
* @param \Iterator|string $path The path to search in or an iterator
* @param string $blacklist Regex that matches against the file path that exclude from the classmap.
* @param IOInterface $io IO object
* @param string $namespace Optional namespace prefix to filter by
*
* @throws \RuntimeException When the path is neither an existing file nor directory
* @return array A class map array
*/
public static function createMap($path, $blacklist = null, IOInterface $io = null, $namespace = null)
{
if (is_string($path)) {
if (is_file($path)) {
$path = array(new \SplFileInfo($path));
} elseif (is_dir($path)) {
$path = Finder::create()->files()->followLinks()->name('/\\.(php|inc|hh)$/')->in($path);
} else {
throw new \RuntimeException('Could not scan for classes inside "' . $path . '" which does not appear to be a file nor a folder');
}
}
$map = array();
foreach ($path as $file) {
$filePath = $file->getRealPath();
if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
continue;
}
if ($blacklist && preg_match($blacklist, strtr($filePath, '\\', '/'))) {
continue;
}
$classes = self::findClasses($filePath);
foreach ($classes as $class) {
// skip classes not within the given namespace prefix
if (null !== $namespace && 0 !== strpos($class, $namespace)) {
continue;
}
if (!isset($map[$class])) {
$map[$class] = $filePath;
} elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class] . ' ' . $filePath, '\\', '/'))) {
$io->writeError('<warning>Warning: Ambiguous class resolution, "' . $class . '"' . ' was found in both "' . $map[$class] . '" and "' . $filePath . '", the first will be used.</warning>');
}
}
}
return $map;
}
示例15: onPreAutoloadDump
/**
* Plugin callback for this script event, which calls the previously implemented static method
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function onPreAutoloadDump()
{
$composerConfig = $this->composer->getConfig();
$includeFile = $composerConfig->get('vendor-dir') . self::INCLUDE_FILE;
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists(dirname($includeFile));
$includeFileContent = $this->getIncludeFileContent($includeFile);
if (false !== @file_put_contents($includeFile, $includeFileContent)) {
$rootPackage = $this->composer->getPackage();
$autoloadDefinition = $rootPackage->getAutoload();
$autoloadDefinition['files'][] = $includeFile;
$rootPackage->setAutoload($autoloadDefinition);
$this->io->writeError('<info>Registered helhum/dotenv-connector in composer autoload definition</info>');
} else {
$this->io->writeError('<error>Could not dump helhum/dotenv-connector autoload include file</error>');
}
}