2018-02-04 18:34:08 +01:00
|
|
|
<?php
|
2018-11-12 16:46:55 +01:00
|
|
|
namespace Psalm\Internal\Codebase;
|
2018-02-04 18:34:08 +01:00
|
|
|
|
2019-06-26 22:52:29 +02:00
|
|
|
use function strtolower;
|
|
|
|
|
2018-12-02 00:37:49 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2018-02-04 18:34:08 +01:00
|
|
|
class PropertyMap
|
|
|
|
{
|
|
|
|
/**
|
2020-12-29 12:42:12 +01:00
|
|
|
* @var array<lowercase-string, array<string, string>>|null
|
2018-02-04 18:34:08 +01:00
|
|
|
*/
|
|
|
|
private static $property_map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the method/function call map
|
|
|
|
*
|
2020-12-29 12:42:12 +01:00
|
|
|
* @return array<lowercase-string, array<string, string>>
|
2018-02-04 18:34:08 +01:00
|
|
|
*/
|
2020-09-04 22:26:33 +02:00
|
|
|
public static function getPropertyMap(): array
|
2018-02-04 18:34:08 +01:00
|
|
|
{
|
|
|
|
if (self::$property_map !== null) {
|
|
|
|
return self::$property_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @var array<string, array<string, string>> */
|
2020-10-12 06:59:19 +02:00
|
|
|
$property_map = require(\dirname(__DIR__, 4) . '/dictionaries/PropertyMap.php');
|
2018-02-04 18:34:08 +01:00
|
|
|
|
|
|
|
self::$property_map = [];
|
|
|
|
|
|
|
|
foreach ($property_map as $key => $value) {
|
|
|
|
$cased_key = strtolower($key);
|
|
|
|
self::$property_map[$cased_key] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::$property_map;
|
|
|
|
}
|
|
|
|
|
2020-09-07 01:36:47 +02:00
|
|
|
public static function inPropertyMap(string $class_name): bool
|
2018-02-04 18:34:08 +01:00
|
|
|
{
|
|
|
|
return isset(self::getPropertyMap()[strtolower($class_name)]);
|
|
|
|
}
|
|
|
|
}
|