From 2ba9332d29c1acdde0f85a2781308d2e8972f00e Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 2 Sep 2021 13:42:38 +0200 Subject: [PATCH] Allow dynamic list of stub files thanks to StubFilesExtension --- src/PhpDoc/StubFilesExtension.php | 13 +++++++++++++ src/PhpDoc/StubPhpDocProviderFactory.php | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/PhpDoc/StubFilesExtension.php diff --git a/src/PhpDoc/StubFilesExtension.php b/src/PhpDoc/StubFilesExtension.php new file mode 100644 index 0000000000..961b2f4b89 --- /dev/null +++ b/src/PhpDoc/StubFilesExtension.php @@ -0,0 +1,13 @@ +parser = $parser; $this->fileTypeMapper = $fileTypeMapper; + $this->container = $container; $this->stubFiles = $stubFiles; } public function create(): StubPhpDocProvider { + $stubFiles = $this->stubFiles; + $extensions = $this->container->getServicesByTag(StubFilesExtension::EXTENSION_TAG); + foreach ($extensions as $extension) { + $extensionFiles = $extension->getFiles(); + foreach ($extensionFiles as $extensionFile) { + $stubFiles[] = $extensionFile; + } + } + return new StubPhpDocProvider( $this->parser, $this->fileTypeMapper, - $this->stubFiles + $stubFiles ); }