diff --git a/box.json.dist b/box.json.dist index 984adfa52..79d859ac5 100644 --- a/box.json.dist +++ b/box.json.dist @@ -9,8 +9,8 @@ "src/psalm-refactor.php" ], "files-bin": ["config.xsd"], - "directories-bin" : ["assets"], + "directories-bin" : ["assets", "dictionaries", "stubs"], "compactors" : [ "KevinGH\\Box\\Compactor\\PhpScoper" ] -} \ No newline at end of file +} diff --git a/src/Psalm/Internal/CallMap.php b/dictionaries/CallMap.php similarity index 100% rename from src/Psalm/Internal/CallMap.php rename to dictionaries/CallMap.php diff --git a/src/Psalm/Internal/CallMap_71_delta.php b/dictionaries/CallMap_71_delta.php similarity index 100% rename from src/Psalm/Internal/CallMap_71_delta.php rename to dictionaries/CallMap_71_delta.php diff --git a/src/Psalm/Internal/CallMap_72_delta.php b/dictionaries/CallMap_72_delta.php similarity index 100% rename from src/Psalm/Internal/CallMap_72_delta.php rename to dictionaries/CallMap_72_delta.php diff --git a/src/Psalm/Internal/CallMap_73_delta.php b/dictionaries/CallMap_73_delta.php similarity index 100% rename from src/Psalm/Internal/CallMap_73_delta.php rename to dictionaries/CallMap_73_delta.php diff --git a/src/Psalm/Internal/CallMap_74_delta.php b/dictionaries/CallMap_74_delta.php similarity index 100% rename from src/Psalm/Internal/CallMap_74_delta.php rename to dictionaries/CallMap_74_delta.php diff --git a/src/Psalm/Internal/InternalTaintSinkMap.php b/dictionaries/InternalTaintSinkMap.php similarity index 100% rename from src/Psalm/Internal/InternalTaintSinkMap.php rename to dictionaries/InternalTaintSinkMap.php diff --git a/src/Psalm/Internal/PropertyMap.php b/dictionaries/PropertyMap.php similarity index 100% rename from src/Psalm/Internal/PropertyMap.php rename to dictionaries/PropertyMap.php diff --git a/psalm.xml.dist b/psalm.xml.dist index 5f027df19..d83a45adb 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -20,13 +20,10 @@ - - - diff --git a/scoper.inc.php b/scoper.inc.php index ed1d45f91..a125df6f2 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -83,10 +83,6 @@ return [ 'Psalm\*', ], 'files-whitelist' => [ - 'src/Psalm/Internal/PropertyMap.php', - 'src/Psalm/Internal/CallMap.php', - 'src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub', - 'src/Psalm/Internal/Stubs/CoreGenericClasses.phpstub', 'src/spl_object_id.php', ], ]; diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index 62e85011f..b07756da5 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -1671,21 +1671,21 @@ class Config $codebase->register_stub_files = true; // note: don't realpath $generic_stubs_path, or phar version will fail - $generic_stubs_path = __DIR__ . '/Internal/Stubs/CoreGenericFunctions.phpstub'; + $generic_stubs_path = dirname(__DIR__, 2) . '/stubs/CoreGenericFunctions.phpstub'; if (!file_exists($generic_stubs_path)) { throw new \UnexpectedValueException('Cannot locate core generic stubs'); } // note: don't realpath $generic_classes_path, or phar version will fail - $generic_classes_path = __DIR__ . '/Internal/Stubs/CoreGenericClasses.phpstub'; + $generic_classes_path = dirname(__DIR__, 2) . '/stubs/CoreGenericClasses.phpstub'; if (!file_exists($generic_classes_path)) { throw new \UnexpectedValueException('Cannot locate core generic classes'); } // note: don't realpath $generic_classes_path, or phar version will fail - $immutable_classes_path = __DIR__ . '/Internal/Stubs/CoreImmutableClasses.phpstub'; + $immutable_classes_path = dirname(__DIR__, 2) . '/stubs/CoreImmutableClasses.phpstub'; if (!file_exists($immutable_classes_path)) { throw new \UnexpectedValueException('Cannot locate core immutable classes'); @@ -1694,7 +1694,7 @@ class Config $core_generic_files = [$generic_stubs_path, $generic_classes_path, $immutable_classes_path]; if (\extension_loaded('ds')) { - $ext_ds_path = __DIR__ . '/Internal/Stubs/ext-ds.php'; + $ext_ds_path = dirname(__DIR__, 2) . '/stubs/ext-ds.php'; if (!file_exists($ext_ds_path)) { throw new \UnexpectedValueException('Cannot locate core generic classes'); @@ -1722,7 +1722,7 @@ class Config } if ($this->load_xdebug_stub) { - $xdebug_stub_path = __DIR__ . '/Internal/Stubs/Xdebug.php'; + $xdebug_stub_path = dirname(__DIR__, 2) . '/stubs/Xdebug.php'; if (!file_exists($xdebug_stub_path)) { throw new \UnexpectedValueException('Cannot locate XDebug stub'); diff --git a/src/Psalm/Internal/Codebase/InternalCallMapHandler.php b/src/Psalm/Internal/Codebase/InternalCallMapHandler.php index 168954eaf..82bc427d7 100644 --- a/src/Psalm/Internal/Codebase/InternalCallMapHandler.php +++ b/src/Psalm/Internal/Codebase/InternalCallMapHandler.php @@ -12,6 +12,7 @@ use Psalm\Internal\Type\Comparator\UnionTypeComparator; use Psalm\Storage\FunctionLikeParameter; use Psalm\Type; use Psalm\Type\Atomic\TCallable; +use function dirname; use function strtolower; use function substr; use function version_compare; @@ -354,7 +355,7 @@ class InternalCallMapHandler } /** @var array> */ - $call_map = require(__DIR__ . '/../CallMap.php'); + $call_map = require(dirname(__DIR__, 4) . '/dictionaries/CallMap.php'); self::$call_map = []; @@ -366,7 +367,7 @@ class InternalCallMapHandler /** * @var array>> */ - $taint_map = require(__DIR__ . '/../InternalTaintSinkMap.php'); + $taint_map = require(dirname(__DIR__, 4) . '/dictionaries/InternalTaintSinkMap.php'); foreach ($taint_map as $key => $value) { $cased_key = strtolower($key); @@ -376,7 +377,7 @@ class InternalCallMapHandler if (version_compare($analyzer_version, $current_version, '<')) { // the following assumes both minor and major versions a single digits for ($i = $current_version_int; $i > $analyzer_version_int && $i >= self::LOWEST_AVAILABLE_DELTA; --$i) { - $delta_file = __DIR__ . '/../CallMap_' . $i . '_delta.php'; + $delta_file = dirname(__DIR__, 4) . '/dictionaries/CallMap_' . $i . '_delta.php'; if (!file_exists($delta_file)) { continue; } diff --git a/src/Psalm/Internal/Codebase/PropertyMap.php b/src/Psalm/Internal/Codebase/PropertyMap.php index cc15e7776..64644dab7 100644 --- a/src/Psalm/Internal/Codebase/PropertyMap.php +++ b/src/Psalm/Internal/Codebase/PropertyMap.php @@ -25,7 +25,7 @@ class PropertyMap } /** @var array> */ - $property_map = require(__DIR__ . '/../PropertyMap.php'); + $property_map = require(\dirname(__DIR__, 4) . '/dictionaries/PropertyMap.php'); self::$property_map = []; diff --git a/src/Psalm/Internal/Stubs/CoreGenericClasses.phpstub b/stubs/CoreGenericClasses.phpstub similarity index 100% rename from src/Psalm/Internal/Stubs/CoreGenericClasses.phpstub rename to stubs/CoreGenericClasses.phpstub diff --git a/src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub similarity index 100% rename from src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub rename to stubs/CoreGenericFunctions.phpstub diff --git a/src/Psalm/Internal/Stubs/CoreImmutableClasses.phpstub b/stubs/CoreImmutableClasses.phpstub similarity index 100% rename from src/Psalm/Internal/Stubs/CoreImmutableClasses.phpstub rename to stubs/CoreImmutableClasses.phpstub diff --git a/src/Psalm/Internal/Stubs/Xdebug.php b/stubs/Xdebug.php similarity index 100% rename from src/Psalm/Internal/Stubs/Xdebug.php rename to stubs/Xdebug.php diff --git a/src/Psalm/Internal/Stubs/ext-ds.php b/stubs/ext-ds.php similarity index 100% rename from src/Psalm/Internal/Stubs/ext-ds.php rename to stubs/ext-ds.php