Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit fd3e212

Browse files
authored
Merge pull request #27 from reactphp-parallel/detect-logger-path-for-both-this-package-and-packages-projects-using-it
Detect logger interface path for both this package and packages/proje…
2 parents 4142e26 + 59eb45c commit fd3e212

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Composer/Installer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static function generateProxies(Event $event): void
9191

9292
if (! function_exists('WyriHaximus\iteratorOrArrayToArray')) {
9393
/** @psalm-suppress UnresolvableInclude */
94-
require_once $composer->getConfig()->get('vendor-dir') . '/wyrihaximus/iterator-or-array-to-array/src/functions_include.php';
94+
require_once $composer->getConfig()->get('vendor-dir') . '/wyrihaximus/iterator-or-array-to-array/src/functions_include.php';
9595
}
9696

9797
if (! function_exists('WyriHaximus\getIn')) {
@@ -127,7 +127,7 @@ public static function generateProxies(Event $event): void
127127
$io->write('<info>react-parallel/object-proxy:</info> Locating interfaces');
128128

129129
$installPath = self::locateRootPackageInstallPath($composer->getConfig(), $composer->getPackage()) . '/src/Generated/';
130-
$proxies = self::getProxies($composer, $io, $rootPath);
130+
$proxies = self::getProxies($composer, $io, $rootPath, $composer->getPackage());
131131

132132
$io->write('<info>react-parallel/object-proxy:</info> Found ' . count($proxies) . ' interface(s) and generated a proxy for each of them');
133133

@@ -177,7 +177,7 @@ private static function locateRootPackageInstallPath(
177177
/**
178178
* @return array<InterfaceProxier>
179179
*/
180-
private static function getProxies(Composer $composer, IOInterface $io, string $rootPath): array
180+
private static function getProxies(Composer $composer, IOInterface $io, string $rootPath, RootPackageInterface $rootPackage): array
181181
{
182182
$phpParser = $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7, new Emulative(['comments' => true]));
183183

@@ -192,7 +192,7 @@ private static function getProxies(Composer $composer, IOInterface $io, string $
192192
static fn (array $interfaces): Observable => observableFromArray(array_unique(array_values($interfaces)))
193193
)->map(
194194
/** @phpstan-ignore-next-line */
195-
static function (string $interface) use ($io, $phpParser, $rootPath): ?array {
195+
static function (string $interface) use ($io, $phpParser, $rootPath, $rootPackage): ?array {
196196
$io->write(sprintf('<info>react-parallel/object-proxy:</info> Creating proxy for %s', $interface));
197197

198198
/**
@@ -201,7 +201,7 @@ static function (string $interface) use ($io, $phpParser, $rootPath): ?array {
201201
*/
202202
$fileName = (new ReflectionClass($interface))->getFileName();
203203
if ($interface === LoggerInterface::class) {
204-
$fileName = $rootPath . '/vendor/psr/log/Psr/Log/LoggerInterface.php';
204+
$fileName = ($rootPackage->getName() === 'react-parallel/object-proxy' ? $rootPath : dirname($rootPath, 3)) . '/vendor/psr/log/Psr/Log/LoggerInterface.php';
205205
}
206206

207207
/**

0 commit comments

Comments
 (0)