aboutsummaryrefslogtreecommitdiffstats
path: root/.phpcs.xml
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-06-12 23:53:20 +0200
committerHarald Eilertsen <haraldei@anduin.net>2024-06-12 23:53:20 +0200
commit9199a1ba81b6ed2c6dcbc1f842eb31b5f2c7d919 (patch)
tree265ca47c9f2fda448b89f6dca9584017257d1ba7 /.phpcs.xml
parent9d56bb952e162dddd24d3bcdc50b2957ef0e0b97 (diff)
downloadvolse-hubzilla-9199a1ba81b6ed2c6dcbc1f842eb31b5f2c7d919.tar.gz
volse-hubzilla-9199a1ba81b6ed2c6dcbc1f842eb31b5f2c7d919.tar.bz2
volse-hubzilla-9199a1ba81b6ed2c6dcbc1f842eb31b5f2c7d919.zip
Add config file and rules for PHP Code Sniffer.
The rules are based on the "Generic" ruleset included by PHP Code Sniffer, with a significant portion of the rules disabled. This is a tradeoff between getting some useful feedback, and not being overloaded by noise. I've tried to encode a coe style that resembles the existing code as much as possible, but have included some sniffs that requires code changes to satisfy the style. This is meant as a starting point, and we can disable or enable more sniffs as we see fit. PHPCS also has ready rule sets for other common coding standards we may want to gravitate towards, e.g. PSR-12. Others are available from the community. The best way to run PHPCS is to integrate it with your editor, so that it will display diacnostics inline when saving or modifying the code. It can also be run from the command line like this: ./vendor/bin/phpcs -n [<path-to-file-to-check>] If no file is specified it will try to check the entire project. The `-n` means don't bother with warnings (I recommend that to begin with. Enable the warnings when the errors are taken care of.)
Diffstat (limited to '.phpcs.xml')
-rw-r--r--.phpcs.xml78
1 files changed, 78 insertions, 0 deletions
diff --git a/.phpcs.xml b/.phpcs.xml
new file mode 100644
index 000000000..0054e4cda
--- /dev/null
+++ b/.phpcs.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<ruleset
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ name="PHP_CodeSniffer"
+ xsi:noNamespaceSchemaLocation="phpcs.xsd"
+ >
+
+ <description>PHP CodeSniffer config for Hubzilla</description>
+
+ <file>app</file>
+ <file>boot.php</file>
+ <file>include</file>
+ <file>index.php</file>
+ <file>install</file>
+ <file>library</file>
+ <file>tests</file>
+ <file>util</file>
+ <file>view</file>
+ <file>Zotlabs</file>
+
+ <rule ref="Generic">
+ <exclude name="Generic.Arrays.ArrayIndent"/>
+ <exclude name="Generic.Arrays.DisallowLongArraySyntax"/>
+ <exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
+ <exclude name="Generic.Files.EndFileNoNewline"/>
+ <exclude name="Generic.Files.LowercasedFilename"/>
+ <exclude name="Generic.Formatting.MultipleStatementAlignment"/>
+ <exclude name="Generic.Formatting.SpaceAfterNot"/>
+ <exclude name="Generic.Functions.FunctionCallArgumentSpacing"/>
+ <exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
+ <exclude name="Generic.NamingConventions.CamelCapsFunctionName"/>
+ <exclude name="Generic.PHP.ClosingPHPTag"/>
+ <exclude name="Generic.PHP.RequireStrictTypes"/>
+ <exclude name="Generic.PHP.UpperCaseConstant"/>
+ <exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
+ <exclude name="Generic.WhiteSpace.ScopeIndent"/>
+ <exclude name="Generic.Commenting.DocComment.ContentAfterOpen"/>
+ <exclude name="Generic.Commenting.DocComment.ContentBeforeClose"/>
+ <exclude name="Generic.Commenting.DocComment.LongNotCapital"/>
+ <exclude name="Generic.Commenting.DocComment.MissingShort"/>
+ <exclude name="Generic.Commenting.DocComment.NonParamGroup"/>
+ <exclude name="Generic.Commenting.DocComment.ParamNotFirst"/>
+ <exclude name="Generic.Commenting.DocComment.ShortNotCapital"/>
+ <exclude name="Generic.Commenting.DocComment.SpacingAfter"/>
+ <exclude name="Generic.Commenting.DocComment.SpacingBeforeShort"/>
+ <exclude name="Generic.Commenting.DocComment.TagValueIndent"/>
+ <exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed"/>
+ <exclude name="Generic.Files.OneClassPerFile.MultipleFound"/>
+ <exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound"/>
+ <exclude name="Generic.Formatting.SpaceAfterCast.NoSpace"/>
+ </rule>
+
+ <!--
+ Warn about lines longer than 100 columns, lines longer than 150
+ columns will flag an error.
+ -->
+ <rule ref="Generic.Files.LineLength">
+ <properties>
+ <property name="lineLimit" value="100" />
+ <property name="absoluteLineLimit" value="150" />
+ </properties>
+ </rule>
+
+ <!--
+ Mark deprecated functions.
+ -->
+ <rule ref="Generic.PHP.DeprecatedFunctions">
+ <properties>
+ <property name="forbiddenFunctions" type="array" extend="true">
+ <element key="load_config" value="Zotlabs\Lib\Config::Load" />
+ <element key="get_config" value="Zotlabs\Lib\Config::Get" />
+ <element key="set_config" value="Zotlabs\Lib\Config::Set" />
+ <element key="del_config" value="Zotlabs\Lib\Config::Delete" />
+ </property>
+ </properties>
+ </rule>
+
+</ruleset>