当前位置: 首页>>代码示例>>PHP>>正文


PHP PackageInterface::isDev方法代码示例

本文整理汇总了PHP中Composer\Package\PackageInterface::isDev方法的典型用法代码示例。如果您正苦于以下问题:PHP PackageInterface::isDev方法的具体用法?PHP PackageInterface::isDev怎么用?PHP PackageInterface::isDev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Package\PackageInterface的用法示例。


在下文中一共展示了PackageInterface::isDev方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: determineBuildNumberFromPackage

 /**
  * Try to determine the build number from a composer package
  *
  * @param \Composer\Package\PackageInterface $package
  *
  * @return string
  */
 public static function determineBuildNumberFromPackage(PackageInterface $package)
 {
     if ($package->isDev()) {
         $buildNumber = self::determineBuildNumberFromBrowscapBuildFile();
         if (is_null($buildNumber)) {
             $buildNumber = substr($package->getSourceReference(), 0, 8);
         }
     } else {
         $installedVersion = $package->getPrettyVersion();
         // SemVer supports build numbers, but fall back to just using
         // version number if not available; at time of writing, composer
         // did not support SemVer 2.0.0 build numbers fully:
         // @see https://github.com/composer/composer/issues/2422
         $plusPos = strpos($installedVersion, '+');
         if ($plusPos !== false) {
             $buildNumber = substr($installedVersion, $plusPos + 1);
         } else {
             $buildNumber = self::determineBuildNumberFromBrowscapBuildFile();
             if (is_null($buildNumber)) {
                 $buildNumber = $installedVersion;
             }
         }
     }
     return $buildNumber;
 }
开发者ID:mimmi20,项目名称:detector,代码行数:32,代码来源:ComposerHook.php

示例2: formatVersion

 public static function formatVersion(PackageInterface $package, $truncate = true)
 {
     if (!$package->isDev() || !in_array($package->getSourceType(), array('hg', 'git'))) {
         return $package->getPrettyVersion();
     }
     return $package->getPrettyVersion() . ' ' . ($truncate ? substr($package->getSourceReference(), 0, 6) : $package->getSourceReference());
 }
开发者ID:nicodmf,项目名称:composer,代码行数:7,代码来源:VersionParser.php

示例3: formatVersion

 public static function formatVersion(PackageInterface $package, $truncate = true)
 {
     if (!$package->isDev() || !in_array($package->getSourceType(), array('hg', 'git'))) {
         return $package->getPrettyVersion();
     }
     // if source reference is a sha1 hash -- truncate
     if ($truncate && strlen($package->getSourceReference()) === 40) {
         return $package->getPrettyVersion() . ' ' . substr($package->getSourceReference(), 0, 7);
     }
     return $package->getPrettyVersion() . ' ' . $package->getSourceReference();
 }
开发者ID:rkallensee,项目名称:composer,代码行数:11,代码来源:VersionParser.php

示例4: findRecommendedRequireVersion

 /**
  * Given a concrete version, this returns a ~ constraint (when possible)
  * that should be used, for example, in composer.json.
  *
  * For example:
  *  * 1.2.1         -> ~1.2
  *  * 1.2           -> ~1.2
  *  * v3.2.1        -> ~3.2
  *  * 2.0-beta.1    -> ~2.0@beta
  *  * dev-master    -> ~2.1@dev      (dev version with alias)
  *  * dev-master    -> dev-master    (dev versions are untouched)
  *
  * @param PackageInterface $package
  * @return string
  */
 public function findRecommendedRequireVersion(PackageInterface $package)
 {
     $version = $package->getVersion();
     if (!$package->isDev()) {
         return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
     }
     $loader = new ArrayLoader($this->getParser());
     $dumper = new ArrayDumper();
     $extra = $loader->getBranchAlias($dumper->dump($package));
     if ($extra) {
         $extra = preg_replace('{^(\\d+\\.\\d+\\.\\d+)(\\.9999999)-dev$}', '$1.0', $extra, -1, $count);
         if ($count) {
             $extra = str_replace('.9999999', '.0', $extra);
             return $this->transformVersion($extra, $extra, 'dev');
         }
     }
     return $package->getPrettyVersion();
 }
开发者ID:composer-fork,项目名称:composer,代码行数:33,代码来源:VersionSelector.php

示例5: isSkippable

 /**
  * Tells if a package has to be dumped or not.
  *
  * @param PackageInterface $package The package to be dumped
  *
  * @return bool false if the package has to be dumped.
  */
 public function isSkippable(PackageInterface $package)
 {
     if ('metapackage' === $package->getType()) {
         return true;
     }
     $name = $package->getPrettyString();
     if (true === $this->archiveConfig['skip-dev'] && true === $package->isDev()) {
         $this->output->writeln(sprintf("<info>Skipping '%s' (is dev)</info>", $name));
         return true;
     }
     $names = $package->getNames();
     if ($this->archiveConfig['whitelist'] && !array_intersect($this->archiveConfig['whitelist'], $names)) {
         $this->output->writeln(sprintf("<info>Skipping '%s' (is not in whitelist)</info>", $name));
         return true;
     }
     if ($this->archiveConfig['blacklist'] && array_intersect($this->archiveConfig['blacklist'], $names)) {
         $this->output->writeln(sprintf("<info>Skipping '%s' (is in blacklist)</info>", $name));
         return true;
     }
     return false;
 }
开发者ID:zyfran,项目名称:satis,代码行数:28,代码来源:ArchiveBuilderHelper.php

示例6: isSharedInstallEnabled

 /**
  * @param PackageInterface $package
  * @return bool
  */
 protected function isSharedInstallEnabled(PackageInterface $package)
 {
     // @todo disabled when prefer source
     if ($package->isDev()) {
         return false;
     }
     $this->initializePattern();
     $name = $package->getName();
     foreach ($this->excludePatterns as $pattern) {
         if (fnmatch($pattern, $name)) {
             return false;
         }
     }
     if (count($this->includePatterns) === 0) {
         return true;
     }
     foreach ($this->includePatterns as $pattern) {
         if (fnmatch($pattern, $name)) {
             return true;
         }
     }
     return false;
 }
开发者ID:ngyuki,项目名称:composer-shared-installer,代码行数:27,代码来源:Installer.php

示例7: update

 /**
  * Updates package from initial to target version.
  *
  * @param PackageInterface $initial   initial package version
  * @param PackageInterface $target    target package version
  * @param string           $targetDir target dir
  *
  * @throws InvalidArgumentException if initial package is not installed
  */
 public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
 {
     $downloader = $this->getDownloaderForInstalledPackage($initial);
     $installationSource = $initial->getInstallationSource();
     if ('dist' === $installationSource) {
         $initialType = $initial->getDistType();
         $targetType = $target->getDistType();
     } else {
         $initialType = $initial->getSourceType();
         $targetType = $target->getSourceType();
     }
     // upgrading from a dist stable package to a dev package, force source reinstall
     if ($target->isDev() && 'dist' === $installationSource) {
         $downloader->remove($initial, $targetDir);
         $this->download($target, $targetDir);
         return;
     }
     if ($initialType === $targetType) {
         $target->setInstallationSource($installationSource);
         $downloader->update($initial, $target, $targetDir);
     } else {
         $downloader->remove($initial, $targetDir);
         $this->download($target, $targetDir, 'source' === $installationSource);
     }
 }
开发者ID:nicodmf,项目名称:composer,代码行数:34,代码来源:DownloadManager.php

示例8: uninstall

 /**
  * @param InstalledRepositoryInterface $repo
  * @param PackageInterface             $package
  *
  * @throws FilesystemException
  */
 public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     if ($package->isDev()) {
         if (!$repo->hasPackage($package)) {
             throw new \InvalidArgumentException('Package is not installed : ' . $package->getPrettyName());
         }
         $this->symlinkInstaller->uninstall($repo, $package);
     } else {
         $this->defaultInstaller->uninstall($repo, $package);
     }
 }
开发者ID:JasLin,项目名称:composer-shared-package-plugin,代码行数:17,代码来源:SharedPackageInstallerSolver.php

示例9: updateInformation

 private function updateInformation(Package $package, PackageInterface $data, $flags)
 {
     $em = $this->doctrine->getManager();
     $version = new Version();
     $normVersion = $data->getVersion();
     $existingVersion = $package->getVersion($normVersion);
     if ($existingVersion) {
         $source = $existingVersion->getSource();
         // update if the right flag is set, or the source reference has changed (re-tag or new commit on branch)
         if ($source['reference'] !== $data->getSourceReference() || $flags & self::UPDATE_EQUAL_REFS) {
             $version = $existingVersion;
         } else {
             // mark it updated to avoid it being pruned
             $existingVersion->setUpdatedAt(new \DateTime());
             return false;
         }
     }
     $version->setName($package->getName());
     $version->setVersion($data->getPrettyVersion());
     $version->setNormalizedVersion($normVersion);
     $version->setDevelopment($data->isDev());
     $em->persist($version);
     $descr = $this->sanitize($data->getDescription());
     $version->setDescription($descr);
     $package->setDescription($descr);
     $version->setHomepage($data->getHomepage());
     $version->setLicense($data->getLicense() ?: array());
     $version->setPackage($package);
     $version->setUpdatedAt(new \DateTime());
     $version->setReleasedAt($data->getReleaseDate());
     if ($data->getSourceType()) {
         $source['type'] = $data->getSourceType();
         $source['url'] = $data->getSourceUrl();
         $source['reference'] = $data->getSourceReference();
         $version->setSource($source);
     } else {
         $version->setSource(null);
     }
     if ($data->getDistType()) {
         $dist['type'] = $data->getDistType();
         $dist['url'] = $data->getDistUrl();
         $dist['reference'] = $data->getDistReference();
         $dist['shasum'] = $data->getDistSha1Checksum();
         $version->setDist($dist);
     } else {
         $version->setDist(null);
     }
     if ($data->getType()) {
         $type = $this->sanitize($data->getType());
         $version->setType($type);
         if ($type !== $package->getType()) {
             $package->setType($type);
         }
     }
     $version->setTargetDir($data->getTargetDir());
     $version->setAutoload($data->getAutoload());
     $version->setExtra($data->getExtra());
     $version->setBinaries($data->getBinaries());
     $version->setIncludePaths($data->getIncludePaths());
     $version->setSupport($data->getSupport());
     if ($data->getKeywords()) {
         $keywords = array();
         foreach ($data->getKeywords() as $keyword) {
             $keywords[mb_strtolower($keyword, 'UTF-8')] = $keyword;
         }
         $existingTags = [];
         foreach ($version->getTags() as $tag) {
             $existingTags[mb_strtolower($tag->getName(), 'UTF-8')] = $tag;
         }
         foreach ($keywords as $tagKey => $keyword) {
             if (isset($existingTags[$tagKey])) {
                 unset($existingTags[$tagKey]);
                 continue;
             }
             $tag = Tag::getByName($em, $keyword, true);
             if (!$version->getTags()->contains($tag)) {
                 $version->addTag($tag);
             }
         }
         foreach ($existingTags as $tag) {
             $version->getTags()->removeElement($tag);
         }
     } elseif (count($version->getTags())) {
         $version->getTags()->clear();
     }
     $authorRepository = $this->doctrine->getRepository('PackagistWebBundle:Author');
     $version->getAuthors()->clear();
     if ($data->getAuthors()) {
         foreach ($data->getAuthors() as $authorData) {
             $author = null;
             foreach (array('email', 'name', 'homepage', 'role') as $field) {
                 if (isset($authorData[$field])) {
                     $authorData[$field] = trim($authorData[$field]);
                     if ('' === $authorData[$field]) {
                         $authorData[$field] = null;
                     }
                 } else {
                     $authorData[$field] = null;
                 }
             }
//.........这里部分代码省略.........
开发者ID:jakoch,项目名称:packagist,代码行数:101,代码来源:Updater.php

示例10: isDev

 /**
  * {@inheritdoc}
  */
 public function isDev()
 {
     return $this->package->isDev();
 }
开发者ID:tenside,项目名称:core,代码行数:7,代码来源:VersionedPackage.php

示例11: updateInformation

 private function updateInformation(Package $package, PackageInterface $data, $flags)
 {
     $em = $this->doctrine->getEntityManager();
     $version = new Version();
     $version->setNormalizedVersion($data->getVersion());
     // check if we have that version yet
     foreach ($package->getVersions() as $existingVersion) {
         if ($existingVersion->getNormalizedVersion() === $version->getNormalizedVersion()) {
             if ($existingVersion->getDevelopment() || $flags & self::UPDATE_TAGS) {
                 $version = $existingVersion;
                 break;
             }
             // mark it updated to avoid it being pruned
             $existingVersion->setUpdatedAt(new \DateTime());
             return;
         }
     }
     $version->setName($package->getName());
     $version->setVersion($data->getPrettyVersion());
     $version->setDevelopment($data->isDev());
     $em->persist($version);
     $version->setDescription($data->getDescription());
     $package->setDescription($data->getDescription());
     $version->setHomepage($data->getHomepage());
     $version->setLicense($data->getLicense() ?: array());
     $version->setPackage($package);
     $version->setUpdatedAt(new \DateTime());
     $version->setReleasedAt($data->getReleaseDate());
     if ($data->getSourceType()) {
         $source['type'] = $data->getSourceType();
         $source['url'] = $data->getSourceUrl();
         $source['reference'] = $data->getSourceReference();
         $version->setSource($source);
     }
     if ($data->getDistType()) {
         $dist['type'] = $data->getDistType();
         $dist['url'] = $data->getDistUrl();
         $dist['reference'] = $data->getDistReference();
         $dist['shasum'] = $data->getDistSha1Checksum();
         $version->setDist($dist);
     }
     if ($data->getType()) {
         $version->setType($data->getType());
         if ($data->getType() && $data->getType() !== $package->getType()) {
             $package->setType($data->getType());
         }
     }
     $version->setTargetDir($data->getTargetDir());
     $version->setAutoload($data->getAutoload());
     $version->setExtra($data->getExtra());
     $version->setBinaries($data->getBinaries());
     $version->setIncludePaths($data->getIncludePaths());
     $version->setSupport($data->getSupport());
     $version->getTags()->clear();
     if ($data->getKeywords()) {
         foreach ($data->getKeywords() as $keyword) {
             $tag = Tag::getByName($em, $keyword, true);
             if (!$version->getTags()->contains($tag)) {
                 $version->addTag($tag);
             }
         }
     }
     $authorRepository = $this->doctrine->getRepository('PackagistWebBundle:Author');
     $version->getAuthors()->clear();
     if ($data->getAuthors()) {
         foreach ($data->getAuthors() as $authorData) {
             $author = null;
             // skip authors with no information
             if (empty($authorData['email']) && empty($authorData['name'])) {
                 continue;
             }
             if (!empty($authorData['email'])) {
                 $author = $authorRepository->findOneByEmail($authorData['email']);
             }
             if (!$author && !empty($authorData['homepage'])) {
                 $author = $authorRepository->findOneBy(array('name' => $authorData['name'], 'homepage' => $authorData['homepage']));
             }
             if (!$author && !empty($authorData['name'])) {
                 $author = $authorRepository->findOneByNameAndPackage($authorData['name'], $package);
             }
             if (!$author) {
                 $author = new Author();
                 $em->persist($author);
             }
             foreach (array('email', 'name', 'homepage', 'role') as $field) {
                 if (isset($authorData[$field])) {
                     $author->{'set' . $field}($authorData[$field]);
                 }
             }
             $author->setUpdatedAt(new \DateTime());
             if (!$version->getAuthors()->contains($author)) {
                 $version->addAuthor($author);
             }
             if (!$author->getVersions()->contains($version)) {
                 $author->addVersion($version);
             }
         }
     }
     // handle links
     foreach ($this->supportedLinkTypes as $linkType => $opts) {
//.........这里部分代码省略.........
开发者ID:ronnylt,项目名称:packagist,代码行数:101,代码来源:Updater.php

示例12: getPackagePath

 protected function getPackagePath(PackageInterface $package)
 {
     $version = $package->getPrettyName();
     if ($package->isDev() && ($reference = $package->getSourceReference())) {
         $reference = strlen($reference) === 40 ? substr($reference, 0, 7) : $reference;
         // If there is / in reference switch to pretty version
         if (strpos($reference, '/') !== FALSE) {
             $version .= '-' . $package->getPrettyVersion();
         } else {
             $version .= '-' . $reference;
         }
     } else {
         $version .= '-' . $package->getPrettyVersion();
     }
     return $version;
 }
开发者ID:itscaro,项目名称:composer-global-installer,代码行数:16,代码来源:GlobalInstaller.php

示例13: update

 /**
  * Updates package from initial to target version.
  *
  * @param PackageInterface $initial   initial package version
  * @param PackageInterface $target    target package version
  * @param string           $targetDir target dir
  *
  * @throws \InvalidArgumentException if initial package is not installed
  */
 public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
 {
     $downloader = $this->getDownloaderForInstalledPackage($initial);
     if (!$downloader) {
         return;
     }
     $installationSource = $initial->getInstallationSource();
     if ('dist' === $installationSource) {
         $initialType = $initial->getDistType();
         $targetType = $target->getDistType();
     } else {
         $initialType = $initial->getSourceType();
         $targetType = $target->getSourceType();
     }
     // upgrading from a dist stable package to a dev package, force source reinstall
     if ($target->isDev() && 'dist' === $installationSource) {
         $downloader->remove($initial, $targetDir);
         $this->download($target, $targetDir);
         return;
     }
     if ($initialType === $targetType) {
         $target->setInstallationSource($installationSource);
         try {
             $downloader->update($initial, $target, $targetDir);
             return;
         } catch (\RuntimeException $e) {
             if (!$this->io->isInteractive()) {
                 throw $e;
             }
             $this->io->writeError('<error>    Update failed (' . $e->getMessage() . ')</error>');
             if (!$this->io->askConfirmation('    Would you like to try reinstalling the package instead [<comment>yes</comment>]? ', true)) {
                 throw $e;
             }
         }
     }
     $downloader->remove($initial, $targetDir);
     $this->download($target, $targetDir, 'source' === $installationSource);
 }
开发者ID:alcaeus,项目名称:composer,代码行数:47,代码来源:DownloadManager.php

示例14: searchInPackage

 /**
  * Search for dependencies in this package.
  *
  * @param PackageInterface $package The package to search in.
  *
  * @return void
  */
 private function searchInPackage(PackageInterface $package)
 {
     $this->progress->advance();
     if ($package instanceof AliasPackage || $this->searchInDevReleases && !$package->isDev() || $this->searchInReleases && $package->isDev()) {
         return;
     }
     $this->progress->setMessage($package->getName());
     $requires = $package->getRequires();
     $this->searchInRequires($package, 'prod', $requires);
     $requires = $package->getDevRequires();
     $this->searchInRequires($package, 'dev', $requires);
 }
开发者ID:bit3,项目名称:composer-global-depends,代码行数:19,代码来源:DependencyAnalyser.php

示例15: download

 /**
  * Downloads package into target dir.
  *
  * @param   PackageInterface    $package        package instance
  * @param   string              $targetDir      target dir
  * @param   Boolean             $preferSource   prefer installation from source
  *
  * @throws  InvalidArgumentException            if package have no urls to download from
  */
 public function download(PackageInterface $package, $targetDir, $preferSource = null)
 {
     $preferSource = null !== $preferSource ? $preferSource : $this->preferSource;
     $sourceType = $package->getSourceType();
     $distType = $package->getDistType();
     if (!$package->isDev() && !($preferSource && $sourceType) && $distType) {
         $package->setInstallationSource('dist');
     } elseif ($sourceType) {
         $package->setInstallationSource('source');
     } elseif ($package->isDev()) {
         throw new \InvalidArgumentException('Dev package ' . $package . ' must have a source specified');
     } else {
         throw new \InvalidArgumentException('Package ' . $package . ' must have a source or dist specified');
     }
     $fs = new Filesystem();
     $fs->ensureDirectoryExists($targetDir);
     $downloader = $this->getDownloaderForInstalledPackage($package);
     $downloader->download($package, $targetDir);
 }
开发者ID:natxet,项目名称:composer,代码行数:28,代码来源:DownloadManager.php


注:本文中的Composer\Package\PackageInterface::isDev方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。