code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
private function rulesetResolution() : array { $layerNames = []; foreach (\array_map(static fn(array $layerDef): string => $layerDef['name'], $this->layers) as $sourceLayerName) { foreach ($this->layerProvider->getAllowedLayers($sourceLayerName) as $destinationLayerName) { $layerNames[$sourceLayerName][$destinationLayerName] = 0; } } return $layerNames; }
@return array<string, array<string, 0>> sourceLayer -> (targetLayer -> 0) @throws CircularReferenceException
rulesetResolution
php
deptrac/deptrac
src/Core/Analyser/RulesetUsageAnalyser.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Analyser/RulesetUsageAnalyser.php
MIT
public function __construct(private readonly AstMapExtractor $astMapExtractor, private readonly TokenResolver $tokenResolver, private readonly LayerResolverInterface $layerResolver, array $config) { $this->tokenTypes = \array_filter(\array_map(static fn(string $emitterType): ?\Deptrac\Deptrac\Core\Analyser\TokenType => \Deptrac\Deptrac\Core\Analyser\TokenType::tryFromEmitterType(EmitterType::from($emitterType)), $config['types'])); }
@param array{types: array<string>} $config
__construct
php
deptrac/deptrac
src/Core/Analyser/TokenInLayerAnalyser.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Analyser/TokenInLayerAnalyser.php
MIT
public function findTokensInLayer(string $layer) : array { try { $astMap = $this->astMapExtractor->extract(); $matchingTokens = []; if (in_array(\Deptrac\Deptrac\Core\Analyser\TokenType::CLASS_LIKE, $this->tokenTypes, \true)) { foreach ($astMap->getClassLikeReferences() as $classReference) { $classToken = $this->tokenResolver->resolve($classReference->getToken(), $astMap); if (\array_key_exists($layer, $this->layerResolver->getLayersForReference($classToken))) { $matchingTokens[] = [$classToken->getToken()->toString(), \Deptrac\Deptrac\Core\Analyser\TokenType::CLASS_LIKE->value]; } } } if (in_array(\Deptrac\Deptrac\Core\Analyser\TokenType::FUNCTION, $this->tokenTypes, \true)) { foreach ($astMap->getFunctionReferences() as $functionReference) { $functionToken = $this->tokenResolver->resolve($functionReference->getToken(), $astMap); if (\array_key_exists($layer, $this->layerResolver->getLayersForReference($functionToken))) { $matchingTokens[] = [$functionToken->getToken()->toString(), \Deptrac\Deptrac\Core\Analyser\TokenType::FUNCTION->value]; } } } if (in_array(\Deptrac\Deptrac\Core\Analyser\TokenType::FILE, $this->tokenTypes, \true)) { foreach ($astMap->getFileReferences() as $fileReference) { $fileToken = $this->tokenResolver->resolve($fileReference->getToken(), $astMap); if (\array_key_exists($layer, $this->layerResolver->getLayersForReference($fileToken))) { $matchingTokens[] = [$fileToken->getToken()->toString(), \Deptrac\Deptrac\Core\Analyser\TokenType::FILE->value]; } } } \uasort($matchingTokens, static fn(array $a, array $b): int => $a[0] <=> $b[0]); return array_values($matchingTokens); } catch (UnrecognizedTokenException $e) { throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::unrecognizedToken($e); } catch (InvalidLayerDefinitionException $e) { throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidLayerDefinition($e); } catch (InvalidCollectorDefinitionException $e) { throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidCollectorDefinition($e); } catch (AstException $e) { throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::failedAstParsing($e); } catch (CouldNotParseFileException $e) { throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::couldNotParseFile($e); } }
@return list<array{string, string}> @throws AnalyserException
findTokensInLayer
php
deptrac/deptrac
src/Core/Analyser/TokenInLayerAnalyser.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Analyser/TokenInLayerAnalyser.php
MIT
public function __construct(private readonly AstMapExtractor $astMapExtractor, private readonly TokenResolver $tokenResolver, private readonly LayerResolverInterface $layerResolver, array $config) { $this->tokenTypes = \array_filter(\array_map(static fn(string $emitterType): ?\Deptrac\Deptrac\Core\Analyser\TokenType => \Deptrac\Deptrac\Core\Analyser\TokenType::tryFromEmitterType(EmitterType::from($emitterType)), $config['types'])); }
@param array{types: array<string>} $config
__construct
php
deptrac/deptrac
src/Core/Analyser/UnassignedTokenAnalyser.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Analyser/UnassignedTokenAnalyser.php
MIT
private function recursivelyResolveDependencies(\Deptrac\Deptrac\Core\Ast\AstMap\AstInherit $inheritDependency, ?ArrayObject $alreadyResolved = null, ?SplStack $pathStack = null) : iterable { $alreadyResolved ??= new ArrayObject(); /** @var ArrayObject<string, true> $alreadyResolved */ if (null === $pathStack) { /** @var SplStack<AstInherit> $pathStack */ $pathStack = new SplStack(); $pathStack->push($inheritDependency); } $className = $inheritDependency->classLikeName->toString(); if (isset($alreadyResolved[$className])) { $pathStack->pop(); return []; } $classReference = $this->getClassReferenceForToken($inheritDependency->classLikeName); if (null === $classReference) { return []; } foreach ($classReference->inherits as $inherit) { $alreadyResolved[$className] = \true; /** @var AstInherit[] $path */ $path = \iterator_to_array($pathStack); (yield $inherit->replacePath($path)); $pathStack->push($inherit); yield from $this->recursivelyResolveDependencies($inherit, $alreadyResolved, $pathStack); unset($alreadyResolved[$className]); $pathStack->pop(); } }
@param ArrayObject<string, true>|null $alreadyResolved @param SplStack<AstInherit>|null $pathStack @return iterable<AstInherit>
recursivelyResolveDependencies
php
deptrac/deptrac
src/Core/Ast/AstMap/AstMap.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/AstMap.php
MIT
public function unresolvedFunctionCall(string $functionName, int $occursAtLine) : self { $this->dependencies[] = new \Deptrac\Deptrac\Core\Ast\AstMap\DependencyToken(FunctionToken::fromFQCN($functionName), $this->createContext($occursAtLine, DependencyType::UNRESOLVED_FUNCTION_CALL)); return $this; }
Unqualified function and constant names inside a namespace cannot be statically resolved. Inside a namespace Foo, a call to strlen() may either refer to the namespaced \Foo\strlen(), or the global \strlen(). Because PHP-Parser does not have the necessary context to decide this, such names are left unresolved.
unresolvedFunctionCall
php
deptrac/deptrac
src/Core/Ast/AstMap/ReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/ReferenceBuilder.php
MIT
public function __construct(private readonly \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken $classLikeName, ?\Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeType $classLikeType = null, public readonly array $inherits = [], public readonly array $dependencies = [], public readonly array $tags = [], private readonly ?FileReference $fileReference = null) { parent::__construct($tags); $this->type = $classLikeType ?? \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeType::TYPE_CLASSLIKE; }
@param AstInherit[] $inherits @param DependencyToken[] $dependencies @param array<string,list<string>> $tags
__construct
php
deptrac/deptrac
src/Core/Ast/AstMap/ClassLike/ClassLikeReference.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/ClassLike/ClassLikeReference.php
MIT
private function __construct(array $tokenTemplates, string $filepath, private readonly \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken $classLikeToken, private readonly \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeType $classLikeType, private readonly array $tags) { parent::__construct($tokenTemplates, $filepath); }
@param list<string> $tokenTemplates @param array<string,list<string>> $tags
__construct
php
deptrac/deptrac
src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
MIT
public static function createClassLike(string $filepath, string $classLikeName, array $classTemplates, array $tags) : self { return new self($classTemplates, $filepath, \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken::fromFQCN($classLikeName), \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeType::TYPE_CLASSLIKE, $tags); }
@param list<string> $classTemplates @param array<string,list<string>> $tags
createClassLike
php
deptrac/deptrac
src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
MIT
public static function createClass(string $filepath, string $classLikeName, array $classTemplates, array $tags) : self { return new self($classTemplates, $filepath, \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken::fromFQCN($classLikeName), \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeType::TYPE_CLASS, $tags); }
@param list<string> $classTemplates @param array<string,list<string>> $tags
createClass
php
deptrac/deptrac
src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
MIT
public static function createTrait(string $filepath, string $classLikeName, array $classTemplates, array $tags) : self { return new self($classTemplates, $filepath, \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken::fromFQCN($classLikeName), \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeType::TYPE_TRAIT, $tags); }
@param list<string> $classTemplates @param array<string,list<string>> $tags
createTrait
php
deptrac/deptrac
src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
MIT
public static function createInterface(string $filepath, string $classLikeName, array $classTemplates, array $tags) : self { return new self($classTemplates, $filepath, \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken::fromFQCN($classLikeName), \Deptrac\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeType::TYPE_INTERFACE, $tags); }
@param list<string> $classTemplates @param array<string,list<string>> $tags
createInterface
php
deptrac/deptrac
src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/ClassLike/ClassLikeReferenceBuilder.php
MIT
public function __construct(public readonly string $filepath, array $classLikeReferences, array $functionReferences, public readonly array $dependencies) { /** @psalm-suppress ImpureFunctionCall */ $this->classLikeReferences = \array_map(fn(ClassLikeReference $classReference): ClassLikeReference => $classReference->withFileReference($this), $classLikeReferences); /** @psalm-suppress ImpureFunctionCall */ $this->functionReferences = \array_map(fn(FunctionReference $functionReference): FunctionReference => $functionReference->withFileReference($this), $functionReferences); }
@param ClassLikeReference[] $classLikeReferences @param FunctionReference[] $functionReferences @param DependencyToken[] $dependencies
__construct
php
deptrac/deptrac
src/Core/Ast/AstMap/File/FileReference.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/File/FileReference.php
MIT
public function newClass(string $classLikeName, array $templateTypes, array $tags) : ClassLikeReferenceBuilder { $classReference = ClassLikeReferenceBuilder::createClass($this->filepath, $classLikeName, $templateTypes, $tags); $this->classReferences[] = $classReference; return $classReference; }
@param list<string> $templateTypes @param array<string,list<string>> $tags
newClass
php
deptrac/deptrac
src/Core/Ast/AstMap/File/FileReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/File/FileReferenceBuilder.php
MIT
public function newTrait(string $classLikeName, array $templateTypes, array $tags) : ClassLikeReferenceBuilder { $classReference = ClassLikeReferenceBuilder::createTrait($this->filepath, $classLikeName, $templateTypes, $tags); $this->classReferences[] = $classReference; return $classReference; }
@param list<string> $templateTypes @param array<string,list<string>> $tags
newTrait
php
deptrac/deptrac
src/Core/Ast/AstMap/File/FileReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/File/FileReferenceBuilder.php
MIT
public function newClassLike(string $classLikeName, array $templateTypes, array $tags) : ClassLikeReferenceBuilder { $classReference = ClassLikeReferenceBuilder::createClassLike($this->filepath, $classLikeName, $templateTypes, $tags); $this->classReferences[] = $classReference; return $classReference; }
@param list<string> $templateTypes @param array<string,list<string>> $tags
newClassLike
php
deptrac/deptrac
src/Core/Ast/AstMap/File/FileReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/File/FileReferenceBuilder.php
MIT
public function newInterface(string $classLikeName, array $templateTypes, array $tags) : ClassLikeReferenceBuilder { $classReference = ClassLikeReferenceBuilder::createInterface($this->filepath, $classLikeName, $templateTypes, $tags); $this->classReferences[] = $classReference; return $classReference; }
@param list<string> $templateTypes @param array<string,list<string>> $tags
newInterface
php
deptrac/deptrac
src/Core/Ast/AstMap/File/FileReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/File/FileReferenceBuilder.php
MIT
public function newFunction(string $functionName, array $templateTypes = [], array $tags = []) : FunctionReferenceBuilder { $functionReference = FunctionReferenceBuilder::create($this->filepath, $functionName, $templateTypes, $tags); $this->functionReferences[] = $functionReference; return $functionReference; }
@param list<string> $templateTypes @param array<string,list<string>> $tags
newFunction
php
deptrac/deptrac
src/Core/Ast/AstMap/File/FileReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/File/FileReferenceBuilder.php
MIT
public function __construct(private readonly \Deptrac\Deptrac\Core\Ast\AstMap\Function\FunctionToken $functionName, public readonly array $dependencies = [], public readonly array $tags = [], private readonly ?FileReference $fileReference = null) { parent::__construct($tags); }
@param DependencyToken[] $dependencies @param array<string,list<string>> $tags
__construct
php
deptrac/deptrac
src/Core/Ast/AstMap/Function/FunctionReference.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/Function/FunctionReference.php
MIT
private function __construct(array $tokenTemplates, string $filepath, private readonly string $functionName, private readonly array $tags) { parent::__construct($tokenTemplates, $filepath); }
@param list<string> $tokenTemplates @param array<string,list<string>> $tags
__construct
php
deptrac/deptrac
src/Core/Ast/AstMap/Function/FunctionReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/Function/FunctionReferenceBuilder.php
MIT
public static function create(string $filepath, string $functionName, array $functionTemplates, array $tags) : self { return new self($functionTemplates, $filepath, $functionName, $tags); }
@param list<string> $functionTemplates @param array<string,list<string>> $tags
create
php
deptrac/deptrac
src/Core/Ast/AstMap/Function/FunctionReferenceBuilder.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/AstMap/Function/FunctionReferenceBuilder.php
MIT
public function resolvePHPStanDocParserType(TypeNode $type, \Deptrac\Deptrac\Core\Ast\Parser\TypeScope $typeScope, array $templateTypes) : array { return match (\true) { $type instanceof IdentifierTypeNode => \in_array($type->name, $templateTypes, \true) ? [] : $this->resolveString($type->name, $typeScope), $type instanceof ConstTypeNode && $type->constExpr instanceof ConstFetchNode => $this->resolveString($type->constExpr->className, $typeScope), $type instanceof NullableTypeNode => $this->resolvePHPStanDocParserType($type->type, $typeScope, $templateTypes), $type instanceof ArrayTypeNode => $this->resolvePHPStanDocParserType($type->type, $typeScope, $templateTypes), $type instanceof UnionTypeNode || $type instanceof IntersectionTypeNode => $this->resolveVariableType($type, $typeScope, $templateTypes), $type instanceof GenericTypeNode => $this->resolveGeneric($type, $typeScope, $templateTypes), $type instanceof ArrayShapeNode => $this->resolveArray($type, $typeScope, $templateTypes), $type instanceof CallableTypeNode => $this->resolveCallable($type, $typeScope, $templateTypes), default => $this->resolveString((string) $type, $typeScope), }; }
@param array<string> $templateTypes @return string[]
resolvePHPStanDocParserType
php
deptrac/deptrac
src/Core/Ast/Parser/TypeResolver.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/TypeResolver.php
MIT
private function resolveGeneric(GenericTypeNode $type, \Deptrac\Deptrac\Core\Ast\Parser\TypeScope $typeScope, array $templateTypes) : array { $preType = 'list' === $type->type->name ? [] : $this->resolvePHPStanDocParserType($type->type, $typeScope, $templateTypes); return \array_merge($preType, ...\array_map(fn(TypeNode $typeNode): array => $this->resolvePHPStanDocParserType($typeNode, $typeScope, $templateTypes), $type->genericTypes)); }
@param array<string> $templateTypes @return string[]
resolveGeneric
php
deptrac/deptrac
src/Core/Ast/Parser/TypeResolver.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/TypeResolver.php
MIT
private function resolveCallable(CallableTypeNode $type, \Deptrac\Deptrac\Core\Ast\Parser\TypeScope $typeScope, array $templateTypes) : array { return \array_merge($this->resolvePHPStanDocParserType($type->returnType, $typeScope, $templateTypes), ...\array_map(fn(CallableTypeParameterNode $parameterNode): array => $this->resolvePHPStanDocParserType($parameterNode->type, $typeScope, $templateTypes), $type->parameters)); }
@param array<string> $templateTypes @return string[]
resolveCallable
php
deptrac/deptrac
src/Core/Ast/Parser/TypeResolver.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/TypeResolver.php
MIT
private function resolveArray(ArrayShapeNode $type, \Deptrac\Deptrac\Core\Ast\Parser\TypeScope $typeScope, array $templateTypes) : array { return \array_merge([], ...\array_map(fn(ArrayShapeItemNode $itemNode): array => $this->resolvePHPStanDocParserType($itemNode->valueType, $typeScope, $templateTypes), $type->items)); }
@param array<string> $templateTypes @return string[]
resolveArray
php
deptrac/deptrac
src/Core/Ast/Parser/TypeResolver.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/TypeResolver.php
MIT
private function resolveVariableType(UnionTypeNode|IntersectionTypeNode $type, \Deptrac\Deptrac\Core\Ast\Parser\TypeScope $typeScope, array $templateTypes) : array { return \array_merge([], ...\array_map(fn(TypeNode $typeNode): array => $this->resolvePHPStanDocParserType($typeNode, $typeScope, $templateTypes), $type->types)); }
@param array<string> $templateTypes @return string[]
resolveVariableType
php
deptrac/deptrac
src/Core/Ast/Parser/TypeResolver.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/TypeResolver.php
MIT
public static function getSubscribedEvents() : array { return [PreCreateAstMapEvent::class => 'onPreCreateAstMapEvent', PostCreateAstMapEvent::class => 'onPostCreateAstMapEvent']; }
@return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
getSubscribedEvents
php
deptrac/deptrac
src/Core/Ast/Parser/Cache/CacheableFileSubscriber.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/Cache/CacheableFileSubscriber.php
MIT
private function getDocNodeCrate(Node $node) : ?array { $docComment = $node->getDocComment(); if (null === $docComment) { return null; } $tokens = new TokenIterator($this->lexer->tokenize($docComment->getText())); return [$this->docParser->parse($tokens), $docComment->getStartLine()]; }
@return ?array{PhpDocNode, int} DocNode, comment start line
getDocNodeCrate
php
deptrac/deptrac
src/Core/Ast/Parser/NikicPhpParser/FileReferenceVisitor.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/NikicPhpParser/FileReferenceVisitor.php
MIT
private function enterInterface(string $name, Interface_ $node, array $tags) : void { $this->currentReference = $this->fileReferenceBuilder->newInterface($name, $this->templatesFromDocs($node), $tags); foreach ($node->extends as $extend) { $this->currentReference->implements($extend->toCodeString(), $extend->getLine()); } }
@param array<string,list<string>> $tags
enterInterface
php
deptrac/deptrac
src/Core/Ast/Parser/NikicPhpParser/FileReferenceVisitor.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/NikicPhpParser/FileReferenceVisitor.php
MIT
private function enterClass(string $name, Class_ $node, array $tags) : void { $this->currentReference = $this->fileReferenceBuilder->newClass($name, $this->templatesFromDocs($node), $tags); if ($node->extends instanceof Name) { $this->currentReference->extends($node->extends->toCodeString(), $node->extends->getLine()); } foreach ($node->implements as $implement) { $this->currentReference->implements($implement->toCodeString(), $implement->getLine()); } }
@param array<string,list<string>> $tags
enterClass
php
deptrac/deptrac
src/Core/Ast/Parser/NikicPhpParser/FileReferenceVisitor.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Ast/Parser/NikicPhpParser/FileReferenceVisitor.php
MIT
private function createDependenciesForReferences(array $references, AstMap $astMap, DependencyList $dependencyList) : void { foreach ($references as $reference) { foreach ($reference->dependencies as $dependency) { if (DependencyType::UNRESOLVED_FUNCTION_CALL !== $dependency->context->dependencyType) { continue; } $token = $dependency->token; \assert($token instanceof FunctionToken); if (null === $astMap->getFunctionReferenceForToken($token)) { continue; } $dependencyList->addDependency(new Dependency($reference->getToken(), $dependency->token, $dependency->context)); } } }
@param array<FunctionReference|ClassLikeReference|FileReference> $references
createDependenciesForReferences
php
deptrac/deptrac
src/Core/Dependency/Emitter/FunctionCallDependencyEmitter.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Dependency/Emitter/FunctionCallDependencyEmitter.php
MIT
public function __construct(array $paths, private readonly array $excludedFilePatterns, string $basePath) { $basePathInfo = new SplFileInfo($basePath); if (!$basePathInfo->isDir() || !$basePathInfo->isReadable()) { throw InvalidPathException::unreadablePath($basePathInfo); } $this->paths = []; foreach ($paths as $originalPath) { if (Path::isRelative($originalPath)) { /** @throws void */ $path = Path::makeAbsolute($originalPath, $basePathInfo->getPathname()); } else { $path = $originalPath; } $path = new SplFileInfo($path); if (!$path->isReadable()) { throw InvalidPathException::unreadablePath($path); } $this->paths[] = Path::canonicalize($path->getPathname()); } }
@param string[] $paths @param string[] $excludedFilePatterns @throws InvalidPathException
__construct
php
deptrac/deptrac
src/Core/InputCollector/FileInputCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/InputCollector/FileInputCollector.php
MIT
private function getSearchedSubstring(array $config) : string { if (!isset($config['value']) || !\is_string($config['value'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('AttributeCollector needs the attribute name as a string.'); } return $config['value']; }
@param array<string, bool|string|array<string, string>> $config @throws InvalidCollectorDefinitionException
getSearchedSubstring
php
deptrac/deptrac
src/Core/Layer/Collector/AttributeCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/AttributeCollector.php
MIT
private function normalizeConfiguration(array $configuration) : array { if (!isset($configuration['must'])) { $configuration['must'] = []; } if (!isset($configuration['must_not'])) { $configuration['must_not'] = []; } if (!$configuration['must'] && !$configuration['must_not']) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('"bool" collector must have a "must" or a "must_not" attribute.'); } return $configuration; }
@param array<string, bool|string|array<string, string>> $configuration @return array<string, bool|string|array<string, string>> @throws InvalidCollectorDefinitionException
normalizeConfiguration
php
deptrac/deptrac
src/Core/Layer/Collector/BoolCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/BoolCollector.php
MIT
public function resolve(array $config) : \Deptrac\Deptrac\Core\Layer\Collector\Collectable { if (!array_key_exists('type', $config) || !is_string($config['type'])) { throw InvalidCollectorDefinitionException::missingType(); } try { $collector = $this->collectorProvider->get($config['type']); } catch (ContainerExceptionInterface $containerException) { throw InvalidCollectorDefinitionException::unsupportedType($config['type'], $this->collectorProvider->getKnownCollectors(), $containerException); } return new \Deptrac\Deptrac\Core\Layer\Collector\Collectable($collector, $config); }
@param array<string, string|array<string, string>> $config @throws InvalidCollectorDefinitionException
resolve
php
deptrac/deptrac
src/Core/Layer/Collector/CollectorResolver.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/CollectorResolver.php
MIT
public function autoloadableNamespacesForRequirements(array $requirements, bool $includeDev) : array { $namespaces = [[]]; foreach ($requirements as $package) { if (!\array_key_exists($package, $this->lockedPackages)) { throw new RuntimeException(\sprintf('Could not find a "%s" package', $package)); } $namespaces[] = $this->extractNamespaces($this->lockedPackages[$package], $includeDev); } return \array_merge(...$namespaces); }
Resolves an array of package names to an array of namespaces declared by those packages. @param string[] $requirements @return string[] @throws RuntimeException
autoloadableNamespacesForRequirements
php
deptrac/deptrac
src/Core/Layer/Collector/ComposerFilesParser.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/ComposerFilesParser.php
MIT
private function getPackagesFromLockFile() : array { $lockedPackages = []; foreach ($this->lockFile['packages'] ?? [] as $package) { $lockedPackages[$package['name']] = $package; } foreach ($this->lockFile['packages-dev'] ?? [] as $package) { $lockedPackages[$package['name']] = $package; } return $lockedPackages; }
@return array<string, array{ autoload?: array{'psr-0'?: array<string, string>, 'psr-4'?: array<string, string>}, autoload-dev?: array{'psr-0'?: array<string, string>, 'psr-4'?: array<string, string>}, }>
getPackagesFromLockFile
php
deptrac/deptrac
src/Core/Layer/Collector/ComposerFilesParser.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/ComposerFilesParser.php
MIT
private function extractNamespaces(array $package, bool $includeDev) : array { $namespaces = []; foreach (\array_keys($package['autoload']['psr-0'] ?? []) as $namespace) { $namespaces[] = $namespace; } foreach (\array_keys($package['autoload']['psr-4'] ?? []) as $namespace) { $namespaces[] = $namespace; } if ($includeDev) { foreach (\array_keys($package['autoload-dev']['psr-0'] ?? []) as $namespace) { $namespaces[] = $namespace; } foreach (\array_keys($package['autoload-dev']['psr-4'] ?? []) as $namespace) { $namespaces[] = $namespace; } } return $namespaces; }
@param array{ autoload?: array{'psr-0'?: array<string, string>, 'psr-4'?: array<string, string>}, autoload-dev?: array{'psr-0'?: array<string, string>, 'psr-4'?: array<string, string>}, } $package @return string[]
extractNamespaces
php
deptrac/deptrac
src/Core/Layer/Collector/ComposerFilesParser.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/ComposerFilesParser.php
MIT
private function getInterfaceName(array $config) : ClassLikeToken { if (!isset($config['value']) || !\is_string($config['value'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('ExtendsCollector needs the interface or class name as a string.'); } return ClassLikeToken::fromFQCN($config['value']); }
@param array<string, bool|string|array<string, string>> $config @throws InvalidCollectorDefinitionException
getInterfaceName
php
deptrac/deptrac
src/Core/Layer/Collector/ExtendsCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/ExtendsCollector.php
MIT
private function getPattern(array $config) : string { if (!isset($config['value']) || !\is_string($config['value'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('FunctionNameCollector needs the regex configuration.'); } return '/' . $config['value'] . '/i'; }
@param array<string, bool|string|array<string, string>> $config @throws InvalidCollectorDefinitionException
getPattern
php
deptrac/deptrac
src/Core/Layer/Collector/FunctionNameCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/FunctionNameCollector.php
MIT
private function getInterfaceName(array $config) : ClassLikeToken { if (!isset($config['value']) || !\is_string($config['value'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('ImplementsCollector needs the interface name as a string.'); } return ClassLikeToken::fromFQCN($config['value']); }
@param array<string, bool|string|array<string, string>> $config @throws InvalidCollectorDefinitionException
getInterfaceName
php
deptrac/deptrac
src/Core/Layer/Collector/ImplementsCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/ImplementsCollector.php
MIT
private function getClassLikeName(array $config) : ClassLikeToken { if (!isset($config['value']) || !\is_string($config['value'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('InheritsCollector needs the interface, trait or class name as a string.'); } return ClassLikeToken::fromFQCN($config['value']); }
@param array<string, bool|string|array<string, string>> $config @throws InvalidCollectorDefinitionException
getClassLikeName
php
deptrac/deptrac
src/Core/Layer/Collector/InheritsCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/InheritsCollector.php
MIT
private function getPattern(array $config) : string { if (!isset($config['value']) || !\is_string($config['value'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('PhpInternalCollector needs configuration.'); } return '/' . $config['value'] . '/i'; }
@param array<string, bool|string|array<string, string>> $config @throws InvalidCollectorDefinitionException
getPattern
php
deptrac/deptrac
src/Core/Layer/Collector/PhpInternalCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/PhpInternalCollector.php
MIT
protected function getValidatedPattern(array $config) : string { $pattern = $this->getPattern($config); if (\false !== @\preg_match($pattern, '')) { return $pattern; } throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('Invalid regex pattern ' . $pattern); }
@param array<string, bool|string|array<string, string>> $config @throws InvalidCollectorDefinitionException
getValidatedPattern
php
deptrac/deptrac
src/Core/Layer/Collector/RegexCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/RegexCollector.php
MIT
private function getNames(array $config) : array { if (!isset($config['value']) || !\is_array($config['value'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('SuperglobalCollector needs the names configuration.'); } return \array_map(static fn($name): string => '$' . $name, $config['value']); }
@param array<string, bool|string|array<string, string>> $config @return string[] @throws InvalidCollectorDefinitionException
getNames
php
deptrac/deptrac
src/Core/Layer/Collector/SuperglobalCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/SuperglobalCollector.php
MIT
public function satisfy(array $config, TokenReferenceInterface $reference) : bool { if (!$reference instanceof TaggedTokenReferenceInterface) { return \false; } $tagLines = $reference->getTagLines($this->getTagName($config)); $pattern = $this->getValidatedPattern($config); if (null === $tagLines || [] === $tagLines) { return \false; } foreach ($tagLines as $line) { if (\preg_match($pattern, $line)) { return \true; } } return \false; }
@param array<string, bool|string|array<string, string>> $config
satisfy
php
deptrac/deptrac
src/Core/Layer/Collector/TagValueRegexCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/TagValueRegexCollector.php
MIT
protected function getTagName(array $config) : string { if (!isset($config['tag']) || !\is_string($config['tag'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('TagValueRegexCollector needs the tag name.'); } if (!\preg_match('/^@[-\\w]+$/', $config['tag'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('TagValueRegexCollector needs a valid tag name.'); } return $config['tag']; }
@param array<string, bool|string|array<string, string>|null> $config @throws InvalidCollectorDefinitionException
getTagName
php
deptrac/deptrac
src/Core/Layer/Collector/TagValueRegexCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/TagValueRegexCollector.php
MIT
private function getTraitName(array $config) : ClassLikeToken { if (!isset($config['value']) || !\is_string($config['value'])) { throw InvalidCollectorDefinitionException::invalidCollectorConfiguration('UsesCollector needs the trait name as a string.'); } return ClassLikeToken::fromFQCN($config['value']); }
@param array<string, bool|string|array<string, string>> $config @throws InvalidCollectorDefinitionException
getTraitName
php
deptrac/deptrac
src/Core/Layer/Collector/UsesCollector.php
https://github.com/deptrac/deptrac/blob/master/src/Core/Layer/Collector/UsesCollector.php
MIT
public function get(string $name) : string|false { return \getenv($name); }
@return string|false Environment variable value or false if the variable does not exist
get
php
deptrac/deptrac
src/Supportive/Console/Env.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Console/Env.php
MIT
public function run(array $files, bool $withDependencies, OutputInterface $output) : void { try { $layers = []; foreach ($files as $file) { $matches = $this->layerForTokenAnalyser->findLayerForToken($file, TokenType::FILE); foreach ($matches as $match) { foreach ($match as $layer) { $layers[$layer] = $layer; } } } $output->writeLineFormatted(\implode(';', $layers)); } catch (AnalyserException $exception) { throw \Deptrac\Deptrac\Supportive\Console\Command\CommandRunException::analyserException($exception); } if ($withDependencies) { try { $result = OutputResult::fromAnalysisResult($this->dependencyLayersAnalyser->analyse()); $layersDependOnLayers = $this->calculateLayerDependencies($result->allRules()); $layerDependencies = []; foreach ($layers as $layer) { $layerDependencies += $layersDependOnLayers[$layer] ?? []; } do { $size = \count($layerDependencies); $layerDependenciesCopy = $layerDependencies; foreach ($layerDependenciesCopy as $layerDependency) { $layerDependencies += $layersDependOnLayers[$layerDependency] ?? []; } } while ($size !== \count($layerDependencies)); $output->writeLineFormatted(\implode(';', $layerDependencies)); } catch (AnalyserException $exception) { throw \Deptrac\Deptrac\Supportive\Console\Command\CommandRunException::analyserException($exception); } } }
@param list<string> $files @throws CommandRunException
run
php
deptrac/deptrac
src/Supportive/Console/Command/ChangedFilesRunner.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Console/Command/ChangedFilesRunner.php
MIT
private function calculateLayerDependencies(array $rules) : array { $layersDependOnLayers = []; foreach ($rules as $rule) { if (!$rule instanceof CoveredRuleInterface) { continue; } $layerA = $rule->getDependerLayer(); $layerB = $rule->getDependentLayer(); if (!isset($layersDependOnLayers[$layerB])) { $layersDependOnLayers[$layerB] = []; } if (!\array_key_exists($layerA, $layersDependOnLayers[$layerB])) { $layersDependOnLayers[$layerB][$layerA] = $layerA; } } return $layersDependOnLayers; }
@param RuleInterface[] $rules @return array<string, array<string, string>>
calculateLayerDependencies
php
deptrac/deptrac
src/Supportive/Console/Command/ChangedFilesRunner.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Console/Command/ChangedFilesRunner.php
MIT
public function run(OutputInterface $output) : bool { try { $unassignedTokens = $this->analyser->findUnassignedTokens(); } catch (AnalyserException $e) { throw \Deptrac\Deptrac\Supportive\Console\Command\CommandRunException::analyserException($e); } if ([] === $unassignedTokens) { $output->writeLineFormatted('There are no unassigned tokens.'); return \false; } $output->writeLineFormatted($unassignedTokens); return \true; }
@return bool are there any unassigned tokens? @throws CommandRunException
run
php
deptrac/deptrac
src/Supportive/Console/Command/DebugUnassignedRunner.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Console/Command/DebugUnassignedRunner.php
MIT
private function prepareOutputTable(array $layerNames, int $limit) : array { $rows = []; foreach ($layerNames as $dependerLayerName => $dependentLayerNames) { foreach ($dependentLayerNames as $dependentLayerName => $numberOfDependencies) { if ($numberOfDependencies <= $limit) { if (0 === $numberOfDependencies) { $rows[] = ["<info>{$dependerLayerName}</info> layer is not dependent on <info>{$dependentLayerName}</info>"]; } else { $rows[] = ["<info>{$dependerLayerName}</info> layer is dependent <info>{$dependentLayerName}</info> layer {$numberOfDependencies} times"]; } } } } return $rows; }
@param array<string, array<string, int>> $layerNames @return array<array{string}>
prepareOutputTable
php
deptrac/deptrac
src/Supportive/Console/Command/DebugUnusedRunner.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Console/Command/DebugUnusedRunner.php
MIT
private function printMessageWithTime(string $event, string $messageWithTime, string $messageWithoutTime) : void { try { $period = $this->stopwatch->stop($event); $this->output->writeLineFormatted(sprintf($messageWithTime, $period->toSeconds())); } catch (StopwatchException) { $this->output->writeLineFormatted($messageWithoutTime); } }
@param non-empty-string $event @param non-empty-string $messageWithTime @param non-empty-string $messageWithoutTime
printMessageWithTime
php
deptrac/deptrac
src/Supportive/Console/Subscriber/ConsoleSubscriber.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Console/Subscriber/ConsoleSubscriber.php
MIT
public static function getSubscribedEvents() : array { return [PreCreateAstMapEvent::class => 'onPreCreateAstMapEvent', PostCreateAstMapEvent::class => ['onPostCreateAstMapEvent', 1], AstFileAnalysedEvent::class => 'onAstFileAnalysedEvent']; }
@return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
getSubscribedEvents
php
deptrac/deptrac
src/Supportive/Console/Subscriber/ProgressSubscriber.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Console/Subscriber/ProgressSubscriber.php
MIT
public function dump(string $file) : void { $filesystem = new Filesystem(); $target = new SplFileInfo($file); if ($filesystem->exists($target->getPathname())) { throw FileAlreadyExistsException::alreadyExists($target); } if (!is_writable($target->getPath())) { throw FileNotWritableException::notWritable($target); } try { $filesystem->copy($this->templateFile->getPathname(), $target->getPathname()); } catch (FileNotFoundException) { throw FileNotExistsException::fromFilePath($this->templateFile->getPathname()); } catch (SymfonyIOException $e) { throw IOException::couldNotCopy($e->getMessage()); } }
@throws FileAlreadyExistsException @throws FileNotWritableException @throws FileNotExistsException @throws IOException
dump
php
deptrac/deptrac
src/Supportive/File/Dumper.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/File/Dumper.php
MIT
public function parseFile(string $file) : array { try { $data = Yaml::parse(\Deptrac\Deptrac\Supportive\File\FileReader::read($file)); } catch (ParseException $exception) { throw FileCannotBeParsedAsYamlException::fromFilenameAndException($file, $exception); } if (!\is_array($data)) { throw ParsedYamlIsNotAnArrayException::fromFilename($file); } /** @var array{parameters: array<string, mixed>, services: array<string, mixed>, imports?: array<string>} $data */ return $data; }
@return array{parameters: array<string, mixed>, services: array<string, mixed>, imports?: array<string>} @throws FileCannotBeParsedAsYamlException @throws ParsedYamlIsNotAnArrayException @throws CouldNotReadFileException
parseFile
php
deptrac/deptrac
src/Supportive/File/YmlFileLoader.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/File/YmlFileLoader.php
MIT
private function addFailure(array &$violationsArray, Violation $violation, ConfigurationCodeclimate $config) : void { $violationsArray[] = $this->buildRuleArray($violation, $this->getFailureMessage($violation), $config->getSeverity('failure') ?? 'major'); }
@param array<array{type: string, check_name: string, fingerprint: string, description: string, categories: array<string>, severity: string, location: array{path: string, lines: array{begin: int}}}> $violationsArray
addFailure
php
deptrac/deptrac
src/Supportive/OutputFormatter/CodeclimateOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/CodeclimateOutputFormatter.php
MIT
private function addSkipped(array &$violationsArray, SkippedViolation $violation, ConfigurationCodeclimate $config) : void { $violationsArray[] = $this->buildRuleArray($violation, $this->getWarningMessage($violation), $config->getSeverity('skipped') ?? 'minor'); }
@param array<array{type: string, check_name: string, fingerprint: string, description: string, categories: array<string>, severity: string, location: array{path: string, lines: array{begin: int}}}> $violationsArray
addSkipped
php
deptrac/deptrac
src/Supportive/OutputFormatter/CodeclimateOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/CodeclimateOutputFormatter.php
MIT
private function addUncovered(array &$violationsArray, Uncovered $violation, ConfigurationCodeclimate $config) : void { $violationsArray[] = $this->buildRuleArray($violation, $this->getUncoveredMessage($violation), $config->getSeverity('uncovered') ?? 'info'); }
@param array<array{type: string, check_name: string, fingerprint: string, description: string, categories: array<string>, severity: string, location: array{path: string, lines: array{begin: int}}}> $violationsArray
addUncovered
php
deptrac/deptrac
src/Supportive/OutputFormatter/CodeclimateOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/CodeclimateOutputFormatter.php
MIT
private function buildRuleArray(RuleInterface $rule, string $message, string $severity) : array { return ['type' => 'issue', 'check_name' => 'Dependency violation', 'fingerprint' => $this->buildFingerprint($rule), 'description' => $message, 'categories' => ['Style', 'Complexity'], 'severity' => $severity, 'location' => ['path' => $rule->getDependency()->getContext()->fileOccurrence->filepath, 'lines' => ['begin' => $rule->getDependency()->getContext()->fileOccurrence->line]]]; }
@return array{type: string, check_name: string, fingerprint: string, description: string, categories: array<string>, severity: string, location: array{path: string, lines: array{begin: int}}}
buildRuleArray
php
deptrac/deptrac
src/Supportive/OutputFormatter/CodeclimateOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/CodeclimateOutputFormatter.php
MIT
private function calculateViolations(array $violations) : array { $layerViolations = []; foreach ($violations as $violation) { if (!isset($layerViolations[$violation->getDependerLayer()])) { $layerViolations[$violation->getDependerLayer()] = []; } if (!isset($layerViolations[$violation->getDependerLayer()][$violation->getDependentLayer()])) { $layerViolations[$violation->getDependerLayer()][$violation->getDependentLayer()] = 1; } else { ++$layerViolations[$violation->getDependerLayer()][$violation->getDependentLayer()]; } } return $layerViolations; }
@param Violation[] $violations @return array<string, array<string, int>>
calculateViolations
php
deptrac/deptrac
src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
MIT
private function calculateLayerDependencies(array $rules) : array { $layersDependOnLayers = []; foreach ($rules as $rule) { if ($rule instanceof CoveredRuleInterface) { $layerA = $rule->getDependerLayer(); $layerB = $rule->getDependentLayer(); if (!isset($layersDependOnLayers[$layerA])) { $layersDependOnLayers[$layerA] = []; } if (!isset($layersDependOnLayers[$layerA][$layerB])) { $layersDependOnLayers[$layerA][$layerB] = 1; continue; } ++$layersDependOnLayers[$layerA][$layerB]; } elseif ($rule instanceof Uncovered) { if (!isset($layersDependOnLayers[$rule->layer])) { $layersDependOnLayers[$rule->layer] = []; } } } return $layersDependOnLayers; }
@param RuleInterface[] $rules @return array<string, array<string, int>>
calculateLayerDependencies
php
deptrac/deptrac
src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
MIT
private function createNodes(ConfigurationGraphViz $outputConfig, array $layersDependOnLayers) : array { $nodes = []; foreach ($layersDependOnLayers as $layer => $layersDependOn) { if (\in_array($layer, $outputConfig->hiddenLayers, \true)) { continue; } if (!isset($nodes[$layer])) { $nodes[$layer] = new Node($layer); } foreach ($layersDependOn as $layerDependOn => $_) { if (\in_array($layerDependOn, $outputConfig->hiddenLayers, \true)) { continue; } if (!isset($nodes[$layerDependOn])) { $nodes[$layerDependOn] = new Node($layerDependOn); } } } return $nodes; }
@param array<string, array<string, int>> $layersDependOnLayers @return Node[]
createNodes
php
deptrac/deptrac
src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
MIT
private function connectEdges(Graph $graph, array $nodes, ConfigurationGraphViz $outputConfig, array $layersDependOnLayers, array $layerViolations) : void { foreach ($layersDependOnLayers as $layer => $layersDependOn) { if (\in_array($layer, $outputConfig->hiddenLayers, \true)) { continue; } foreach ($layersDependOn as $layerDependOn => $layerDependOnCount) { if (\in_array($layerDependOn, $outputConfig->hiddenLayers, \true)) { continue; } $edge = new Edge($nodes[$layer], $nodes[$layerDependOn]); if ($outputConfig->pointToGroups && $graph->hasGraph($this->getSubgraphName($layerDependOn))) { $edge->setAttribute('lhead', $this->getSubgraphName($layerDependOn)); } $graph->link($edge); if (isset($layerViolations[$layer][$layerDependOn])) { $edge->setAttribute('label', (string) $layerViolations[$layer][$layerDependOn]); $edge->setAttribute('color', 'red'); } else { $edge->setAttribute('label', (string) $layerDependOnCount); } } } }
@param Node[] $nodes @param array<string, array<string, int>> $layersDependOnLayers @param array<string, array<string, int>> $layerViolations
connectEdges
php
deptrac/deptrac
src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/GraphVizOutputFormatter.php
MIT
private function addFailure(array &$violationsArray, Violation $violation) : void { $className = $violation->getDependency()->getContext()->fileOccurrence->filepath; $violationsArray[$className]['messages'][] = ['message' => $this->getFailureMessage($violation), 'line' => $violation->getDependency()->getContext()->fileOccurrence->line, 'type' => 'error']; }
@param array<string, array{messages: array<int, array{message: string, line: int, type: string}>}> $violationsArray
addFailure
php
deptrac/deptrac
src/Supportive/OutputFormatter/JsonOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/JsonOutputFormatter.php
MIT
private function addSkipped(array &$violationsArray, SkippedViolation $violation) : void { $className = $violation->getDependency()->getContext()->fileOccurrence->filepath; $violationsArray[$className]['messages'][] = ['message' => $this->getWarningMessage($violation), 'line' => $violation->getDependency()->getContext()->fileOccurrence->line, 'type' => 'warning']; }
@param array<string, array{messages: array<int, array{message: string, line: int, type: string}>}> $violationsArray
addSkipped
php
deptrac/deptrac
src/Supportive/OutputFormatter/JsonOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/JsonOutputFormatter.php
MIT
private function addUncovered(array &$violationsArray, Uncovered $violation) : void { $className = $violation->getDependency()->getContext()->fileOccurrence->filepath; $violationsArray[$className]['messages'][] = ['message' => $this->getUncoveredMessage($violation), 'line' => $violation->getDependency()->getContext()->fileOccurrence->line, 'type' => 'warning']; }
@param array<string, array{messages: array<int, array{message: string, line: int, type: string}>}> $violationsArray
addUncovered
php
deptrac/deptrac
src/Supportive/OutputFormatter/JsonOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/JsonOutputFormatter.php
MIT
protected function parseResults(OutputResult $result) : array { $graph = []; foreach ($result->allowed() as $rule) { if (!isset($graph[$rule->getDependerLayer()][$rule->getDependentLayer()])) { $graph[$rule->getDependerLayer()][$rule->getDependentLayer()] = 1; } else { ++$graph[$rule->getDependerLayer()][$rule->getDependentLayer()]; } } return $graph; }
@return array<string, array<string, int<1, max>>>
parseResults
php
deptrac/deptrac
src/Supportive/OutputFormatter/MermaidJSOutputFormatter.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/MermaidJSOutputFormatter.php
MIT
public static function fromArray(array $array) : self { return new self($array['severity'] ?? []); }
@param array{severity?: array{failure?: string, skipped?: string, uncovered?: string}} $array
fromArray
php
deptrac/deptrac
src/Supportive/OutputFormatter/Configuration/ConfigurationCodeclimate.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/Configuration/ConfigurationCodeclimate.php
MIT
public static function fromArray(array $arr) : self { return new self($arr['hidden_layers'] ?? [], $arr['groups'] ?? [], $arr['point_to_groups'] ?? \false); }
@param array{hidden_layers?: string[], groups?: array<string, string[]>, point_to_groups?: bool} $arr
fromArray
php
deptrac/deptrac
src/Supportive/OutputFormatter/Configuration/ConfigurationGraphViz.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/OutputFormatter/Configuration/ConfigurationGraphViz.php
MIT
public function start(string $event) : void { $this->assertPeriodNotStarted($event); $this->periods[$event] = \Deptrac\Deptrac\Supportive\Time\StartedPeriod::start(); }
@param non-empty-string $event @throws StopwatchException
start
php
deptrac/deptrac
src/Supportive/Time/Stopwatch.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Time/Stopwatch.php
MIT
public function stop(string $event) : \Deptrac\Deptrac\Supportive\Time\Period { $this->assertPeriodStarted($event); $period = $this->periods[$event]->stop(); unset($this->periods[$event]); return $period; }
@param non-empty-string $event @throws StopwatchException
stop
php
deptrac/deptrac
src/Supportive/Time/Stopwatch.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Time/Stopwatch.php
MIT
private function assertPeriodNotStarted(string $event) : void { if (array_key_exists($event, $this->periods)) { throw \Deptrac\Deptrac\Supportive\Time\StopwatchException::periodAlreadyStarted($event); } }
@param non-empty-string $event @throws StopwatchException
assertPeriodNotStarted
php
deptrac/deptrac
src/Supportive/Time/Stopwatch.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Time/Stopwatch.php
MIT
private function assertPeriodStarted(string $event) : void { if (!array_key_exists($event, $this->periods)) { throw \Deptrac\Deptrac\Supportive\Time\StopwatchException::periodNotStarted($event); } }
@param non-empty-string $event @throws StopwatchException
assertPeriodStarted
php
deptrac/deptrac
src/Supportive/Time/Stopwatch.php
https://github.com/deptrac/deptrac/blob/master/src/Supportive/Time/Stopwatch.php
MIT
public function getClassMap() { return $this->classMap; }
@return array<string, string> Array of classname => path
getClassMap
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function addClassMap(array $classMap) { if ($this->classMap) { $this->classMap = array_merge($this->classMap, $classMap); } else { $this->classMap = $classMap; } }
@param array<string, string> $classMap Class to filename map @return void
addClassMap
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function add($prefix, $paths, $prepend = false) { $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, $paths ); } return; } $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], $paths ); } }
Registers a set of PSR-0 directories for a given prefix, either appending or prepending to the ones previously set for this prefix. @param string $prefix The prefix @param list<string>|string $paths The PSR-0 root directories @param bool $prepend Whether to prepend the directories @return void
add
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function addPsr4($prefix, $paths, $prepend = false) { $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { // Register directories for a new namespace. $length = strlen($prefix); if ('\\' !== $prefix[$length - 1]) { throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], $paths ); } }
Registers a set of PSR-4 directories for a given namespace, either appending or prepending to the ones previously set for this namespace. @param string $prefix The prefix/namespace, with trailing '\\' @param list<string>|string $paths The PSR-4 base directories @param bool $prepend Whether to prepend the directories @throws \InvalidArgumentException @return void
addPsr4
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function set($prefix, $paths) { if (!$prefix) { $this->fallbackDirsPsr0 = (array) $paths; } else { $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; } }
Registers a set of PSR-0 directories for a given prefix, replacing any others previously set for this prefix. @param string $prefix The prefix @param list<string>|string $paths The PSR-0 base directories @return void
set
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function setPsr4($prefix, $paths) { if (!$prefix) { $this->fallbackDirsPsr4 = (array) $paths; } else { $length = strlen($prefix); if ('\\' !== $prefix[$length - 1]) { throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; $this->prefixDirsPsr4[$prefix] = (array) $paths; } }
Registers a set of PSR-4 directories for a given namespace, replacing any others previously set for this namespace. @param string $prefix The prefix/namespace, with trailing '\\' @param list<string>|string $paths The PSR-4 base directories @throws \InvalidArgumentException @return void
setPsr4
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function setUseIncludePath($useIncludePath) { $this->useIncludePath = $useIncludePath; }
Turns on searching the include path for class files. @param bool $useIncludePath @return void
setUseIncludePath
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function getUseIncludePath() { return $this->useIncludePath; }
Can be used to check if the autoloader uses the include path to check for classes. @return bool
getUseIncludePath
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function setClassMapAuthoritative($classMapAuthoritative) { $this->classMapAuthoritative = $classMapAuthoritative; }
Turns off searching the prefix and fallback directories for classes that have not been registered with the class map. @param bool $classMapAuthoritative @return void
setClassMapAuthoritative
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function isClassMapAuthoritative() { return $this->classMapAuthoritative; }
Should class lookup fail if not found in the current class map? @return bool
isClassMapAuthoritative
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function setApcuPrefix($apcuPrefix) { $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; }
APCu prefix to use to cache found/not-found classes, if the extension is enabled. @param string|null $apcuPrefix @return void
setApcuPrefix
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function getApcuPrefix() { return $this->apcuPrefix; }
The APCu prefix in use, or null if APCu caching is not enabled. @return string|null
getApcuPrefix
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); if (null === $this->vendorDir) { return; } if ($prepend) { self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; } else { unset(self::$registeredLoaders[$this->vendorDir]); self::$registeredLoaders[$this->vendorDir] = $this; } }
Registers this instance as an autoloader. @param bool $prepend Whether to prepend the autoloader or not @return void
register
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); if (null !== $this->vendorDir) { unset(self::$registeredLoaders[$this->vendorDir]); } }
Unregisters this instance as an autoloader. @return void
unregister
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function loadClass($class) { if ($file = $this->findFile($class)) { $includeFile = self::$includeFile; $includeFile($file); return true; } return null; }
Loads the given class or interface. @param string $class The name of the class @return true|null True if loaded, null otherwise
loadClass
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public function findFile($class) { // class map lookup if (isset($this->classMap[$class])) { return $this->classMap[$class]; } if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { return false; } if (null !== $this->apcuPrefix) { $file = apcu_fetch($this->apcuPrefix.$class, $hit); if ($hit) { return $file; } } $file = $this->findFileWithExtension($class, '.php'); // Search for Hack files if we are running on HHVM if (false === $file && defined('HHVM_VERSION')) { $file = $this->findFileWithExtension($class, '.hh'); } if (null !== $this->apcuPrefix) { apcu_add($this->apcuPrefix.$class, $file); } if (false === $file) { // Remember that this class does not exist. $this->missingClasses[$class] = true; } return $file; }
Finds the path to the file where the class is defined. @param string $class The name of the class @return string|false The path if found, false otherwise
findFile
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public static function getRegisteredLoaders() { return self::$registeredLoaders; }
Returns the currently registered loaders keyed by their corresponding vendor directories. @return array<string, self>
getRegisteredLoaders
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
private function findFileWithExtension($class, $ext) { // PSR-4 lookup $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; $first = $class[0]; if (isset($this->prefixLengthsPsr4[$first])) { $subPath = $class; while (false !== $lastPos = strrpos($subPath, '\\')) { $subPath = substr($subPath, 0, $lastPos); $search = $subPath . '\\'; if (isset($this->prefixDirsPsr4[$search])) { $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); foreach ($this->prefixDirsPsr4[$search] as $dir) { if (file_exists($file = $dir . $pathEnd)) { return $file; } } } } } // PSR-4 fallback dirs foreach ($this->fallbackDirsPsr4 as $dir) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { return $file; } } // PSR-0 lookup if (false !== $pos = strrpos($class, '\\')) { // namespaced class name $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); } else { // PEAR-like class name $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; } if (isset($this->prefixesPsr0[$first])) { foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { foreach ($dirs as $dir) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { return $file; } } } } } // PSR-0 fallback dirs foreach ($this->fallbackDirsPsr0 as $dir) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { return $file; } } // PSR-0 include paths. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { return $file; } return false; }
@param string $class @param string $ext @return string|false
findFileWithExtension
php
deptrac/deptrac
vendor/composer/ClassLoader.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/ClassLoader.php
MIT
public static function getInstalledPackages() { $packages = array(); foreach (self::getInstalled() as $installed) { $packages[] = \array_keys($installed['versions']); } if (1 === \count($packages)) { return $packages[0]; } return \array_keys(\array_flip(\call_user_func_array('DEPTRAC_INTERNAL\\array_merge', $packages))); }
Returns a list of all package names which are present, either by being installed, replaced or provided @return string[] @psalm-return list<string>
getInstalledPackages
php
deptrac/deptrac
vendor/composer/InstalledVersions.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
MIT
public static function getInstalledPackagesByType($type) { $packagesByType = array(); foreach (self::getInstalled() as $installed) { foreach ($installed['versions'] as $name => $package) { if (isset($package['type']) && $package['type'] === $type) { $packagesByType[] = $name; } } } return $packagesByType; }
Returns a list of all package names with a specific type e.g. 'library' @param string $type @return string[] @psalm-return list<string>
getInstalledPackagesByType
php
deptrac/deptrac
vendor/composer/InstalledVersions.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
MIT
public static function isInstalled($packageName, $includeDevRequirements = \true) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === \false; } } return \false; }
Checks whether the given package is installed This also returns true if the package name is provided or replaced by another package @param string $packageName @param bool $includeDevRequirements @return bool
isInstalled
php
deptrac/deptrac
vendor/composer/InstalledVersions.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
MIT
public static function satisfies(VersionParser $parser, $packageName, $constraint) { $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); }
Checks whether the given package satisfies a version constraint e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') @param VersionParser $parser Install composer/semver to have access to this class and functionality @param string $packageName @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package @return bool
satisfies
php
deptrac/deptrac
vendor/composer/InstalledVersions.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
MIT
public static function getVersionRanges($packageName) { foreach (self::getInstalled() as $installed) { if (!isset($installed['versions'][$packageName])) { continue; } $ranges = array(); if (isset($installed['versions'][$packageName]['pretty_version'])) { $ranges[] = $installed['versions'][$packageName]['pretty_version']; } if (\array_key_exists('aliases', $installed['versions'][$packageName])) { $ranges = \array_merge($ranges, $installed['versions'][$packageName]['aliases']); } if (\array_key_exists('replaced', $installed['versions'][$packageName])) { $ranges = \array_merge($ranges, $installed['versions'][$packageName]['replaced']); } if (\array_key_exists('provided', $installed['versions'][$packageName])) { $ranges = \array_merge($ranges, $installed['versions'][$packageName]['provided']); } return \implode(' || ', $ranges); } throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); }
Returns a version constraint representing all the range(s) which are installed for a given package It is easier to use this via isInstalled() with the $constraint argument if you need to check whether a given version of a package is installed, and not just whether it exists @param string $packageName @return string Version constraint usable with composer/semver
getVersionRanges
php
deptrac/deptrac
vendor/composer/InstalledVersions.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
MIT
public static function getVersion($packageName) { foreach (self::getInstalled() as $installed) { if (!isset($installed['versions'][$packageName])) { continue; } if (!isset($installed['versions'][$packageName]['version'])) { return null; } return $installed['versions'][$packageName]['version']; } throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); }
@param string $packageName @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
getVersion
php
deptrac/deptrac
vendor/composer/InstalledVersions.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
MIT
public static function getPrettyVersion($packageName) { foreach (self::getInstalled() as $installed) { if (!isset($installed['versions'][$packageName])) { continue; } if (!isset($installed['versions'][$packageName]['pretty_version'])) { return null; } return $installed['versions'][$packageName]['pretty_version']; } throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); }
@param string $packageName @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
getPrettyVersion
php
deptrac/deptrac
vendor/composer/InstalledVersions.php
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
MIT