```php
diff --git a/docs/tech/classes/ClassEntity.md b/docs/tech/classes/ClassEntity.md
index 565619cb..910c0443 100644
--- a/docs/tech/classes/ClassEntity.md
+++ b/docs/tech/classes/ClassEntity.md
@@ -2,7 +2,7 @@
@@ -249,6 +249,9 @@ class ClassEntity extends \BumbleDocGen\LanguageHandler\Php\Parser\Entity\BaseEn
@@ -273,6 +276,9 @@ class ClassEntity extends \BumbleDocGen\LanguageHandler\Php\Parser\Entity\BaseEn
@@ -294,11 +300,11 @@ class ClassEntity extends \BumbleDocGen\LanguageHandler\Php\Parser\Entity\BaseEn
```php
-public function __construct(\BumbleDocGen\Core\Configuration\Configuration $configuration, \BumbleDocGen\LanguageHandler\Php\PhpHandlerSettings $phpHandlerSettings, \BumbleDocGen\LanguageHandler\Php\Parser\Entity\Reflection\ReflectorWrapper $reflector, \BumbleDocGen\LanguageHandler\Php\Parser\Entity\ClassEntityCollection $classEntityCollection, \BumbleDocGen\LanguageHandler\Php\Parser\ParserHelper $parserHelper, \BumbleDocGen\Core\Cache\LocalCache\LocalObjectCache $localObjectCache, \Psr\Log\LoggerInterface $logger, string $className, string|null $relativeFileName);
+public function __construct(\BumbleDocGen\Core\Configuration\Configuration $configuration, \BumbleDocGen\LanguageHandler\Php\PhpHandlerSettings $phpHandlerSettings, \BumbleDocGen\LanguageHandler\Php\Parser\Entity\Reflection\ReflectorWrapper $reflector, \BumbleDocGen\LanguageHandler\Php\Parser\Entity\ClassEntityCollection $classEntityCollection, \BumbleDocGen\LanguageHandler\Php\Parser\ParserHelper $parserHelper, \BumbleDocGen\LanguageHandler\Php\Parser\ComposerParser $composerParser, \BumbleDocGen\Core\Cache\LocalCache\LocalObjectCache $localObjectCache, \Psr\Log\LoggerInterface $logger, string $className, string|null $relativeFileName);
```
@@ -338,6 +344,11 @@ public function __construct(\BumbleDocGen\Core\Configuration\Configuration $conf
$localObjectCache |
@@ -371,7 +382,7 @@ public function __construct(\BumbleDocGen\Core\Configuration\Configuration $conf
```php
@@ -430,7 +441,7 @@ public function cursorToDocAttributeLinkFragment(string $cursor, bool $isForDocu
```php
@@ -461,7 +472,7 @@ public function documentCreationAllowed(): bool;
```php
@@ -494,7 +505,7 @@ public function entityCacheIsOutdated(): bool;
```php
@@ -516,6 +527,9 @@ public function entityDataCanBeLoaded(): bool;
\BumbleDocGen\Core\Configuration\Exception\InvalidConfigurationParameterException
+
+ \Exception
+
@@ -525,7 +539,7 @@ public function entityDataCanBeLoaded(): bool;
```php
@@ -578,7 +592,7 @@ public function getCacheKey(): string;
```php
@@ -608,7 +622,7 @@ public function getCachedEntityDependencies(): array;
```php
@@ -639,7 +653,7 @@ public function getCasesNames(): array;
```php
@@ -687,7 +701,7 @@ public function getConstant(string $name): string|array|int|bool|null|float;
```php
@@ -746,7 +760,7 @@ public function getConstantEntity(string $constantName, bool $unsafe = true): \B
```php
@@ -783,7 +797,7 @@ public function getConstantEntityCollection(): \BumbleDocGen\LanguageHandler\Php
```php
@@ -814,7 +828,7 @@ public function getConstants(): array;
```php
@@ -845,7 +859,7 @@ public function getConstantsData(): array;
```php
@@ -882,7 +896,7 @@ public function getDescription(): string;
```php
@@ -915,7 +929,7 @@ public function getDescriptionLinks(): array;
```php
@@ -952,7 +966,7 @@ public function getDocBlock(): \phpDocumentor\Reflection\DocBlock;
```php
@@ -985,7 +999,7 @@ public function getDocComment(): string;
```php
@@ -1022,7 +1036,7 @@ public function getDocCommentEntity(): \BumbleDocGen\LanguageHandler\Php\Parser\
```php
@@ -1045,7 +1059,7 @@ public function getDocNote(): string;
```php
@@ -1076,7 +1090,7 @@ public function getDocRender(): \BumbleDocGen\Core\Renderer\EntityDocRenderer\En
```php
@@ -1107,7 +1121,7 @@ public function getEndLine(): int;
```php
@@ -1128,7 +1142,7 @@ public function getEntityDependencies(): array;
```php
@@ -1151,7 +1165,7 @@ public function getExamples(): array;
```php
@@ -1182,7 +1196,7 @@ public function getExtends(): string|null;
```php
@@ -1210,7 +1224,7 @@ public function getFileContent(): string;
```php
@@ -1231,7 +1245,7 @@ public function getFileName(): string|null;
```php
@@ -1278,7 +1292,7 @@ public function getFileSourceLink(bool $withLine = true): string|null;
```php
@@ -1301,7 +1315,7 @@ public function getFirstExample(): string;
```php
@@ -1332,7 +1346,7 @@ public function getFullFileName(): string|null;
```php
@@ -1363,7 +1377,7 @@ public function getImplementingReflectionClass(): \Roave\BetterReflection\Reflec
```php
@@ -1394,7 +1408,7 @@ public function getInterfaceNames(): array;
```php
@@ -1425,7 +1439,7 @@ public function getInterfacesEntities(): array;
```php
@@ -1456,7 +1470,7 @@ public function getInterfacesString(): string;
```php
@@ -1515,7 +1529,7 @@ public function getMethodEntity(string $methodName, bool $unsafe = true): \Bumbl
```php
@@ -1552,7 +1566,7 @@ public function getMethodEntityCollection(): \BumbleDocGen\LanguageHandler\Php\P
```php
@@ -1583,7 +1597,7 @@ public function getMethodsData(): array;
```php
@@ -1614,7 +1628,7 @@ public function getModifiersString(): string;
```php
@@ -1635,7 +1649,7 @@ public function getName(): string;
```php
@@ -1666,7 +1680,7 @@ public function getNamespaceName(): string;
```php
@@ -1687,7 +1701,7 @@ public function getObjectId(): string;
```php
@@ -1718,7 +1732,7 @@ public function getParentClass(): \BumbleDocGen\LanguageHandler\Php\Parser\Entit
```php
@@ -1749,7 +1763,7 @@ public function getParentClassName(): string|null;
```php
@@ -1780,7 +1794,7 @@ public function getParentClassNames(): array;
```php
@@ -1801,7 +1815,7 @@ public function getPhpHandlerSettings(): \BumbleDocGen\LanguageHandler\Php\PhpHa
```php
@@ -1839,7 +1853,7 @@ public function getPluginData(string $pluginKey): array|null;
```php
@@ -1870,7 +1884,7 @@ public function getPropertiesData(): array;
```php
@@ -1929,7 +1943,7 @@ public function getPropertyEntity(string $propertyName, bool $unsafe = true): \B
```php
@@ -1966,7 +1980,7 @@ public function getPropertyEntityCollection(): \BumbleDocGen\LanguageHandler\Php
```php
@@ -1987,7 +2001,7 @@ public function getReflector(): \BumbleDocGen\LanguageHandler\Php\Parser\Entity\
```php
@@ -2035,7 +2049,7 @@ public function getRelativeFileName(bool $loadIfEmpty = true): string|null;
```php
@@ -2056,7 +2070,7 @@ public function getRootEntityCollection(): \BumbleDocGen\LanguageHandler\Php\Par
```php
@@ -2077,7 +2091,7 @@ public function getShortName(): string;
```php
@@ -2108,7 +2122,7 @@ public function getStartLine(): int;
```php
@@ -2141,7 +2155,7 @@ public function getThrows(): array;
```php
@@ -2172,7 +2186,7 @@ public function getTraitsNames(): array;
```php
@@ -2210,7 +2224,7 @@ public function hasAnnotationKey(string $annotationKey): bool;
```php
@@ -2258,7 +2272,7 @@ public function hasConstant(string $constant): bool;
```php
@@ -2288,7 +2302,7 @@ public function hasDescriptionLinks(): bool;
```php
@@ -2311,7 +2325,7 @@ public function hasExamples(): bool;
```php
@@ -2359,7 +2373,7 @@ public function hasMethod(string $method): bool;
```php
@@ -2407,7 +2421,7 @@ public function hasParentClass(string $parentClassName): bool;
```php
@@ -2455,7 +2469,7 @@ public function hasProperty(string $property): bool;
```php
@@ -2478,7 +2492,7 @@ public function hasThrows(): bool;
```php
@@ -2509,7 +2523,7 @@ public function hasTraits(): bool;
```php
@@ -2557,7 +2571,7 @@ public function implementsInterface(string $interfaceName): bool;
```php
@@ -2588,7 +2602,7 @@ public function isAbstract(): bool;
```php
@@ -2609,7 +2623,7 @@ public function isClassLoad(): bool;
```php
@@ -2632,7 +2646,7 @@ public function isDeprecated(): bool;
```php
@@ -2662,7 +2676,7 @@ public function isEntityDataCacheOutdated(): bool;
```php
@@ -2695,7 +2709,7 @@ public function isEntityFileCanBeLoad(): bool;
```php
@@ -2733,7 +2747,7 @@ public static function isEntityNameValid(string $entityName): bool;
```php
@@ -2757,6 +2771,27 @@ public function isEnum(): bool;
+
+
+
+
+
+
+```php
+public function isExternalLibraryEntity(): bool;
+```
+
+
The entity is loaded from a third party library and should not be treated the same as a standard one
+
+
Parameters: not specified
+
+
Return value: bool
+
+
@@ -2764,7 +2799,7 @@ public function isEnum(): bool;
```php
@@ -2795,7 +2830,7 @@ public function isInGit(): bool;
```php
@@ -2826,7 +2861,7 @@ public function isInstantiable(): bool;
```php
@@ -2857,7 +2892,7 @@ public function isInterface(): bool;
```php
@@ -2880,7 +2915,7 @@ public function isInternal(): bool;
```php
@@ -2928,7 +2963,7 @@ public function isSubclassOf(string $className): bool;
```php
@@ -2959,7 +2994,7 @@ public function isTrait(): bool;
```php
@@ -3002,20 +3037,20 @@ public function loadPluginData(string $pluginKey, array $data): void;
```php
// Implemented in BumbleDocGen\LanguageHandler\Php\Parser\Entity\BaseEntity
-public function reloadEntityDependenciesCache(): void;
+public function reloadEntityDependenciesCache(): array;
```
Parameters: not specified
-
Return value: void
+
Return value: array
Throws:
@@ -3025,6 +3060,46 @@ public function reloadEntityDependenciesCache(): void;
+
+
+
+
+
+
+```php
+// Implemented in BumbleDocGen\Core\Parser\Entity\Cache\CacheableEntityTrait
+
+public function removeEntityValueFromCache(string $key): void;
+```
+
+
+
+
Parameters:
+
+
+
+
+ Name |
+ Type |
+ Description |
+
+
+
+
+ $key |
+ string |
+ - |
+
+
+
+
+
Return value: void
+
+
@@ -3032,7 +3107,7 @@ public function reloadEntityDependenciesCache(): void;
```php
@@ -3062,7 +3137,7 @@ public function removeNotUsedEntityDataCache(): void;
```php
diff --git a/docs/tech/classes/ComposerParser.md b/docs/tech/classes/ComposerParser.md
new file mode 100644
index 00000000..fd9b98ed
--- /dev/null
+++ b/docs/tech/classes/ComposerParser.md
@@ -0,0 +1,163 @@
+
+
+
+
+
+
+
+
+
+```php
+namespace BumbleDocGen\LanguageHandler\Php\Parser;
+
+final class ComposerParser
+```
+
+
+
+
+
+
+
+
+
Initialization methods:
+
+
+-
+ __construct
+
+
+
+
Methods:
+
+
+-
+ getComposerPackageDataByClassName
+
+-
+ getComposerPackages
+
+
+
+
+
+
+
+
+
+
Method details:
+
+
+
+
+
+```php
+public function __construct(\BumbleDocGen\Core\Configuration\Configuration $configuration);
+```
+
+
+
+
Parameters:
+
+
+
+
+
+
+
+
+
+
+
+```php
+public function getComposerPackageDataByClassName(string $className): array|null;
+```
+
+
+
+
Parameters:
+
+
+
+
+ Name |
+ Type |
+ Description |
+
+
+
+
+ $className |
+ string |
+ - |
+
+
+
+
+
Return value: array |
null
+
+
+
Throws:
+
+
+
+
+
+
+
+
+```php
+public function getComposerPackages(): array;
+```
+
+
+
+
Parameters: not specified
+
+
Return value: array
+
+
+
Throws:
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/tech/classes/Configuration.md b/docs/tech/classes/Configuration.md
index 78387f36..06d57a9a 100644
--- a/docs/tech/classes/Configuration.md
+++ b/docs/tech/classes/Configuration.md
@@ -291,7 +291,7 @@ public function getGitClientPath(): string;
```php
diff --git a/docs/tech/classes/ConstantEntity.md b/docs/tech/classes/ConstantEntity.md
index 7f234d3f..17205916 100644
--- a/docs/tech/classes/ConstantEntity.md
+++ b/docs/tech/classes/ConstantEntity.md
@@ -147,6 +147,9 @@ class ConstantEntity extends \BumbleDocGen\LanguageHandler\Php\Parser\Entity\Bas
reloadEntityDependenciesCache
+
+ removeEntityValueFromCache
+
removeNotUsedEntityDataCache
@@ -237,7 +240,7 @@ public function __construct(\BumbleDocGen\Core\Configuration\Configuration $conf
```php
@@ -270,7 +273,7 @@ public function entityCacheIsOutdated(): bool;
```php
@@ -323,7 +326,7 @@ public function getCacheKey(): string;
```php
@@ -384,7 +387,7 @@ public function getDescription(): string;
```php
@@ -448,7 +451,7 @@ public function getDocBlock(): \phpDocumentor\Reflection\DocBlock;
```php
@@ -502,7 +505,7 @@ public function getDocCommentEntity(): \BumbleDocGen\LanguageHandler\Php\Parser\
```php
@@ -556,7 +559,7 @@ public function getEndLine(): int;
```php
@@ -610,7 +613,7 @@ public function getFileName(): string|null;
```php
@@ -657,7 +660,7 @@ public function getFileSourceLink(bool $withLine = true): string|null;
```php
@@ -805,7 +808,7 @@ public function getNamespaceName(): string;
```php
@@ -943,7 +946,7 @@ public function getStartLine(): int;
```php
@@ -976,7 +979,7 @@ public function getThrows(): array;
```php
@@ -1006,7 +1009,7 @@ public function hasDescriptionLinks(): bool;
```php
@@ -1029,7 +1032,7 @@ public function hasExamples(): bool;
```php
@@ -1052,7 +1055,7 @@ public function hasThrows(): bool;
```php
@@ -1075,7 +1078,7 @@ public function isDeprecated(): bool;
```php
@@ -1105,7 +1108,7 @@ public function isEntityDataCacheOutdated(): bool;
```php
@@ -1138,7 +1141,7 @@ public function isEntityFileCanBeLoad(): bool;
```php
@@ -1254,20 +1257,20 @@ public function isPublic(): bool;
```php
// Implemented in BumbleDocGen\LanguageHandler\Php\Parser\Entity\BaseEntity
-public function reloadEntityDependenciesCache(): void;
+public function reloadEntityDependenciesCache(): array;
```
Parameters: not specified
-
Return value: void
+
Return value: array
Throws:
@@ -1277,6 +1280,46 @@ public function reloadEntityDependenciesCache(): void;
+
+
+
+
+
+
+```php
+// Implemented in BumbleDocGen\Core\Parser\Entity\Cache\CacheableEntityTrait
+
+public function removeEntityValueFromCache(string $key): void;
+```
+
+
+
+
Parameters:
+
+
+
+
+ Name |
+ Type |
+ Description |
+
+
+
+
+ $key |
+ string |
+ - |
+
+
+
+
+
Return value: void
+
+
@@ -1284,7 +1327,7 @@ public function reloadEntityDependenciesCache(): void;
```php
diff --git a/docs/tech/classes/GenerationErrorsHandler.md b/docs/tech/classes/GenerationErrorsHandler.md
index 4c08c9f0..1e1e8f56 100644
--- a/docs/tech/classes/GenerationErrorsHandler.md
+++ b/docs/tech/classes/GenerationErrorsHandler.md
@@ -12,7 +12,7 @@
```php
namespace BumbleDocGen\Core\Logger\Handler;
-final class GenerationErrorsHandler extends \Monolog\Handler\AbstractProcessingHandler implements \Monolog\Handler\ProcessableHandlerInterface, \Monolog\Handler\FormattableHandlerInterface, \Monolog\ResettableInterface, \Monolog\Handler\HandlerInterface
+final class GenerationErrorsHandler extends \Monolog\Handler\AbstractProcessingHandler
```
Base Handler class providing the Handler structure, including processors and formatters
@@ -192,7 +192,7 @@ public function __sleep(): mixed;
```php
@@ -322,7 +322,7 @@ public function getLevel(): int;
```php
diff --git a/docs/tech/classes/MethodEntity.md b/docs/tech/classes/MethodEntity.md
index 21822f84..2507d37d 100644
--- a/docs/tech/classes/MethodEntity.md
+++ b/docs/tech/classes/MethodEntity.md
@@ -201,6 +201,9 @@ class MethodEntity extends \BumbleDocGen\LanguageHandler\Php\Parser\Entity\BaseE
reloadEntityDependenciesCache
+
+ removeEntityValueFromCache
+
removeNotUsedEntityDataCache
@@ -296,7 +299,7 @@ public function __construct(\BumbleDocGen\Core\Configuration\Configuration $conf
```php
@@ -329,7 +332,7 @@ public function entityCacheIsOutdated(): bool;
```php
@@ -413,7 +416,7 @@ public function getCacheKey(): string;
```php
@@ -480,7 +483,7 @@ public function getDescription(): string;
```php
@@ -740,7 +743,7 @@ public function getDocCommentRecursive(): string;
```php
@@ -794,7 +797,7 @@ public function getEndLine(): int;
```php
@@ -848,7 +851,7 @@ public function getFileName(): string|null;
```php
@@ -895,7 +898,7 @@ public function getFileSourceLink(bool $withLine = true): string|null;
```php
@@ -1105,7 +1108,7 @@ public function getNamespaceName(): string;
```php
@@ -1462,7 +1465,7 @@ public function getStartLine(): int;
```php
@@ -1495,7 +1498,7 @@ public function getThrows(): array;
```php
@@ -1525,7 +1528,7 @@ public function hasDescriptionLinks(): bool;
```php
@@ -1548,7 +1551,7 @@ public function hasExamples(): bool;
```php
@@ -1592,7 +1595,7 @@ public function isConstructor(): bool;
```php
@@ -1636,7 +1639,7 @@ public function isDynamic(): bool;
```php
@@ -1666,7 +1669,7 @@ public function isEntityDataCacheOutdated(): bool;
```php
@@ -1757,7 +1760,7 @@ public function isInitialization(): bool;
```php
@@ -1942,20 +1945,20 @@ public static function parseAnnotationParams(array $params): array;
```php
// Implemented in BumbleDocGen\LanguageHandler\Php\Parser\Entity\BaseEntity
-public function reloadEntityDependenciesCache(): void;
+public function reloadEntityDependenciesCache(): array;
```
Parameters: not specified
-
Return value: void
+
Return value: array
Throws:
@@ -1965,6 +1968,46 @@ public function reloadEntityDependenciesCache(): void;
+
+
+
+
+
+
+```php
+// Implemented in BumbleDocGen\Core\Parser\Entity\Cache\CacheableEntityTrait
+
+public function removeEntityValueFromCache(string $key): void;
+```
+
+
+
+
Parameters:
+
+
+
+
+ Name |
+ Type |
+ Description |
+
+
+
+
+ $key |
+ string |
+ - |
+
+
+
+
+
Return value: void
+
+
@@ -1972,7 +2015,7 @@ public function reloadEntityDependenciesCache(): void;
```php
diff --git a/docs/tech/classes/PluginEventDispatcher.md b/docs/tech/classes/PluginEventDispatcher.md
index 326c8968..1959099a 100644
--- a/docs/tech/classes/PluginEventDispatcher.md
+++ b/docs/tech/classes/PluginEventDispatcher.md
@@ -2,7 +2,7 @@
@@ -12,7 +12,7 @@
```php
namespace BumbleDocGen\Core\Plugin;
-class PluginEventDispatcher extends \Symfony\Component\EventDispatcher\EventDispatcher implements \Symfony\Component\EventDispatcher\EventDispatcherInterface, \Symfony\Contracts\EventDispatcher\EventDispatcherInterface, \Psr\EventDispatcher\EventDispatcherInterface
+class PluginEventDispatcher extends \Symfony\Component\EventDispatcher\EventDispatcher
```
The EventDispatcherInterface is the central point of Symfony's event listener system.
@@ -72,18 +72,33 @@ class PluginEventDispatcher extends \Symfony\Component\EventDispatcher\EventDisp
```php
-// Implemented in Symfony\Component\EventDispatcher\EventDispatcher
-
-public function __construct();
+public function __construct(\Monolog\Logger $logger);
```
-
Parameters: not specified
+
Parameters:
+
+
+
+
+ Name |
+ Type |
+ Description |
+
+
+
+
+ $logger |
+ \Monolog\Logger |
+ - |
+
+
+
@@ -185,7 +200,7 @@ public function addSubscriber(\Symfony\Component\EventDispatcher\EventSubscriber
```php
diff --git a/docs/tech/classes/ProjectParser.md b/docs/tech/classes/ProjectParser.md
index 52e5ef4f..f9a01dd5 100644
--- a/docs/tech/classes/ProjectParser.md
+++ b/docs/tech/classes/ProjectParser.md
@@ -110,13 +110,13 @@ public function parse(): \BumbleDocGen\Core\Parser\Entity\RootEntityCollectionsG
Throws:
diff --git a/docs/tech/classes/PropertyEntity.md b/docs/tech/classes/PropertyEntity.md
index 49bbbad2..f7a13d86 100644
--- a/docs/tech/classes/PropertyEntity.md
+++ b/docs/tech/classes/PropertyEntity.md
@@ -159,6 +159,9 @@ class PropertyEntity extends \BumbleDocGen\LanguageHandler\Php\Parser\Entity\Bas
reloadEntityDependenciesCache
+
+ removeEntityValueFromCache
+
removeNotUsedEntityDataCache
@@ -249,7 +252,7 @@ public function __construct(\BumbleDocGen\Core\Configuration\Configuration $conf
```php
@@ -282,7 +285,7 @@ public function entityCacheIsOutdated(): bool;
```php
@@ -335,7 +338,7 @@ public function getCacheKey(): string;
```php
@@ -433,7 +436,7 @@ public function getDescription(): string;
```php
@@ -503,7 +506,7 @@ public function getDocBlock(): \phpDocumentor\Reflection\DocBlock;
```php
@@ -573,7 +576,7 @@ public function getDocCommentEntity(): \BumbleDocGen\LanguageHandler\Php\Parser\
```php
@@ -627,7 +630,7 @@ public function getEndLine(): int;
```php
@@ -681,7 +684,7 @@ public function getFileName(): string|null;
```php
@@ -728,7 +731,7 @@ public function getFileSourceLink(bool $withLine = true): string|null;
```php
@@ -913,7 +916,7 @@ public function getNamespaceName(): string;
```php
@@ -1051,7 +1054,7 @@ public function getStartLine(): int;
```php
@@ -1121,7 +1124,7 @@ public function getType(): string;
```php
@@ -1151,7 +1154,7 @@ public function hasDescriptionLinks(): bool;
```php
@@ -1174,7 +1177,7 @@ public function hasExamples(): bool;
```php
@@ -1197,7 +1200,7 @@ public function hasThrows(): bool;
```php
@@ -1220,7 +1223,7 @@ public function isDeprecated(): bool;
```php
@@ -1250,7 +1253,7 @@ public function isEntityDataCacheOutdated(): bool;
```php
@@ -1304,7 +1307,7 @@ public function isImplementedInParentClass(): bool;
```php
@@ -1420,20 +1423,20 @@ public function isPublic(): bool;
```php
// Implemented in BumbleDocGen\LanguageHandler\Php\Parser\Entity\BaseEntity
-public function reloadEntityDependenciesCache(): void;
+public function reloadEntityDependenciesCache(): array;
```
Parameters: not specified
-
Return value: void
+
Return value: array
Throws:
@@ -1443,6 +1446,46 @@ public function reloadEntityDependenciesCache(): void;
+
+
+
+
+
+
+```php
+// Implemented in BumbleDocGen\Core\Parser\Entity\Cache\CacheableEntityTrait
+
+public function removeEntityValueFromCache(string $key): void;
+```
+
+
+
+
Parameters:
+
+
+
+
+ Name |
+ Type |
+ Description |
+
+
+
+
+ $key |
+ string |
+ - |
+
+
+
+
+
Return value: void
+
+
@@ -1450,7 +1493,7 @@ public function reloadEntityDependenciesCache(): void;
```php
diff --git a/docs/tech/classes/RootEntityInterface.md b/docs/tech/classes/RootEntityInterface.md
index 98f570ab..d581979c 100644
--- a/docs/tech/classes/RootEntityInterface.md
+++ b/docs/tech/classes/RootEntityInterface.md
@@ -63,6 +63,9 @@ their entities need to correspond to the same interfaces
isEntityNameValid
- Check if entity name is valid
+
+ isExternalLibraryEntity
+ - The entity is loaded from a third party library and should not be treated the same as a standard one
isInGit
- The entity file is in the git repository
@@ -148,7 +151,7 @@ public function getAbsoluteFileName(): string|null;
```php
@@ -169,7 +172,7 @@ public function getEntityDependencies(): array;
```php
@@ -213,7 +216,7 @@ public function getFileName(): string|null;
```php
@@ -374,6 +377,27 @@ public static function isEntityNameValid(string $entityName): bool;
Return value: bool
+
+
+
+
+
+
+```php
+public function isExternalLibraryEntity(): bool;
+```
+
+
The entity is loaded from a third party library and should not be treated the same as a standard one
+
+
Parameters: not specified
+
+
Return value: bool
+
+
@@ -381,7 +405,7 @@ public static function isEntityNameValid(string $entityName): bool;
```php
diff --git a/docs/tech/classes/StrTypeToUrl.md b/docs/tech/classes/StrTypeToUrl.md
index 2b2d7ad5..25da40e7 100644
--- a/docs/tech/classes/StrTypeToUrl.md
+++ b/docs/tech/classes/StrTypeToUrl.md
@@ -2,7 +2,7 @@
@@ -77,7 +77,7 @@ See:
```php
@@ -124,7 +124,7 @@ public function __construct(\BumbleDocGen\Core\Renderer\RendererHelper $renderer
```php
@@ -170,22 +170,6 @@ public function __invoke(string $text, \BumbleDocGen\Core\Parser\Entity\RootEnti
Return value: string
-
Throws:
-
-
@@ -193,7 +177,7 @@ public function __invoke(string $text, \BumbleDocGen\Core\Parser\Entity\RootEnti
```php
@@ -214,7 +198,7 @@ public static function getName(): string;
```php
diff --git a/docs/tech/classes/StubberPlugin.md b/docs/tech/classes/StubberPlugin.md
index f3e82546..115ce876 100644
--- a/docs/tech/classes/StubberPlugin.md
+++ b/docs/tech/classes/StubberPlugin.md
@@ -2,7 +2,7 @@
@@ -57,11 +57,11 @@ final class StubberPlugin implements \BumbleDocGen\Core\Plugin\PluginInterface,
```php
-public function __construct(\BumbleDocGen\Core\Configuration\Configuration $configuration);
+public function __construct(\BumbleDocGen\LanguageHandler\Php\Parser\ComposerParser $composerParser);
```
@@ -78,8 +78,8 @@ public function __construct(\BumbleDocGen\Core\Configuration\Configuration $conf
- $configuration |
- \BumbleDocGen\Core\Configuration\Configuration |
+ $composerParser |
+ \BumbleDocGen\LanguageHandler\Php\Parser\ComposerParser |
- |
@@ -94,7 +94,7 @@ public function __construct(\BumbleDocGen\Core\Configuration\Configuration $conf
```php
@@ -115,7 +115,7 @@ public static function getSubscribedEvents(): array;
```php
@@ -160,7 +160,7 @@ public function onCheckIsClassEntityCanBeLoad(\BumbleDocGen\LanguageHandler\Php\
```php
diff --git a/docs/tech/map.md b/docs/tech/map.md
index b4e5458b..83e291c7 100644
--- a/docs/tech/map.md
+++ b/docs/tech/map.md
@@ -219,6 +219,7 @@ Directory layout ( only documented files shown ):
│ │ │ │ │ │ └──
SystemAsyncSourceLocator.php
│ │ │ │ │ ├──
AsyncSourceLocator.php — Lazy loading classes. Cannot be used for initial parsing of files, only for getting specific docu...
│ │ │ │ │ └──
CustomSourceLocatorInterface.php
+│ │ │ │ ├──
ComposerParser.php
│ │ │ │ └──
ParserHelper.php
│ │ │ ├──
Plugin/
│ │ │ │ ├──
CorePlugin/
diff --git a/docs/tech/readme.md b/docs/tech/readme.md
index 5585ae45..ca268f55 100644
--- a/docs/tech/readme.md
+++ b/docs/tech/readme.md
@@ -44,4 +44,4 @@ After that, the process of parsing the project code according to the configurati
-
Last page committer: fshcherbanich <filipp.shcherbanich@team.bumble.com>
Last modified date: Thu Oct 5 17:42:06 2023 +0300
Page content update date: Wed Nov 01 2023
Made with
Bumble Documentation Generator
\ No newline at end of file
+
Last page committer: fshcherbanich <filipp.shcherbanich@team.bumble.com>
Last modified date: Thu Oct 5 17:42:06 2023 +0300
Page content update date: Thu Nov 02 2023
Made with
Bumble Documentation Generator
\ No newline at end of file
diff --git a/src/Core/Logger/Handler/GenerationErrorsHandler.php b/src/Core/Logger/Handler/GenerationErrorsHandler.php
index 8da55a70..b21143af 100644
--- a/src/Core/Logger/Handler/GenerationErrorsHandler.php
+++ b/src/Core/Logger/Handler/GenerationErrorsHandler.php
@@ -41,7 +41,8 @@ protected function write(array $record): void
"type" => $record['level_name'],
"msg" => $record['message'],
'initiator' => $initiator,
- 'isRenderingError' => boolval($this->rendererContext->getCurrentTemplateFilePatch())
+ 'isRenderingError' => boolval($this->rendererContext->getCurrentTemplateFilePatch()),
+ 'currentDocumentedEntityWrapper' => $this->rendererContext->getCurrentDocumentedEntityWrapper()?->getDocumentTransformableEntity()?->getName()
];
}
diff --git a/src/Core/Parser/Entity/Cache/CacheableEntityInterface.php b/src/Core/Parser/Entity/Cache/CacheableEntityInterface.php
index eafa8bb4..db46a416 100644
--- a/src/Core/Parser/Entity/Cache/CacheableEntityInterface.php
+++ b/src/Core/Parser/Entity/Cache/CacheableEntityInterface.php
@@ -16,7 +16,7 @@ public function isEntityFileCanBeLoad(): bool;
public function isEntityDataCacheOutdated(): bool;
- public function reloadEntityDependenciesCache(): void;
+ public function reloadEntityDependenciesCache(): array;
public function removeNotUsedEntityDataCache(): void;
}
diff --git a/src/Core/Parser/Entity/Cache/CacheableEntityTrait.php b/src/Core/Parser/Entity/Cache/CacheableEntityTrait.php
index 5bbab53c..f09b89fc 100644
--- a/src/Core/Parser/Entity/Cache/CacheableEntityTrait.php
+++ b/src/Core/Parser/Entity/Cache/CacheableEntityTrait.php
@@ -62,6 +62,15 @@ protected function addEntityValueToCache(string $key, mixed $value, int $cacheEx
);
}
+ public function removeEntityValueFromCache(string $key): void
+ {
+ $this->isCacheChanged = true;
+ $this->entityCacheStorageHelper->removeItemValueFromCache(
+ $this->getCacheKey(),
+ $key,
+ );
+ }
+
/**
* @throws InvalidArgumentException
*/
diff --git a/src/Core/Parser/Entity/Cache/CacheableEntityWrapperTrait.php b/src/Core/Parser/Entity/Cache/CacheableEntityWrapperTrait.php
index 3b344ec4..03bda662 100644
--- a/src/Core/Parser/Entity/Cache/CacheableEntityWrapperTrait.php
+++ b/src/Core/Parser/Entity/Cache/CacheableEntityWrapperTrait.php
@@ -5,12 +5,15 @@
namespace BumbleDocGen\Core\Parser\Entity\Cache;
use BumbleDocGen\Core\Configuration\Exception\InvalidConfigurationParameterException;
+use BumbleDocGen\Core\Logger\Handler\GenerationErrorsHandler;
+use DI\Attribute\Inject;
use Psr\Cache\InvalidArgumentException;
trait CacheableEntityWrapperTrait
{
use CacheableEntityTrait;
+ #[Inject] private GenerationErrorsHandler $generationErrorsHandler;
private bool $noCacheMode = false;
abstract public function isEntityFileCanBeLoad(): bool;
@@ -39,9 +42,11 @@ final protected function getWrappedMethodResult(
if ($this->hasEntityCacheValue($cacheKey) && !$this->entityCacheIsOutdated()) {
$methodReturnValue = $this->getEntityCacheValue($cacheKey);
} else {
+ $errorsBeforeGenerationCount = count($this->generationErrorsHandler->getRecords());
$methodReturnValue = call_user_func_array([parent::class, $methodName], $funcArgs);
$this->noCacheMode = true;
- if ($this->isEntityFileCanBeLoad()) {
+ $errorsCount = count($this->generationErrorsHandler->getRecords());
+ if ($errorsCount === $errorsBeforeGenerationCount && $this->isEntityFileCanBeLoad()) {
$this->addEntityValueToCache($cacheKey, $methodReturnValue, $cacheExpiresAfter);
}
$this->noCacheMode = false;
diff --git a/src/Core/Parser/Entity/RootEntityInterface.php b/src/Core/Parser/Entity/RootEntityInterface.php
index 54d1594b..babd4697 100644
--- a/src/Core/Parser/Entity/RootEntityInterface.php
+++ b/src/Core/Parser/Entity/RootEntityInterface.php
@@ -20,6 +20,11 @@ public static function isEntityNameValid(string $entityName): bool;
*/
public function entityDataCanBeLoaded(): bool;
+ /**
+ * The entity is loaded from a third party library and should not be treated the same as a standard one
+ */
+ public function isExternalLibraryEntity(): bool;
+
/**
* @return string[]
*/
diff --git a/src/Core/Plugin/PluginEventDispatcher.php b/src/Core/Plugin/PluginEventDispatcher.php
index c9198bf7..d6a5858a 100644
--- a/src/Core/Plugin/PluginEventDispatcher.php
+++ b/src/Core/Plugin/PluginEventDispatcher.php
@@ -4,12 +4,19 @@
namespace BumbleDocGen\Core\Plugin;
+use BumbleDocGen\Core\Configuration\Configuration;
+use Monolog\Logger;
use Symfony\Component\EventDispatcher\EventDispatcher;
class PluginEventDispatcher extends EventDispatcher
{
private array $handledSingleExecutionEvents = [];
+ public function __construct(private Logger $logger)
+ {
+ parent::__construct();
+ }
+
public function dispatch(object $event, string $eventName = null): object
{
if ($event instanceof OnlySingleExecutionEvent) {
@@ -20,6 +27,10 @@ public function dispatch(object $event, string $eventName = null): object
$this->handledSingleExecutionEvents[$uniqueExecutionId] = true;
}
}
- return parent::dispatch($event, $eventName);
+ try {
+ return parent::dispatch($event, $eventName);
+ } catch (\Exception $e) {
+ $this->logger->error($e->getMessage());
+ }
}
}
diff --git a/src/Core/Renderer/Twig/Filter/StrTypeToUrl.php b/src/Core/Renderer/Twig/Filter/StrTypeToUrl.php
index 3764fe10..1f9678b3 100644
--- a/src/Core/Renderer/Twig/Filter/StrTypeToUrl.php
+++ b/src/Core/Renderer/Twig/Filter/StrTypeToUrl.php
@@ -4,13 +4,9 @@
namespace BumbleDocGen\Core\Renderer\Twig\Filter;
-use BumbleDocGen\Core\Configuration\Exception\InvalidConfigurationParameterException;
use BumbleDocGen\Core\Parser\Entity\RootEntityCollection;
use BumbleDocGen\Core\Renderer\RendererHelper;
use BumbleDocGen\Core\Renderer\Twig\Function\GetDocumentedEntityUrl;
-use BumbleDocGen\LanguageHandler\Php\Parser\Entity\Exception\ReflectionException;
-use DI\DependencyException;
-use DI\NotFoundException;
use Monolog\Logger;
/**
@@ -49,10 +45,6 @@ public static function getOptions(): array
* If true, creates an entity document. Otherwise, just gives a reference to the entity code
*
* @return string
- * @throws NotFoundException
- * @throws ReflectionException
- * @throws DependencyException
- * @throws InvalidConfigurationParameterException
*/
public function __invoke(
string $text,
@@ -70,30 +62,34 @@ public function __invoke(
$preparedTypes[] = "{$type}";
continue;
}
+ try {
+ $entityOfLink = $rootEntityCollection->getLoadedOrCreateNew($type);
+ if (!$entityOfLink->isExternalLibraryEntity() && $entityOfLink->entityDataCanBeLoaded()) {
+ if ($entityOfLink->getAbsoluteFileName()) {
+ $link = $getDocumentedEntityUrlFunction($rootEntityCollection, $type, '', $createDocument);
- $entityOfLink = $rootEntityCollection->getLoadedOrCreateNew($type);
- if ($entityOfLink->entityDataCanBeLoaded()) {
- if ($entityOfLink->getAbsoluteFileName()) {
- $link = $getDocumentedEntityUrlFunction($rootEntityCollection, $type, '', $createDocument);
+ if ($useShortLinkVersion) {
+ $type = $entityOfLink->getShortName();
+ } else {
+ $type = "\\{$entityOfLink->getName()}";
+ }
- if ($useShortLinkVersion) {
- $type = $entityOfLink->getShortName();
- } else {
- $type = "\\{$entityOfLink->getName()}";
+ if ($link && $link !== '#') {
+ $preparedTypes[] = "{$type}";
+ } else {
+ $preparedTypes[] = $type;
+ }
}
-
- if ($link && $link !== '#') {
- $preparedTypes[] = "{$type}";
- } else {
- $preparedTypes[] = $type;
+ } else {
+ if ($entityOfLink::isEntityNameValid($type)) {
+ $this->logger->warning(
+ "StrTypeToUrl: Entity {$type} not found in specified sources"
+ );
}
+ $preparedTypes[] = $type;
}
- } else {
- if ($entityOfLink::isEntityNameValid($type)) {
- $this->logger->warning(
- "StrTypeToUrl: Entity {$type} not found in specified sources"
- );
- }
+ } catch (\Exception $e) {
+ $this->logger->error($e->getMessage());
$preparedTypes[] = $type;
}
}
diff --git a/src/LanguageHandler/Php/Parser/ComposerParser.php b/src/LanguageHandler/Php/Parser/ComposerParser.php
new file mode 100644
index 00000000..32feaf16
--- /dev/null
+++ b/src/LanguageHandler/Php/Parser/ComposerParser.php
@@ -0,0 +1,73 @@
+packages) {
+ return $this->packages;
+ }
+ $installedJsonFile = realpath($this->configuration->getProjectRoot() . '/vendor/composer/installed.json');
+ $installedPackagesData = json_decode(file_get_contents($installedJsonFile), true);
+ foreach ($installedPackagesData['packages'] as $package) {
+ if (!isset($package['source']['url'])) {
+ continue;
+ }
+
+ if (str_starts_with($package['source']['url'], 'https://github.com/')) {
+ $url = str_replace('.git', '', $package['source']['url']);
+ } elseif (str_starts_with($package['source']['url'], 'git@github')) {
+ preg_match('/(@)(.*?)(:)(.*?)(.git)/', $package['source']['url'], $matches);
+ $url = "https://{$matches[2]}/{$matches[4]}";
+ } else {
+ continue;
+ }
+
+ $psr4 = $package['autoload']["psr-4"] ?? [];
+ foreach ($psr4 as $namespace => $path) {
+ $this->packages[$namespace] = [
+ 'path' => $path,
+ 'namespace' => $namespace,
+ 'url' => $url
+ ];
+ }
+ }
+ return $this->packages;
+ }
+
+ /**
+ * @throws \Exception
+ */
+ public function getComposerPackageDataByClassName(string $className): ?array
+ {
+ if (!ParserHelper::isCorrectClassName($className)) {
+ return null;
+ }
+ $packages = $this->getComposerPackages();
+ $classParts = explode('\\', $className);
+ $namespace = '';
+ foreach ($classParts as $part) {
+ if ($part) {
+ $namespace .= "{$part}\\";
+ if (isset($packages[$namespace])) {
+ return $packages[$namespace];
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/LanguageHandler/Php/Parser/Entity/BaseEntity.php b/src/LanguageHandler/Php/Parser/Entity/BaseEntity.php
index 39b59557..ac4bf729 100644
--- a/src/LanguageHandler/Php/Parser/Entity/BaseEntity.php
+++ b/src/LanguageHandler/Php/Parser/Entity/BaseEntity.php
@@ -8,6 +8,7 @@
use BumbleDocGen\Core\Cache\LocalCache\LocalObjectCache;
use BumbleDocGen\Core\Configuration\Configuration;
use BumbleDocGen\Core\Configuration\Exception\InvalidConfigurationParameterException;
+use BumbleDocGen\Core\Logger\Handler\GenerationErrorsHandler;
use BumbleDocGen\Core\Parser\Entity\Cache\CacheableEntityInterface;
use BumbleDocGen\Core\Parser\Entity\Cache\CacheableEntityTrait;
use BumbleDocGen\Core\Parser\Entity\Cache\CacheableMethod;
@@ -477,7 +478,7 @@ protected function getCurrentRootEntity(): ?RootEntityInterface
return null;
}
- private function getEntityDependenciesCacheKey(): string
+ protected function getEntityDependenciesCacheKey(): string
{
return "__internalEntityDependencies{$this->getCacheKey()}";
}
@@ -493,23 +494,32 @@ final public function getCachedEntityDependencies(): array
$filesDependenciesCacheKey = $this->getEntityDependenciesCacheKey();
$entityDependencies = $this->getEntityCacheValue($filesDependenciesCacheKey);
if (is_null($entityDependencies)) {
- $entityDependencies = $entity->getEntityDependencies();
- $this->addEntityValueToCache($this->getEntityDependenciesCacheKey(), $entityDependencies);
+ $entityDependencies = $this->reloadEntityDependenciesCache();
}
}
return $entityDependencies;
}
+ #[Inject] private GenerationErrorsHandler $generationErrorsHandler;
/**
* @throws InvalidArgumentException
*/
- final public function reloadEntityDependenciesCache(): void
+ final public function reloadEntityDependenciesCache(): array
{
+ $entityDependencies = [];
$entity = $this->getCurrentRootEntity();
if ($entity) {
+ $errorsBeforeCount = count($this->generationErrorsHandler->getRecords());
$entityDependencies = $entity->getEntityDependencies();
- $this->addEntityValueToCache($this->getEntityDependenciesCacheKey(), $entityDependencies);
+ $errorsAfterCount = count($this->generationErrorsHandler->getRecords());
+ if ($errorsBeforeCount === $errorsAfterCount) {
+ $this->addEntityValueToCache($this->getEntityDependenciesCacheKey(), $entityDependencies);
+ } else {
+ $this->removeEntityValueFromCache($this->getEntityDependenciesCacheKey());
+ $entityDependencies = [];
+ }
}
+ return $entityDependencies;
}
/**
diff --git a/src/LanguageHandler/Php/Parser/Entity/ClassEntity.php b/src/LanguageHandler/Php/Parser/Entity/ClassEntity.php
index 61cf3940..efde7556 100644
--- a/src/LanguageHandler/Php/Parser/Entity/ClassEntity.php
+++ b/src/LanguageHandler/Php/Parser/Entity/ClassEntity.php
@@ -13,6 +13,7 @@
use BumbleDocGen\Core\Renderer\Context\DocumentTransformableEntityInterface;
use BumbleDocGen\Core\Renderer\EntityDocRenderer\EntityDocRendererInterface;
use BumbleDocGen\Core\Renderer\Twig\Filter\PrepareSourceLink;
+use BumbleDocGen\LanguageHandler\Php\Parser\ComposerParser;
use BumbleDocGen\LanguageHandler\Php\Parser\Entity\Exception\ReflectionException;
use BumbleDocGen\LanguageHandler\Php\Parser\Entity\Reflection\ReflectorWrapper;
use BumbleDocGen\LanguageHandler\Php\Parser\ParserHelper;
@@ -49,6 +50,7 @@ public function __construct(
private ReflectorWrapper $reflector,
private ClassEntityCollection $classEntityCollection,
private ParserHelper $parserHelper,
+ private ComposerParser $composerParser,
private LocalObjectCache $localObjectCache,
private LoggerInterface $logger,
private string $className,
@@ -75,6 +77,15 @@ public function getObjectId(): string
return $this->className;
}
+ /**
+ * @inheritDoc
+ * @throws \Exception
+ */
+ public function isExternalLibraryEntity(): bool
+ {
+ return !is_null($this->composerParser->getComposerPackageDataByClassName($this->getName()));
+ }
+
public function setReflectionClass(ReflectionClass $reflectionClass): void
{
$this->reflectionClass = $reflectionClass;
@@ -102,6 +113,7 @@ public function getRootEntityCollection(): ClassEntityCollection
* @throws DependencyException
* @throws ReflectionException
* @throws InvalidConfigurationParameterException
+ * @throws \Exception
*/
public function getEntityDependencies(): array
{
@@ -113,8 +125,9 @@ public function getEntityDependencies(): array
$interfaceNames = $this->getInterfaceNames();
$classNames = array_unique(array_merge($parentClassNames, $traitClassNames, $interfaceNames));
+ $classNames = array_filter($classNames, fn(string $className) => !$this->composerParser->getComposerPackageDataByClassName($className));
- $reflections = array_map(fn($className) => $this->getReflector()->reflectClass($className), $classNames);
+ $reflections = array_map(fn(string $className): ReflectionClass => $this->getReflector()->reflectClass($className), $classNames);
$reflections[] = $currentClassEntityReflection;
foreach ($reflections as $reflectionClass) {
$fileName = $reflectionClass->getFileName();
@@ -293,6 +306,7 @@ public function isClassLoad(): bool
/**
* @throws ReflectionException
* @throws InvalidConfigurationParameterException
+ * @throws \Exception
*/
#[CacheableMethod] public function entityDataCanBeLoaded(): bool
{
@@ -304,7 +318,7 @@ public function isClassLoad(): bool
$this->logger->notice("Class `{$this->getName()}` loading skipped by plugin");
return false;
}
- return $this->isEntityFileCanBeLoad();
+ return !$this->isExternalLibraryEntity() && $this->isEntityFileCanBeLoad();
}
public function getShortName(): string
@@ -457,6 +471,9 @@ public function getInterfacesEntities(): array
*/
#[CacheableMethod] public function getParentClassNames(): array
{
+ if ($this->isExternalLibraryEntity()) {
+ return [];
+ }
if ($this->isInterface()) {
return $this->getInterfaceNames();
} else {
@@ -506,7 +523,9 @@ public function getInterfacesEntities(): array
$parentInterfaceNames = [];
try {
$interfaceEntity = $this->getRootEntityCollection()->getLoadedOrCreateNew($interfaceName);
- $parentInterfaceNames = $interfaceEntity->getInterfaceNames();
+ if (!$interfaceEntity->isExternalLibraryEntity()) {
+ $parentInterfaceNames = $interfaceEntity->getInterfaceNames();
+ }
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}
@@ -515,7 +534,9 @@ public function getInterfacesEntities(): array
if (!$this->isInterface() && $parentClass = $this->getParentClass()) {
$parentInterfaceNames = [];
try {
- $parentInterfaceNames = $parentClass->getInterfaceNames();
+ if (!$parentClass->isExternalLibraryEntity()) {
+ $parentInterfaceNames = $parentClass->getInterfaceNames();
+ }
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}
@@ -812,7 +833,7 @@ public function getFileContent(): string
*/
#[CacheableMethod] public function isInterface(): bool
{
- return $this->getReflection()->isInterface();
+ return $this->getReflection()->getAst() instanceof InterfaceNode;
}
/**
diff --git a/src/LanguageHandler/Php/Plugin/CorePlugin/ComposerPackagesStubber/StubberPlugin.php b/src/LanguageHandler/Php/Plugin/CorePlugin/ComposerPackagesStubber/StubberPlugin.php
index 1be4a906..a2d6f610 100644
--- a/src/LanguageHandler/Php/Plugin/CorePlugin/ComposerPackagesStubber/StubberPlugin.php
+++ b/src/LanguageHandler/Php/Plugin/CorePlugin/ComposerPackagesStubber/StubberPlugin.php
@@ -4,10 +4,9 @@
namespace BumbleDocGen\LanguageHandler\Php\Plugin\CorePlugin\ComposerPackagesStubber;
-use BumbleDocGen\Core\Configuration\Configuration;
use BumbleDocGen\Core\Plugin\Event\Renderer\OnGettingResourceLink;
use BumbleDocGen\Core\Plugin\PluginInterface;
-use BumbleDocGen\LanguageHandler\Php\Parser\ParserHelper;
+use BumbleDocGen\LanguageHandler\Php\Parser\ComposerParser;
use BumbleDocGen\LanguageHandler\Php\Plugin\Event\Entity\OnCheckIsClassEntityCanBeLoad;
/**
@@ -18,7 +17,7 @@ final class StubberPlugin implements PluginInterface
private array $packages = [];
private array $foundLinks = [];
- public function __construct(private Configuration $configuration)
+ public function __construct(private ComposerParser $composerParser)
{
}
@@ -39,7 +38,7 @@ final public function onGettingResourceLink(OnGettingResourceLink $event): void
$resourceName = trim($event->getResourceName());
if (!isset($this->foundLinks[$resourceName])) {
- $packageData = $this->getPackageDataByName($resourceName);
+ $packageData = $this->composerParser->getComposerPackageDataByClassName($resourceName);
if (!$packageData) {
return;
}
@@ -61,66 +60,8 @@ final public function onGettingResourceLink(OnGettingResourceLink $event): void
*/
final public function onCheckIsClassEntityCanBeLoad(OnCheckIsClassEntityCanBeLoad $event): void
{
- if ($this->getPackageDataByName($event->getEntity()->getName())) {
+ if ($this->composerParser->getComposerPackageDataByClassName($event->getEntity()->getName())) {
$event->disableClassLoading();
}
}
-
- /**
- * @throws \Exception
- */
- private function getComposerPackages(): array
- {
- if ($this->packages) {
- return $this->packages;
- }
- $installedJsonFile = realpath($this->configuration->getProjectRoot() . '/vendor/composer/installed.json');
- $installedPackagesData = json_decode(file_get_contents($installedJsonFile), true);
- foreach ($installedPackagesData['packages'] as $package) {
- if (!isset($package['source']['url'])) {
- continue;
- }
-
- if (str_starts_with($package['source']['url'], 'https://github.com/')) {
- $url = str_replace('.git', '', $package['source']['url']);
- } elseif (str_starts_with($package['source']['url'], 'git@github')) {
- preg_match('/(@)(.*?)(:)(.*?)(.git)/', $package['source']['url'], $matches);
- $url = "https://{$matches[2]}/{$matches[4]}";
- } else {
- continue;
- }
-
- $psr4 = $package['autoload']["psr-4"] ?? [];
- foreach ($psr4 as $namespace => $path) {
- $this->packages[$namespace] = [
- 'path' => $path,
- 'namespace' => $namespace,
- 'url' => $url
- ];
- }
- }
- return $this->packages;
- }
-
- /**
- * @throws \Exception
- */
- private function getPackageDataByName(string $className): ?array
- {
- if (!ParserHelper::isCorrectClassName($className)) {
- return null;
- }
- $packages = $this->getComposerPackages();
- $classParts = explode('\\', $className);
- $namespace = '';
- foreach ($classParts as $part) {
- if ($part) {
- $namespace .= "{$part}\\";
- if (isset($packages[$namespace])) {
- return $packages[$namespace];
- }
- }
- }
- return null;
- }
}