Adding composer_bin_dir path expander#2753
Merged
dantleech merged 3 commits intophpactor:masterfrom Oct 11, 2024
Merged
Conversation
composer_bin_dir path expander
70db756 to
937396b
Compare
Contributor
Author
|
Found the problem, you can't have a service tagged as a value expander and depend a service that resolves paths. But I don't know how to solve that. |
dantleech
reviewed
Oct 7, 2024
| } | ||
|
|
||
| private function readFile(): void | ||
| public function getBinDir(): string |
dantleech
reviewed
Oct 7, 2024
| { | ||
| if ($this->loaded) { | ||
| if ($this->loaded || !file_exists($this->lockFile) || !file_exists($this->composerFile)) { | ||
| $this->loaded = true; |
Collaborator
There was a problem hiding this comment.
both files are now optional...
Contributor
Author
There was a problem hiding this comment.
Yes, before the lock file was optional before and I don't know if you don't use composer in your project this inspector shouldn't crash.
Collaborator
There was a problem hiding this comment.
I mean you could have a JSON file but not a lock file or vice versa potentially but this requires thatbyiu have both. We should allow it to work with only a JSON file
Collaborator
|
you can use a lazy/callback expander as follows: diff --git a/lib/Extension/ComposerInspector/ComposerInspectorExtension.php b/lib/Extension/ComposerInspector/ComposerInspectorExtension.php
index f289fa3e..3abef5ea 100644
--- a/lib/Extension/ComposerInspector/ComposerInspectorExtension.php
+++ b/lib/Extension/ComposerInspector/ComposerInspectorExtension.php
@@ -7,6 +7,7 @@ use Phpactor\Container\Container;
use Phpactor\Container\ContainerBuilder;
use Phpactor\Container\Extension;
use Phpactor\Extension\FilePathResolver\FilePathResolverExtension;
+use Phpactor\FilePathResolver\Expander\CallbackExpander;
use Phpactor\FilePathResolver\Expander\ValueExpander;
use Phpactor\FilePathResolver\PathResolver;
use Phpactor\MapResolver\Resolver;
@@ -24,8 +25,10 @@ class ComposerInspectorExtension implements Extension
});
$container->register('composer.bin_path_expander', function (Container $container) {
- $path = $container->get(ComposerInspector::class)->getBinDir();
- return new ValueExpander('composer_bin_dir', $path);
+ return new CallbackExpander('composer_bin_dir', function () use ($container) {
+ $path = $container->get(ComposerInspector::class)->getBinDir();
+ return $path;
+ });
}, [ FilePathResolverExtension::TAG_EXPANDER => [] ]);
} |
ddf7e0c to
571025f
Compare
040ebf3 to
71711f7
Compare
Collaborator
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
However, when I run phpactor locally with this enabled it doesn't load anymore. It's stuck in some kind of cycle of allocating stuff (at least that's what I can tell from the
strace).And when trying to debug it with xdebug it freezes on a
proc_closecall.Closes #2749