View Issue Details

IDProjectCategoryView StatusLast Update
0003681Composrcorepublic2019-08-12 17:23
ReporterSalmanAssigned To 
Status non-assignedResolutionopen 
Product Version 
Fixed in Version 
Summary0003681: Run the PHP codebase through PHP_CodeSniffer beautifier
DescriptionRunning the beautifier breaks easy merging so we need to take that into consideration. Sometimes reformatted spacing can make code harder to follow but we can fine tune the Code Sniffer config file to deal with that I think.

Attached is the rule set config file following coding standards agreed at

PHPStorm can be configured to use the rule set or a report can be generated by installing Code Sniffer using Composer `composer global require "squizlabs/php_codesniffer=*"` and running `phpcs --standard=phpcs.xml --parallel=1024`.

Beautifier is `phpcbf --standard=phpcs.xml --parallel=1024`.
TagsRoadmap: v11, Type: Standards compliance
Attach Tags
Time estimation (hours)7
Sponsorship open


related to 0002747 non-assigned PHP refresh (ongoing) 
related to 0003860 non-assigned Use PSR-12 standard 



2018-09-07 18:21


phpcs.xml.txt (3,047 bytes)
<?xml version="1.0"?>
<!-- PHP_CodeSniffer ruleset file -->
<!-- Example: -->
<ruleset name="PHP_CodeSniffer">
	<description>PHP coding standard for Composr CMS</description>


	<!-- Exclude third-party code -->
	<!-- Include the PSR2 standard ( -->
	<!-- We only partially follow it: -->
	<rule ref="PSR2">
		<!-- Excludes with the generated error messages mentioned: -->
		<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
		<!-- ^ "Method name [...] is not in camel caps format" -->
		<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
		<!-- ^ "Each class must be in a namespace of at least one level (a top-level vendor name)" -->
		<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
		<!-- ^ "Method name should not be prefixed with an underscore to indicate visibility" -->
		<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
		<!-- ^ "Property name [...] should not be prefixed with an underscore to indicate visibility" -->
		<exclude name="Generic.Files.LineLength.TooLong" />
		<!-- ^ "Line exceeds 120 characters" -->
		<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
		<!-- ^ "Class name [...] is not in PascalCase format" -->
		<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" />
		<!-- ^ "Each class must be in a file by itself" -->
		<exclude name="Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase" />
		<!-- ^ "Constants must be uppercase; expected 'SOME_CONSTANT' but found 'SOME_constant'" -->
		<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace" />
		<!-- ^ "Expected 0 spaces after opening bracket; newline found" -->
phpcs.xml.txt (3,047 bytes)

Chris Graham

2018-09-07 19:34

administrator   ~0005824

I believe the Code Book lists somewhere the lint tools we currently use, so that should be updated.

The 'external_code_considerations' test needs to be updated to make sure exceptions coded for 3rd party libs are consistent with exceptions coded in other configuration files.

Advantages to running the formatter: closer to the code examples in the PSR-2 spec (which apparently our initial PHPStorm-based is not so much); closer to how our JS code is now formatted.

After running the formatter carefully check over the diff to make sure it's not breaking stuff.

We need to make sure the CQC still works. In particular it checks tabbing by comparing opening and closing brace positions.

Issue History

Date Modified Username Field Change
2018-09-07 18:21 Salman New Issue
2018-09-07 18:21 Salman File Added: phpcs.xml.txt
2018-09-07 19:34 Chris Graham Note Added: 0005824
2018-09-07 19:35 Chris Graham Time estimation (hours) => 7
2018-09-07 19:35 Chris Graham Sponsorship open 0 =>
2019-06-27 17:37 Chris Graham Tag Attached: Roadmap: v11
2019-08-12 17:22 Chris Graham Relationship added related to 0003860
2019-08-12 17:23 Chris Graham Tag Attached: Type: Standards compliance
2019-08-12 17:23 Chris Graham Relationship added related to 0002747