This document describes the Architecture/ThinLayer* cop family.
Thin-layer cops protect entrypoint scripts (controllers/pages/ajax/templates) from accumulating business logic. The intent is:
- keep orchestration in thin layer,
- keep domain/business behavior in service/lib classes.
Architecture/ThinLayerBoundary is the source of truth for file scope:
TargetPathsBusinessLayerPathsExcludePaths
Other thin-layer cops inherit these keys by default.
If a child cop defines one of these keys explicitly, that value overrides inheritance for that key.
Enabled is also inherited from Architecture/ThinLayerBoundary unless explicitly set in a child cop section.
Anchor cop for shared thin-layer scope.
Does not report offenses directly.
Default severity: warning.
Key config:
Architecture/ThinLayerBoundary:
Enabled: false
TargetPaths: ["**/*.php"]
BusinessLayerPaths: []
ExcludePaths: ["vendor/**"]Checks branch-node complexity per file (if/elseif/for/foreach/while/do/switch/case/ternary).
Default severity: warning.
Key config:
Architecture/ThinLayerComplexity:
MaxBranchNodes: 6Checks direct function calls in thin layer against ForbiddenFunctions.
Default severity: warning.
Key config:
Architecture/ThinLayerForbiddenFunctions:
ForbiddenFunctions: ["mysql_query", "mysqli_query", "pg_query"]Checks total file size by line count.
Default severity: warning.
Key config:
Architecture/ThinLayerLength:
Max: 25
CountAsOne:
- array
- heredoc
- call_chainChecks direct use of configured PHP superglobals in thin-layer scripts.
Default severity: warning.
Key config:
Architecture/ThinLayerSuperglobalUsage:
ForbiddenSuperglobals:
- "_REQUEST"Checks direct object method calls in thin-layer scripts by configured regex patterns.
Default severity: warning.
Key config:
Architecture/ThinLayerForbiddenMethodCalls:
ForbiddenMethodPatterns:
- "^(query|exec|fetch|fetchall|fetchassoc|fetchrow)$"Checks global state usage in thin-layer scripts:
globalkeyword (configurable),- direct usage of configured globals (for example
$GLOBALS,$APPLICATION,$USER,$DB).
Default severity: warning.
Key config:
Architecture/ThinLayerGlobalStateUsage:
CheckGlobalKeyword: false
ForbiddenGlobals:
- "DB"Checks require/include usage in thin-layer scripts against AllowedIncludePatterns.
Default severity: warning.
Key config:
Architecture/ThinLayerIncludeUsage:
AllowedIncludePatterns:
- "/bitrix/modules/main/include/prolog_before.php"
- "/bitrix/modules/main/include/prolog_after.php"
- "/bitrix/header.php"
- "/bitrix/footer.php"
- "/local/php_interface/lib/"
- "/include/"Checks direct Class::method() usage in thin layer by:
ForbiddenStaticCallPrefixes(namespace/class prefix match),ForbiddenStaticClasses(exact class names).
Default severity: warning.
Key config:
Architecture/ThinLayerForbiddenStaticCalls:
ForbiddenStaticCallPrefixes:
- "bitrix\\sale\\"
- "bitrix\\iblock\\"
ForbiddenStaticClasses:
- "csaleorder"
- "ciblock"AllCops.Profile: bitrix (or --profile=bitrix) enables all thin-layer cops and fills thin-layer scope using detected Bitrix root.
Architecture/ThinLayerBoundary:
Enabled: true
TargetPaths: ["www_data/**"]
BusinessLayerPaths:
- "www_data/local/php_interface/lib/**"
- "www_data/local/php_interface/migrations/**"
ExcludePaths: ["vendor/**"]
Architecture/ThinLayerComplexity:
MaxBranchNodes: 6
Architecture/ThinLayerLength:
Max: 25
CountAsOne:
- array
- heredoc
- call_chain
Architecture/ThinLayerSuperglobalUsage:
ForbiddenSuperglobals:
- "_REQUEST"
Architecture/ThinLayerForbiddenMethodCalls:
ForbiddenMethodPatterns:
- "^(query|exec|fetch|fetchall|fetchassoc|fetchrow)$"
Architecture/ThinLayerGlobalStateUsage:
CheckGlobalKeyword: false
ForbiddenGlobals:
- "DB"
Architecture/ThinLayerIncludeUsage:
AllowedIncludePatterns:
- "/bitrix/modules/main/include/prolog_before.php"
- "/bitrix/modules/main/include/prolog_after.php"
- "/bitrix/header.php"
- "/bitrix/footer.php"
- "/local/php_interface/lib/"
- "/include/"
Architecture/ThinLayerForbiddenFunctions:
ForbiddenFunctions:
- "mysql_query"
- "mysqli_query"
- "pg_query"
Architecture/ThinLayerForbiddenStaticCalls:
ForbiddenStaticCallPrefixes:
- "bitrix\\sale\\"