{"record":{"id":"9f168f8c9ffb1b16","repo":"rectorphp/rector","slug":"matching-file-paths-by-using-glob-patterns-is-no-l","errorCode":null,"errorMessage":"Matching file paths by using glob-patterns is no longer supported. Use specific file path instead.","messagePattern":"Matching file paths by using glob-patterns is no longer supported\\. Use specific file path instead\\.","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"src/Config/RectorConfig.php","lineNumber":239,"sourceCode":"            $this->import($configFile);\n        }\n    }\n    /**\n     * @param class-string<Command> $commandClass\n     */\n    public function command(string $commandClass): void\n    {\n        $this->singleton($commandClass);\n        $this->tag($commandClass, Command::class);\n    }\n    public function import(string $filePath): void\n    {\n        /**\n         * Only stop when filePath realpath is false and contains glob patterns\n         * @see https://github.com/rectorphp/rector/issues/9156#issuecomment-2869130541\n         */\n        if (realpath($filePath) === \\false && strpos($filePath, '*') !== \\false) {\n            throw new ShouldNotHappenException('Matching file paths by using glob-patterns is no longer supported. Use specific file path instead.');\n        }\n        Assert::fileExists($filePath);\n        $self = $this;\n        $callable = require $filePath;\n        Assert::isCallable($callable);\n        /** @var callable(Container $container): void $callable */\n        $callable($self);\n    }\n    /**\n     * @param array<class-string<RectorInterface>> $rectorClasses\n     */\n    public function rules(array $rectorClasses): void\n    {\n        Assert::allString($rectorClasses);\n        RectorConfigValidator::ensureNoDuplicatedClasses($rectorClasses);\n        foreach ($rectorClasses as $rectorClass) {\n            $this->rule($rectorClass);\n        }","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/src/Config/RectorConfig.php#L221-L257","documentation":"RectorConfig::import() loads another config file and executes its returned closure; glob/wildcard imports were removed, so it rejects any path that both fails realpath() and contains '*' with ShouldNotHappenException (see upstream issue #9156). The message tells you to import concrete files instead. Every other file type still works -- only wildcard patterns are refused.","triggerScenarios":"Writing ->import(__DIR__ . '/config/*.php') or ->import(__DIR__ . '/sets/*.php') inside rector.php so multiple sub-configs can be pulled in at once.","commonSituations":"Configs migrated from other tools (PHPStan/ ECS) or older conventions that allowed glob imports; monorepos trying to auto-discover per-package rule files.","solutions":["Import each file explicitly: ->import(__DIR__ . '/config/early.php')","Or expand the glob yourself and import every existing file (see example)","Prefer native builder composition: put shared rules in a class or use ->withSets()/->import() on concrete files"],"exampleFix":"// before\nreturn RectorConfig::configure()\n    ->import(__DIR__ . '/config/*.php');\n\n// after\n$rectorConfig = RectorConfig::configure();\nforeach (glob(__DIR__ . '/config/*.php') as $configFile) {\n    $rectorConfig->import($configFile);\n}","handlingStrategy":"validation","validationCode":"// expand globs yourself so only concrete files reach import()\n$configFiles = glob(__DIR__ . '/config/*.php') ?: [];\nforeach ($configFiles as $configFile) {\n    if (! is_file($configFile)) {\n        throw new InvalidArgumentException('Config file vanished: ' . $configFile);\n    }\n    $rectorConfig->import($configFile);\n}","typeGuard":"function isImportableConfigFile(string $path): bool\n{\n    return strpos($path, '*') === false && is_file($path);\n}","tryCatchPattern":null,"preventionTips":["Never put '*' in paths passed to ->import(); Rector rejects them by design","List sub-configs explicitly for discoverability, or loop over glob() results yourself","Remember only wildcard paths are rejected -- plain missing files still fail with Assert::fileExists()"],"tags":["php","rector","config","import","glob","wildcard"],"backgroundTag":"glob-import-unsupported","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}