From 736c26f1ec5d08ef16eb7aaeb9d29939ee07de48 Mon Sep 17 00:00:00 2001 From: Koala Yeung Date: Wed, 29 Sep 2021 09:31:16 +0800 Subject: [PATCH] Test: phpstan to use config file (#1448) * Test: phpstan to use config file * Use phpstan.neon to config the behaviour instead of using the CLI arguments. Much cleaner and more readable. * Define how to format a .neon file in .editorconfig to ensure consistancy. * Test: .htaccess to forbid access to .neon files --- .editorconfig | 4 ++++ .htaccess | 4 ++-- composer.json | 2 +- phpstan.neon | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 phpstan.neon diff --git a/.editorconfig b/.editorconfig index 103c3478de..499c398147 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,7 @@ indent_size = 4 [*.yml] indent_size = 2 + +[*.neon] +indent_style = tab +indent_size = 4 diff --git a/.htaccess b/.htaccess index f5db2be3a8..4d40d6be8a 100644 --- a/.htaccess +++ b/.htaccess @@ -1,4 +1,4 @@ - + Order Allow,Deny Deny from all - \ No newline at end of file + diff --git a/composer.json b/composer.json index f09841a1f6..9ba7ca3c39 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "cd tests && ../vendor/bin/phpunit --verbose --colors=always --configuration phpunit.xml" ], "test:phpstan": [ - "vendor/bin/phpstan analyse --ansi --no-progress --no-interaction --autoload-file=functions.php src" + "vendor/bin/phpstan analyse --ansi --no-progress --no-interaction -c phpstan.neon" ], "test:codesniffer": [ "vendor/bin/phpcs --standard=PSR2 modules/Library/" diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000000..a2677928dd --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,32 @@ +parameters: + level: 0 + paths: + - src + ignoreErrors: + - '#Unsafe usage of new static\(\)#' + scanFiles: + - functions.php + - modules/Activities/moduleFunctions.php + - modules/Attendance/moduleFunctions.php + - modules/Behaviour/moduleFunctions.php + - modules/Crowd Assessment/moduleFunctions.php + - modules/Data Updater/moduleFunctions.php + - modules/Departments/moduleFunctions.php + - modules/Finance/moduleFunctions.php + - modules/Form Groups/moduleFunctions.php + - modules/Formal Assessment/moduleFunctions.php + - modules/Individual Needs/moduleFunctions.php + - modules/Library/moduleFunctions.php + - modules/Markbook/moduleFunctions.php + - modules/Messenger/moduleFunctions.php + - modules/Planner/moduleFunctions.php + - modules/Reports/moduleFunctions.php + - modules/Rubrics/moduleFunctions.php + - modules/School Admin/moduleFunctions.php + - modules/Staff/moduleFunctions.php + - modules/Students/moduleFunctions.php + - modules/System Admin/moduleFunctions.php + - modules/Timetable Admin/moduleFunctions.php + - modules/Timetable/moduleFunctions.php + - modules/Tracking/moduleFunctions.php + - modules/User Admin/moduleFunctions.php