Skip to content

Commit

Permalink
Merge pull request #224 from php-http/dbu-patch-1
Browse files Browse the repository at this point in the history
use safe class_exists call to prevent issue with magentos classloader
  • Loading branch information
dbu authored Mar 31, 2023
2 parents 5cc4283 + a27395d commit 3ccd28d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 1.15.3 - 2023-03-31

- [#224](https://github.com/php-http/discovery/pull/224) - Fix regression with Magento classloader

## 1.15.2 - 2023-02-11

- [#219](https://github.com/php-http/discovery/pull/219) - Fix handling of replaced packages
Expand Down
7 changes: 4 additions & 3 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Composer\Repository\RepositorySet;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use Http\Discovery\ClassDiscovery;

/**
* Auto-installs missing implementations.
Expand Down Expand Up @@ -187,7 +188,7 @@ public function postUpdate(Event $event)
return;
}

$versionSelector = new VersionSelector(class_exists(RepositorySet::class) ? new RepositorySet() : new Pool());
$versionSelector = new VersionSelector(ClassDiscovery::safeClassExists(RepositorySet::class) ? new RepositorySet() : new Pool());
$updateComposerJson = false;

foreach ($composer->getRepositoryManager()->getLocalRepository()->getPackages() as $package) {
Expand Down Expand Up @@ -236,7 +237,7 @@ public function getMissingRequires(InstalledRepositoryInterface $repo, array $re
$missingRequires = [[], [], []];
$versionParser = new VersionParser();

if (class_exists(\Phalcon\Http\Message\RequestFactory::class, false)) {
if (ClassDiscovery::safeClassExists(\Phalcon\Http\Message\RequestFactory::class, false)) {
$missingRequires[0]['psr/http-factory-implementation'] = [];
$missingRequires[1]['psr/http-factory-implementation'] = [];
}
Expand Down Expand Up @@ -360,7 +361,7 @@ private function updateComposerLock(Composer $composer, IOInterface $io)
$lock = substr(Factory::getComposerFile(), 0, -4).'lock';
$composerJson = file_get_contents(Factory::getComposerFile());
$lockFile = new JsonFile($lock, null, $io);
$locker = class_exists(RepositorySet::class)
$locker = ClassDiscovery::safeClassExists(RepositorySet::class)
? new Locker($io, $lockFile, $composer->getInstallationManager(), $composerJson)
: new Locker($io, $lockFile, $composer->getRepositoryManager(), $composer->getInstallationManager(), $composerJson);
$lockData = $locker->getLockData();
Expand Down

0 comments on commit 3ccd28d

Please sign in to comment.