update config files and inspection script

This commit is contained in:
Dennis Eichhorn 2022-12-25 00:03:54 +01:00
parent d9898111e0
commit c107b326a4
4 changed files with 43 additions and 165 deletions

View File

@ -20,16 +20,21 @@
<exclude-pattern>*/Web/*</exclude-pattern>
<exclude-pattern>*/omsSetup/*</exclude-pattern>
<exclude-pattern>*/demoSetup/*</exclude-pattern>
<exclude-pattern>*/privateSetup/*</exclude-pattern>
<exclude-pattern>*/Routes/*</exclude-pattern>
<exclude-pattern>*/Tools/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/OAuth2/*</exclude-pattern><!-- @todo: temporarily disabled-->
<exclude-pattern>*/Mail/*</exclude-pattern><!-- @todo: temporarily disabled-->
<exclude-pattern>*/Interfaces/*</exclude-pattern><!-- @todo: temporarily disabled-->
<exclude-pattern>*/Workflows/*</exclude-pattern><!-- @todo: temporarily disabled-->
<exclude-pattern>*/Accounting/*</exclude-pattern><!-- @todo: temporarily disabled-->
<exclude-pattern>*Hooks.php</exclude-pattern>
<exclude-pattern>*Markdown.js</exclude-pattern>
<exclude-pattern>*Markdown.php</exclude-pattern>
<exclude-pattern>*ObjLoader.js</exclude-pattern>
<exclude-pattern>config.php</exclude-pattern>
<exclude-pattern>*Routes.php</exclude-pattern>
<exclude-pattern>*SearchCommands.php</exclude-pattern>
<exclude-pattern>*Sha1.js</exclude-pattern>
@ -164,6 +169,7 @@
<exclude-pattern>*Pdf.php</exclude-pattern><!-- Just a wrapper -->
<exclude-pattern>*Excel.php</exclude-pattern><!-- Just a wrapper -->
<exclude-pattern>*/tests/*</exclude-pattern><!-- Tests don't always have side effects -->
<exclude-pattern>*/Interfaces/*</exclude-pattern><!-- Interfaces use require_once due to unknown upload locations and therefore no autoloading -->
</rule>
<rule ref="PSR2.Classes.ClassDeclaration"/>
<rule ref="PSR2.Classes.PropertyDeclaration"/>

View File

@ -1,151 +1,2 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$columns of method phpOMS\\\\DataStorage\\\\Database\\\\Query\\\\Builder\\:\\:where\\(\\) expects array\\|phpOMS\\\\DataStorage\\\\Database\\\\Query\\\\Where\\|string, string\\|null given\\.$#"
count: 1
path: *Modules/Admin/Models/GroupMapper.php
-
message: "#^Cannot access offset string on array\\<Modules\\\\Media\\\\Models\\\\Media\\>\\|Modules\\\\Media\\\\Models\\\\Media\\.$#"
count: 4
path: *Modules/Helper/Controller/ApiController.php
-
message: "#^Cannot access an offset on array\\<int, Modules\\\\Media\\\\Models\\\\Media\\>\\|Modules\\\\Media\\\\Models\\\\Media\\.$#"
count: 1
path: *Modules/Helper/Controller/BackendController.php
-
message: "#^Method Modules\\\\Workflow\\\\Templates\\\\Permission\\\\Workflow\\:\\:run\\(\\) has parameter \\$data with no typehint specified\\.$#"
count: 1
path: *Modules/Workflow/Templates/Permission/Workflow.php
-
message: "#^Method Modules\\\\Workflow\\\\Templates\\\\Permission\\\\Workflow\\:\\:runPending\\(\\) has parameter \\$data with no typehint specified\\.$#"
count: 1
path: *Modules/Workflow/Templates/Permission/Workflow.php
-
message: "#^Method Modules\\\\Workflow\\\\Templates\\\\Permission\\\\Workflow\\:\\:runRequest\\(\\) has parameter \\$data with no typehint specified\\.$#"
count: 1
path: *Modules/Workflow/Templates/Permission/Workflow.php
-
message: "#^Property Modules\\\\Workflow\\\\Templates\\\\Permission\\\\Workflow\\:\\:\\$id has no typehint specified\\.$#"
count: 1
path: *Modules/Workflow/Templates/Permission/Workflow.php
-
message: "#^Property Modules\\\\Workflow\\\\Templates\\\\Permission\\\\Workflow\\:\\:\\$state has no typehint specified\\.$#"
count: 1
path: *Modules/Workflow/Templates/Permission/Workflow.php
-
message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(mixed, mixed\\)\\: int, array\\('self', 'continuousComparator'\\) given\\.$#"
count: 1
path: *phpOMS/Algorithm/Knapsack/Continuous.php
-
message: "#^Constructor of class phpOMS\\\\Business\\\\Marketing\\\\ArticleCorrelationAffinity has an unused parameter \\$considerQuantity\\.$#"
count: 1
path: *phpOMS/Business/Marketing/ArticleCorrelationAffinity.php
-
message: "#^Parameter \\#1 \\$dbdata of class phpOMS\\\\DataStorage\\\\Database\\\\Connection\\\\MysqlConnection constructor expects array\\('db' \\=\\> string, 'host' \\=\\> string, 'port' \\=\\> int, 'login' \\=\\> string, 'password' \\=\\> string, 'database' \\=\\> string\\), array\\('db' \\=\\> string, \\?'host' \\=\\> string, \\?'port' \\=\\> int, \\?'login' \\=\\> string, \\?'password' \\=\\> string, 'database' \\=\\> string\\) given\\.$#"
count: 1
path: *phpOMS/DataStorage/Database/Connection/ConnectionFactory.php
-
message: "#^Parameter \\#1 \\$dbdata of class phpOMS\\\\DataStorage\\\\Database\\\\Connection\\\\PostgresConnection constructor expects array\\('db' \\=\\> string, 'host' \\=\\> string, 'port' \\=\\> int, 'login' \\=\\> string, 'password' \\=\\> string, 'database' \\=\\> string\\), array\\('db' \\=\\> string, \\?'host' \\=\\> string, \\?'port' \\=\\> int, \\?'login' \\=\\> string, \\?'password' \\=\\> string, 'database' \\=\\> string\\) given\\.$#"
count: 1
path: *phpOMS/DataStorage/Database/Connection/ConnectionFactory.php
-
message: "#^Parameter \\#1 \\$dbdata of class phpOMS\\\\DataStorage\\\\Database\\\\Connection\\\\SqlServerConnection constructor expects array\\('db' \\=\\> string, 'host' \\=\\> string, 'port' \\=\\> int, 'login' \\=\\> string, 'password' \\=\\> string, 'database' \\=\\> string\\), array\\('db' \\=\\> string, \\?'host' \\=\\> string, \\?'port' \\=\\> int, \\?'login' \\=\\> string, \\?'password' \\=\\> string, 'database' \\=\\> string\\) given\\.$#"
count: 1
path: *phpOMS/DataStorage/Database/Connection/ConnectionFactory.php
-
message: "#^Array \\(array\\<phpOMS\\\\DataStorage\\\\Database\\\\Connection\\\\ConnectionAbstract\\>\\) does not accept phpOMS\\\\DataStorage\\\\DataStorageConnectionInterface\\.$#"
count: 1
path: *phpOMS/DataStorage/Database/DatabasePool.php
-
message: "#^Call to an undefined method phpOMS\\\\DataStorage\\\\Database\\\\Query\\\\Column\\:\\:getColumn\\(\\)\\.$#"
count: 1
path: *phpOMS/DataStorage/Database/Query/Builder.php
-
message: "#^Parameter \\#2 \\$operator of method phpOMS\\\\DataStorage\\\\Database\\\\Query\\\\Builder\\:\\:on\\(\\) expects array\\|string, array\\|string\\|null given\\.$#"
count: 2
path: *phpOMS/DataStorage/Database/Query/Builder.php
-
message: "#^Parameter \\#2 \\$operator of method phpOMS\\\\DataStorage\\\\Database\\\\Query\\\\Builder\\:\\:where\\(\\) expects array\\|string, array\\|string\\|null given\\.$#"
count: 2
path: *phpOMS/DataStorage/Database/Query/Builder.php
-
message: "#^Parameter \\#3 \\$values of method phpOMS\\\\DataStorage\\\\Database\\\\Query\\\\Builder\\:\\:on\\(\\) expects array\\|string, array\\|string\\|null given\\.$#"
count: 2
path: *phpOMS/DataStorage/Database/Query/Builder.php
-
message: "#^Possibly invalid array key type phpOMS\\\\DataStorage\\\\Database\\\\Query\\\\Builder\\|string\\.$#"
count: 1
path: *phpOMS/DataStorage/Database/Query/Builder.php
-
message: "#^Method phpOMS\\\\Math\\\\Geometry\\\\ConvexHull\\\\MonotoneChain\\:\\:createConvexHull\\(\\) should return array\\<int, array\\('x' \\=\\> float\\|int, 'y' \\=\\> float\\|int\\)\\> but returns array\\<int\\|string, array\\('x' \\=\\> float\\|int, 'y' \\=\\> float\\|int\\)\\>\\.$#"
count: 1
path: *phpOMS/Math/Geometry/ConvexHull/MonotoneChain.php
-
message: "#^Parameter \\#3 \\$length of function array_slice expects int\\|null, float\\|int given\\.$#"
count: 1
path: *phpOMS/Math/Geometry/ConvexHull/MonotoneChain.php
-
message: "#^Parameter \\#1 \\$matrix of method phpOMS\\\\Math\\\\Matrix\\\\Matrix\\:\\:setMatrix\\(\\) expects array\\<int, array\\<float\\|int\\>\\>, array\\<int\\|string, array\\<int, \\(float\\|int\\)\\>\\> given\\.$#"
count: 1
path: *phpOMS/Math/Matrix/CholeskyDecomposition.php
-
message: "#^Binary operation \"\\-\" between string\\|null and int results in an error\\.$#"
count: 1
path: *phpOMS/Math/Matrix/Matrix.php
-
message: "#^Method phpOMS\\\\Math\\\\Matrix\\\\Matrix\\:\\:current\\(\\) should return int but returns float\\|int\\.$#"
count: 1
path: *phpOMS/Math/Matrix/Matrix.php
-
message: "#^Method phpOMS\\\\Math\\\\Matrix\\\\Matrix\\:\\:key\\(\\) should return string but returns int\\.$#"
count: 1
path: *phpOMS/Math/Matrix/Matrix.php
-
message: "#^Parameter \\#1 \\$offset of method phpOMS\\\\Math\\\\Matrix\\\\Matrix\\:\\:offsetExists\\(\\) expects string, int given\\.$#"
count: 1
path: *phpOMS/Math/Matrix/Matrix.php
-
message: "#^Call to an undefined method DirectoryIterator\\|RecursiveIteratorIterator\\<RecursiveDirectoryIterator\\>\\|RegexIterator\\:\\:getPathname\\(\\)\\.$#"
count: 1
path: *phpOMS/System/File/Local/Directory.php
-
message: "#^Parameter \\#2 \\$count of function array_fill expects int\\<0, max\\>, int given\\.$#"
count: 1
path: *phpOMS/Algorithm/Knapsack/Bounded.php
-
message: "#^Offset 'currency' does not exist on SimpleXMLElement\\|null\\.$#"
count: 1
path: *phpOMS/Utils/Converter/Currency.php
-
message: "#^Offset 'rate' does not exist on SimpleXMLElement\\|null\\.$#"
count: 1
path: *phpOMS/Utils/Converter/Currency.php

View File

@ -10,26 +10,26 @@ parameters:
treatPhpDocTypesAsCertain: false
excludePaths:
- *.tpl.php
- */tests/*
- */Modules/Media/Files/*
- */omsSetup/*
- */demoSetup/*
- */d0cbb361b14ac3ef32486f0a09ab937d/*
- */privateSetup/*
- */test/*
- */tests/*
- */Sandbox/*
- */Tools/*
- */Logs/*
- *Test.php
- *Routes.php
- *Hooks.php
- *ObjLoader.js
- */vendor/*
- *vendor*
- */Demo/*
- */Build/*
- */Cache/*
- */Docs/*
- */Documentation/*
- */Resources/*
- */Libraries/*
- */Web/*
- */Routes/*
- */Hooks/*
- */DataStorage/Database/*
@ -39,27 +39,31 @@ parameters:
- */Socket/*
- */node_modules/*
- */Modules/Shop/Admin/Install/Application/*
- */Install/Application*
- */Web/*
- */Modules/**/Application/*
- */Modules/Organization/Controller/BackendController.php
- *Model/CoreSettings.php
- */Accounting/*
ignoreErrors:
- '#[.]*tag @var for constant .* is not subtype of value array[.]*#'
- '#.*tag @var for constant.*#'
- '#[.]*Offset .* on array.* always exists[.]*#'
- '#[.]*separator of function explode expects non-empty-string[.]*#'
- '#[.]*PhpOffice\\PhpSpreadsheet\\[.]*#'
- '#^Call to an undefined method phpOMS\\Module\\ModuleAbstract::[.]*#'
- '#^Strict comparison using === between[.]*#'
- '#.*key\(\) should return.*#'
- '#.*current\(\) should return.*#'
- '#.*offsetExists\(\) expects.*#'
- '#[.]*jsonSerialize\(\) has no return typehint specified#'
- '#.*unserialize\(\) has parameter .* with no typehint specified#'
- '#expects phpOMS\\Algorithm\\PathFinding\\JumpPointNode\|null, phpOMS\\Algorithm\\PathFinding\\Node\|null given#'
- '#should return array<phpOMS\\Algorithm\\PathFinding\\Node> but returns array<int, phpOMS\\Algorithm\\PathFinding\\Node\|null#'
- '#^Offset .* does not exist on array.*#'
- '#.*unserialize\(\) has parameter .* with no typehint specified#'
- '#.*refClass with generic class ReflectionClass but does not specify its types.*#'
- '#.*class Mpdf\\.*#'
- '#.*PHPDoc tag @var for constant.*#'
- '#.*Cannot cast mixed to.*#'
- '#.*Instantiated class .*\\WorkflowInstance.*#'
- '#.*class Mpdf\\.*#'
- '#.*unknown class .*Stripe\\.*#'
- '#.*Instantiated class .*Stripe\\.*#'
- '#.*unknown class .*PhpOffice\\.*#'
- '#.*Instantiated class .*PhpOffice\\.*#'
- '#[.]*PhpOffice\\PhpSpreadsheet\\[.]*#'
-
message: '#.*has parameter \$con with no typehint specified#'
path: *Ftp/File.php
@ -74,4 +78,16 @@ parameters:
path: *Module/ModuleManager.php
-
message: '#.*continuousComparator\(\) is unused.*#'
path: *Algorithm/Knapsack/Continuous.php
path: *Algorithm/Knapsack/Continuous.php
-
message: '#.*Empty array passed to foreach.*#'
path: *Admin/Install/Workflows*
-
message: '#.*app is never read.*#'
path: *Admin/Install/Workflows*
-
message: '#.*unknown class Modules\\Workflow\\Controller\\WorkflowInstance.*#'
path: *Admin/Install/Workflows*
-
message: '#.*undefined method object::getId.*#'
path: *TableView.php*

View File

@ -5,13 +5,18 @@ BPATH=$(dirname "$SCRIPT")
# php/js strict checks
printf "\nStrict checks\n\n"
grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ${BPATH}/../../phpOMS ${BPATH}/../../Web ${BPATH}/../../Modules ${BPATH}/../../Model
grep -r -L "declare(strict_types=1);" --include=*.php --exclude-dir={*vendor*,*Files*,*privateSetup*,*demoSetup*} --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ${BPATH}/../../phpOMS ${BPATH}/../../Web ${BPATH}/../../Modules ${BPATH}/../../Model
# js uses on actions
printf "\nJs Action checks\n\n"
grep -rlni "onafterprint=\|onbeforeprint=\|onbeforeunload=\|onerror=\|onhaschange=\|onload=\|onmessage=\|onoffline=\|ononline=\|onpagehide=\|onpageshow=\|onpopstate=\|onredo=\|onresize=\|onstorage=\|onund=o\|onunload=\|onblur=\|onchage=\|oncontextmenu=\|onfocus=\|onformchange=\|onforminput=\|oninput=\|oninvalid=\|onreset=\|onselect=\|onsubmit=\|onkeydown=\|onkeypress=\|onkeyup=\|onclick=\|ondblclic=k\|ondrag=\|ondragend=\|ondragenter=\|ondragleave=\|ondragover=\|ondragstart=\|ondrop=\|onmousedown=\|onmousemove=\|onmouseout=\|onmouseover=\|onmouseup=\|onmousewheel=\|onscroll=\|onabor=t\|oncanplay=\|oncanplaythrough=\|ondurationchange=\|onemptied=\|onended=\|onerror=\|onloadeddata=\|onloadedmetadata=\|onloadstart=\|onpause=\|onplay=\|onplaying=\|onprogress=\|onratechange=\|onreadystatechange=\|onseeked=\|onseeking=\|onstalled=\|onsuspend=\|ontimeupdate=\|onvolumechange=" --include=*.js ${BPATH}/../../jsOMS ${BPATH}/../../Model ${BPATH}/../../Modules ${BPATH}/../../Web
# php cs + phpstan + eslint
printf "\nPHPCS checks\n\n"
./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml"
printf "\nPHPStan checks\n\n"
./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 8 -c Build/Config/phpstan.neon ./
printf "\nESlint checks\n\n"
npx eslint jsOMS/ -c Build/Config/.eslintrc.json