Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 17f471b

Browse files
committed
fix : added check if the input variable of composer is empty
feat: added auto merge for js in dependabot
1 parent ccde519 commit 17f471b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(Composer $composer, IOInterface $io)
5151
IOInterface::class => static function () use ($io): IOInterface {
5252
return $io;
5353
},
54-
InputInterface::class => static function (ContainerContract $container) use ($genericPropertyReader): InputInterface {
54+
InputInterface::class => static function (ContainerContract $container) use ($genericPropertyReader): ?InputInterface {
5555
return $genericPropertyReader($container->get(IOInterface::class), 'input');
5656
},
5757
RemoteFilesystem::class => static function (ContainerContract $container): RemoteFilesystem {

Plugin.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
use FilesystemIterator;
3535
use InvalidArgumentException;
3636
use Narrowspark\Automatic\Common\AbstractContainer;
37-
use Narrowspark\Automatic\Common\Contract\Container as ContainerContract;
3837
use Narrowspark\Automatic\Common\Downloader\ParallelDownloader;
3938
use Narrowspark\Automatic\Prefetcher\Common\Util;
4039
use Narrowspark\Automatic\Prefetcher\Contract\LegacyTagsManager as LegacyTagsManagerContract;
@@ -44,6 +43,7 @@
4443
use ReflectionMethod;
4544
use SplFileInfo;
4645
use Symfony\Component\Console\Input\ArgvInput;
46+
use Symfony\Component\Console\Input\InputInterface;
4747

4848
class Plugin implements EventSubscriberInterface, PluginInterface
4949
{
@@ -70,14 +70,6 @@ class Plugin implements EventSubscriberInterface, PluginInterface
7070
*/
7171
private static $activated = true;
7272

73-
/**
74-
* Get the Container instance.
75-
*/
76-
public function getContainer(): ContainerContract
77-
{
78-
return $this->container;
79-
}
80-
8173
/**
8274
* {@inheritdoc}
8375
*/
@@ -106,6 +98,14 @@ public function activate(Composer $composer, IOInterface $io): void
10698

10799
$this->container = new Container($composer, $io);
108100

101+
if ($this->container->get(InputInterface::class) === null) {
102+
self::$activated = false;
103+
104+
$io->writeError('<warning>Narrowspark Automatic Prefetcher has been disabled. No input object found on composer class.</warning>');
105+
106+
return;
107+
}
108+
109109
/** @var \Narrowspark\Automatic\Prefetcher\Contract\LegacyTagsManager $tagsManager */
110110
$tagsManager = $this->container->get(LegacyTagsManagerContract::class);
111111

@@ -118,8 +118,6 @@ public function activate(Composer $composer, IOInterface $io): void
118118
return $composer;
119119
});
120120

121-
$this->container->get(PrefetcherContract::class)->populateRepoCacheDir();
122-
123121
$this->extendComposer(\debug_backtrace(), $tagsManager);
124122
}
125123

@@ -348,9 +346,9 @@ private function getErrorMessage(): ?string
348346
/**
349347
* Extend the composer object with some automatic prefetcher settings.
350348
*
351-
* @param array $backtrace
349+
* @param array<int|string, mixed> $backtrace
352350
*/
353-
private function extendComposer($backtrace, LegacyTagsManagerContract $tagsManager): void
351+
private function extendComposer(array $backtrace, LegacyTagsManagerContract $tagsManager): void
354352
{
355353
foreach ($backtrace as $trace) {
356354
if (! isset($trace['object']) || ! isset($trace['args'][0])) {
@@ -388,5 +386,7 @@ private function extendComposer($backtrace, LegacyTagsManagerContract $tagsManag
388386

389387
break;
390388
}
389+
390+
$this->container->get(PrefetcherContract::class)->populateRepoCacheDir();
391391
}
392392
}

0 commit comments

Comments
 (0)