mirror of
https://github.com/danog/psalm.git
synced 2024-12-15 19:07:00 +01:00
56 lines
2.1 KiB
PHP
56 lines
2.1 KiB
PHP
|
<?php
|
||
|
namespace Psalm\Internal\Codebase;
|
||
|
|
||
|
class ReferenceMapGenerator
|
||
|
{
|
||
|
public static function getReferenceMap(
|
||
|
\Psalm\Internal\Provider\ClassLikeStorageProvider $classlike_storage_provider,
|
||
|
array $expected_references
|
||
|
) : array {
|
||
|
$reference_dictionary = [];
|
||
|
|
||
|
foreach ($classlike_storage_provider->getAll() as $storage) {
|
||
|
if (!$storage->location) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$fq_classlike_name = $storage->name;
|
||
|
|
||
|
if (isset($expected_references[$fq_classlike_name])) {
|
||
|
$reference_dictionary[$fq_classlike_name]
|
||
|
= $storage->location->file_name
|
||
|
. ':' . $storage->location->getLineNumber()
|
||
|
. ':' . $storage->location->getColumn();
|
||
|
}
|
||
|
|
||
|
foreach ($storage->methods as $method_name => $method_storage) {
|
||
|
if (!$method_storage->location) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (isset($expected_references[$fq_classlike_name . '::' . $method_name . '()'])) {
|
||
|
$reference_dictionary[$fq_classlike_name . '::' . $method_name . '()']
|
||
|
= $method_storage->location->file_name
|
||
|
. ':' . $method_storage->location->getLineNumber()
|
||
|
. ':' . $method_storage->location->getColumn();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
foreach ($storage->properties as $property_name => $property_storage) {
|
||
|
if (!$property_storage->location) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (isset($expected_references[$fq_classlike_name . '::$' . $property_name])) {
|
||
|
$reference_dictionary[$fq_classlike_name . '::$' . $property_name]
|
||
|
= $property_storage->location->file_name
|
||
|
. ':' . $property_storage->location->getLineNumber()
|
||
|
. ':' . $property_storage->location->getColumn();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return $reference_dictionary;
|
||
|
}
|
||
|
}
|