From 9147226c48726207c2343cbd13226637658fc4cd Mon Sep 17 00:00:00 2001 From: "maho-organization-controller[bot]" <289500297+maho-organization-controller[bot]@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:53:59 +0000 Subject: [PATCH] chore: sync .rector.php from infrastructure --- .rector.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.rector.php b/.rector.php index 9ad63e1..345ae86 100644 --- a/.rector.php +++ b/.rector.php @@ -14,6 +14,22 @@ // Maho\Rector\* rules and the Varien->Maho migration) stays in maho and is not // synced. Only the paths that exist in a given repo are scanned, so the one // config works for app-only modules and the infra tool's src/ alike. +// +// Existence alone is not enough: in a module repo `composer install` lets the +// maho composer plugin generate public/ and lib/ from maho core, and those are +// git-ignored. Rector must not lint core files a module cannot change, so a +// directory is only scanned when git does not ignore it. +function isGitIgnored(string $path): bool +{ + exec( + 'git -C ' . escapeshellarg(__DIR__) . ' check-ignore -q ' . escapeshellarg($path) . ' 2>/dev/null', + $output, + $exitCode, + ); + + return $exitCode === 0; +} + return RectorConfig::configure() ->withPaths(array_values(array_merge( array_filter([ @@ -21,7 +37,7 @@ __DIR__ . '/lib', __DIR__ . '/public', __DIR__ . '/src', - ], 'is_dir'), + ], static fn(string $dir): bool => is_dir($dir) && !isGitIgnored($dir)), // Root-level entry points (e.g. the infra tool's sync.php / config.php). // glob skips dotfiles, so this very config file isn't included. glob(__DIR__ . '/*.php') ?: [],