diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 23b8f00..e7e6b95 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -80,8 +80,7 @@ intval=>null, strval=>null, settype=>null, - exit=>null, - reset=>array_key_first + exit=>null " /> diff --git a/src/Provider/SymfonyUsageProvider.php b/src/Provider/SymfonyUsageProvider.php index 73e1420..74f2980 100644 --- a/src/Provider/SymfonyUsageProvider.php +++ b/src/Provider/SymfonyUsageProvider.php @@ -28,15 +28,18 @@ use SimpleXMLElement; use SplFileInfo; use UnexpectedValueException; -use function array_key_first; +use function array_filter; +use function array_keys; use function count; use function explode; use function file_get_contents; use function in_array; use function is_dir; use function preg_match_all; +use function reset; use function simplexml_load_string; use function sprintf; +use function strpos; use const PHP_VERSION_ID; class SymfonyUsageProvider implements MemberUsageProvider @@ -405,16 +408,19 @@ private function createUsage(ExtendedMethodReflection $methodReflection): ClassM private function autodetectConfigDir(): ?string { - $classLoaders = ClassLoader::getRegisteredLoaders(); + $vendorDirs = array_filter(array_keys(ClassLoader::getRegisteredLoaders()), static function (string $vendorDir): bool { + return strpos($vendorDir, 'phar://') === false; + }); - if (count($classLoaders) !== 1) { + if (count($vendorDirs) !== 1) { return null; } - $vendorDir = array_key_first($classLoaders); + $vendorDir = reset($vendorDirs); + $configDir = $vendorDir . '/../config'; - if (is_dir($vendorDir . '/../config')) { - return $vendorDir . '/config'; + if (is_dir($configDir)) { + return $configDir; } return null;