From 589313f4ad431b40cde57311c4bd4a81d55b3390 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 17 Apr 2023 10:40:25 +0200 Subject: [PATCH] fix modules inter-dependencies on phpstan --- src/module/phpstan.php | 17 +++++++++++++++++ src/module/phpstan/phpstan.rules.conf | 1 + src/module/phpstan/phpstan.rules.full.conf | 4 +--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/module/phpstan.php b/src/module/phpstan.php index 9a5012a..9b2bc62 100644 --- a/src/module/phpstan.php +++ b/src/module/phpstan.php @@ -282,12 +282,14 @@ class phpstan extends Action '%MODULE_ROOT%', '%DC_ROOT%', '%BOOTSTRAP_ROOT%', + '%SCAN_DIRECTORIES%' ], [ $this->run_level, (string) Path::real($this->module->get('root'), false), (string) Path::real(DC_ROOT, false), (string) Path::real(__DIR__ . '/phpstan', false), + $this->getScanDirectories(), ], (string) file_get_contents(__DIR__ . '/phpstan/phpstan.rules.' . $full . 'conf') ); @@ -306,4 +308,19 @@ class phpstan extends Action return (bool) file_put_contents(DC_VAR . '/phpstan.neon', $content); } + + private function getScanDirectories() + { + $ret = ''; + if ($this->module->get('type') == 'plugin') { + $paths = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT); + foreach($paths as $path) { + $path = Path::real($path, false); + if ($path !== false && $path != Path::real(DC_ROOT . DIRECTORY_SEPARATOR . 'plugins', false)) { + $ret .= ' - ' . $path . "\n"; + } + } + } + return $ret; + } } diff --git a/src/module/phpstan/phpstan.rules.conf b/src/module/phpstan/phpstan.rules.conf index 05e771c..346fbf7 100644 --- a/src/module/phpstan/phpstan.rules.conf +++ b/src/module/phpstan/phpstan.rules.conf @@ -9,6 +9,7 @@ parameters: scanDirectories: - %DC_ROOT% +%SCAN_DIRECTORIES% excludePaths: - %MODULE_ROOT%/*/libs/* diff --git a/src/module/phpstan/phpstan.rules.full.conf b/src/module/phpstan/phpstan.rules.full.conf index 20906f1..5d395cb 100644 --- a/src/module/phpstan/phpstan.rules.full.conf +++ b/src/module/phpstan/phpstan.rules.full.conf @@ -9,6 +9,7 @@ parameters: scanDirectories: - %DC_ROOT% +%SCAN_DIRECTORIES% excludePaths: - %MODULE_ROOT%/*/libs/* @@ -120,9 +121,6 @@ parameters: # dbStruct object and auto properties - message : '#Access to an undefined property dbStruct::#' - # fileItem object and auto properties - - message : '#Access to an undefined property fileItem::#' - # cursor object and auto properties - message : '#Access to an undefined property cursor::#'