Embed Instructions

Across all 194 projects, 88% of the source code conforms to the same coding conventions

  • Image URL
    https://squizlabs.github.io/PHP_CodeSniffer/analysis/grade.svg
  • Markdown
    [![Code consistency](https://squizlabs.github.io/PHP_CodeSniffer/analysis/grade.svg)](https://squizlabs.github.io/PHP_CodeSniffer/analysis)
Bconsistency

Analysis of Coding Conventions

PHP_CodeSniffer, using a custom coding standard and report, was used to record various coding conventions across 194 PHP projects.

Conventions

Analysis of Coding Conventions

Back to top

View project specific report

Project
Consistency

Short array syntax used

Are arrays defined using the PHP 5.4+ short array syntax?

Current
Key Method Use
no no 49.62%
preferred by 42.19% of projects
yes - Most popular method yes 50.38%
preferred by 55.73% of projects
undecided 2.08% of projects are undecided

Based on 475,544 array definitions in 192 projects

107 projects prefer yes

Historical

Array end comma

Does the last item end with a comma in a multi-line array definition?

Current
Key Method Use
no - Most popular method no 52.17%
preferred by 28.78% of projects
yes yes 47.83%
preferred by 44.6% of projects
undecided 26.62% of projects are undecided

Based on 13,286 array definitions in 139 projects

Historical
  • 01 Dec 2015: there was a 0.89% swing from no to yes
    • Anchor CMS saw a 19.05% swing from no to yes
    • Chamilo saw a 4.97% swing from no to yes
    • Monolog saw a 12.5% swing from no to yes
    • Chamilo added 77 array definitions using yes
  • 01 Jan 2016: there was a 0.62% swing from no to yes
    • AWS SDK for PHP saw a 3.85% swing from no to yes
    • Chamilo saw a 4.33% swing from no to yes
    • PhpMetrics saw a 6.67% swing from no to yes
    • PHPMailer saw a 4.29% swing from no to yes
    • Chamilo removed 175 array definitions using no and added 5 array definitions using yes
  • 01 Mar 2016: there was a 0.61% swing from no to yes
  • 01 Nov 2016: there was a 1.11% swing from no to yes

Spacing after string concat

How many spaces follow the string concatenation operator?

Current
Key Method Use
0 0 38.6%
preferred by 12.57% of projects
1 - Most popular method 1 55.01%
preferred by 73.77% of projects
newline newline 6.26%
preferred by 1.64% of projects
Other other 0.12%
undecided 12.02% of projects are undecided

Based on 381,841 concat operators in 183 projects

135 projects prefer 1

Historical
  • 01 Mar 2015: there was a 0.68% swing away from 0
    • Zikula saw a 3.52% swing away from 0
    • Chamilo removed 7404 concat operators using 0
  • 01 Dec 2015: there was a 0.77% swing towards 0
    • Chamilo added 2624 concat operators using 0
    • there was a 0.73% swing away from 1
    • Chamilo removed 411 concat operators using 1
  • 01 Nov 2016: there was a 0.75% swing away from 0

Spacing before string concat

How many spaces precede the string concatenation operator?

Current
Key Method Use
0 0 39.22%
preferred by 12.57% of projects
1 - Most popular method 1 56.38%
preferred by 63.39% of projects
newline newline 4.22%
preferred by 1.09% of projects
Other other 0.18%
undecided 22.95% of projects are undecided

Based on 381,841 concat operators in 183 projects

116 projects prefer 1

2 projects prefer newline

Historical
  • 01 Mar 2015: there was a 0.66% swing away from 0
    • Chamilo removed 7448 concat operators using 0
    • there was a 0.57% swing towards 1
  • 01 Dec 2015: there was a 0.75% swing from 1 to 0
    • Chamilo removed 472 concat operators using 1 and added 2663 concat operators using 0
  • 01 Nov 2016: there was a 0.77% swing from 0 to 1

Spacing after cast statement

How many spaces are there between a cast statement and the variable?

Current
Key Method Use
0 - Most popular method 0 59.39%
preferred by 14.44% of projects
1 1 40.6%
preferred by 78.89% of projects
2 2 < 0.01%
preferred by 0% of projects
8 8 < 0.01%
preferred by 0% of projects
undecided 6.67% of projects are undecided

Based on 37,113 cast statements in 180 projects

142 projects prefer 1

Historical
  • 01 Mar 2015: there was a 0.71% swing from 1 to 0
  • 01 Apr 2015: there was a 0.6% swing from 1 to 0
    • Chamilo saw a 5.86% swing away from 1
    • TYPO3 CMS saw a 3.17% swing from 1 to 0
    • Chamilo saw a 5.83% swing towards 0
    • Chamilo removed 188 cast statements using 1
  • 01 Nov 2016: there was a 2.18% swing from 0 to 1
    • Moodle saw a 3.14% swing from 0 to 1
    • TYPO3 CMS removed 330 cast statements using 0 and added 6 cast statements using 1

Class defined in namespace

Is each class defined in a namespace of at least 1 level?

Current
Key Method Use
no no 37.37%
preferred by 14.43% of projects
yes - Most popular method yes 62.63%
preferred by 84.02% of projects
undecided 1.55% of projects are undecided

Based on 50,312 classes in 194 projects

163 projects prefer yes

3 projects are undecided

Historical
  • 01 Mar 2015: there was a 0.6% swing from yes to no
    • Chamilo saw a 42.09% swing from yes to no
    • Chamilo removed 1397 classes using yes
  • 01 Jun 2015: there was a 0.74% swing from yes to no
  • 01 Sep 2015: there was a 4.04% swing from yes to no
  • 01 Nov 2015: there was a 0.64% swing from no to yes
    • Chamilo saw a 4.45% swing from no to yes
    • phpMyAdmin saw a 70.26% swing from no to yes
  • 01 Dec 2015: there was a 2.09% swing from no to yes
    • Chamilo saw a 12.09% swing from no to yes
    • TYPO3 CMS saw a 39.86% swing from no to yes
    • Chamilo added 270 classes using yes
    • TYPO3 CMS removed 1318 classes using no
  • 01 Feb 2016: there was a 0.67% swing from no to yes
    • pimcore saw a 4.55% swing from no to yes
    • pimcore added 576 classes using yes
  • 01 Nov 2016: there was a 2.25% swing from no to yes
  • 01 Jan 2017: there was a 0.81% swing from no to yes
    • PHPUnit saw a 93.75% swing from no to yes

Lowercase filename

Are PHP filenames lowercase?

Current
Key Method Use
no - Most popular method no 67.28%
preferred by 87.63% of projects
yes yes 32.72%
preferred by 6.19% of projects
undecided 6.19% of projects are undecided

Based on 54,946 files in 194 projects

170 projects prefer no

Historical
  • 01 Mar 2015: there was a 0.58% swing from yes to no
    • Chamilo removed 1377 files using yes
  • 01 Apr 2015: there was a 3.01% swing from yes to no
  • 01 May 2016: there was a 0.64% swing from yes to no
    • ownCloud saw a 32.66% swing from yes to no
  • 01 Jun 2016: there was a 1.35% swing from yes to no
  • 01 Nov 2016: there was a 1.83% swing from yes to no

Class has doc comment

Does each class have a docblock comment to describe its purpose?

Current
Key Method Use
no no 31.82%
preferred by 15.98% of projects
yes - Most popular method yes 68.18%
preferred by 65.98% of projects
undecided 18.04% of projects are undecided

Based on 49,946 classes in 194 projects

128 projects prefer yes

Historical
  • 01 Mar 2015: there was a 0.65% swing from yes to no
    • Chamilo removed 1599 classes using yes
  • 01 Apr 2015: there was a 0.69% swing from yes to no
  • 01 Sep 2015: there was a 3.57% swing from yes to no
  • 01 Dec 2015: there was a 0.95% swing from yes to no
  • 01 Nov 2016: there was a 2.6% swing from no to yes
    • pimcore saw a 27.86% swing from no to yes
  • 01 Jan 2017: there was a 0.78% swing from yes to no

Function has doc comment

Does each function have a docblock comment to describe its purpose?

Current
Key Method Use
no no 27.91%
preferred by 5.15% of projects
yes - Most popular method yes 72.09%
preferred by 79.38% of projects
undecided 15.46% of projects are undecided

Based on 331,315 functions in 194 projects

154 projects prefer yes

Historical
  • 01 Sep 2015: there was a 5.53% swing from yes to no
  • 01 Nov 2016: there was a 1.68% swing from no to yes
    • RoboTask saw a 50.37% swing from no to yes

CamelCase class name

Are class names defined using CamelCase?

Current
Key Method Use
no no 27.81%
preferred by 7.73% of projects
yes - Most popular method yes 72.19%
preferred by 89.18% of projects
undecided 3.09% of projects are undecided

Based on 50,312 classes in 194 projects

173 projects prefer yes

Historical
  • 01 Sep 2015: there was a 4.98% swing from yes to no
  • 01 Dec 2015: there was a 2.4% swing from no to yes
    • Chamilo saw a 4.68% swing from no to yes
    • TYPO3 CMS saw a 39.71% swing from no to yes
    • Chamilo added 271 classes using yes
    • TYPO3 CMS removed 1312 classes using no
  • 01 Feb 2016: there was a 0.84% swing from yes to no
    • pimcore saw a 47.63% swing from yes to no
    • pimcore added 558 classes using no
  • 01 Nov 2016: there was a 1.2% swing from no to yes
  • 01 Jan 2017: there was a 0.71% swing from no to yes
    • PHPUnit saw a 93.75% swing from no to yes

Function opening brace placement

Is the opening brace of a function on the same line as the function keyword or the next line?

Current
Key Method Use
new line - Most popular method new line 75.14%
preferred by 90.72% of projects
same line same line 24.86%
preferred by 7.73% of projects
undecided 1.55% of projects are undecided

Based on 314,937 functions in 194 projects

176 projects prefer new line

3 projects are undecided

Historical
  • 01 Sep 2015: there was a 2.43% swing from same line to new line
    • Pux saw a 48.99% swing from same line to new line
    • SugarCRM CE saw a 27.79% swing from same line to new line
    • SugarCRM CE added 23601 functions using new line
  • 01 Nov 2015: there was a 4.38% swing from same line to new line
    • TYPO3 CMS saw a 94.97% swing from same line to new line
  • 01 Mar 2016: there was a 1.41% swing from same line to new line
    • Anchor CMS saw a 88.8% swing from same line to new line
    • Faveo Help-desk saw a 75.09% swing from same line to new line
    • pimcore saw a 69.15% swing from same line to new line
  • 01 Nov 2016: there was a 2.72% swing from new line to same line

Line indent

Are lines indented using spaces or tabs?

Current
Key Method Use
spaces - Most popular method spaces 77.35%
preferred by 82.47% of projects
tabs tabs 22.65%
preferred by 17.01% of projects
undecided 0.52% of projects are undecided

Based on 7,304,313 indented lines in 194 projects

160 projects prefer spaces

1 project is undecided

Historical
  • 01 Aug 2015: there was a 1.99% swing from tabs to spaces
    • PrestaShop saw a 81.97% swing from tabs to spaces
  • 01 Sep 2015: there was a 0.88% swing from tabs to spaces
  • 01 Nov 2015: there was a 5.09% swing from tabs to spaces
    • TYPO3 CMS saw a 96.62% swing from tabs to spaces
  • 01 Nov 2016: there was a 1.42% swing from tabs to spaces

File has doc comment

Does each PHP file have a docblock comment to describe its purpose?

Current
Key Method Use
no no 22.31%
preferred by 18.56% of projects
yes - Most popular method yes 77.69%
preferred by 79.38% of projects
undecided 2.06% of projects are undecided

Based on 54,945 files in 194 projects

154 projects prefer yes

Historical
  • 01 Mar 2015: there was a 0.95% swing from no to yes
    • Chamilo saw a 12.53% swing from no to yes
    • ownCloud saw a 3.44% swing from no to yes
    • Chamilo removed 1018 files using no
  • 01 Apr 2015: there was a 0.91% swing from yes to no
  • 01 Jun 2015: there was a 0.67% swing from yes to no
  • 01 Jan 2016: there was a 0.66% swing from yes to no
  • 01 Nov 2016: there was a 1.51% swing from no to yes
  • 01 Jan 2017: there was a 1.06% swing from yes to no

Use of ELSE IF or ELSEIF

Are elseif statements defined using elseif or else if?

Current
Key Method Use
else if else if 22.15%
preferred by 6.51% of projects
elseif - Most popular method elseif 77.85%
preferred by 86.98% of projects
undecided 6.51% of projects are undecided

Based on 26,181 elseif statements in 169 projects

147 projects prefer elseif

Historical
  • 01 Mar 2015: there was a 1.63% swing from else if to elseif
    • Chamilo saw a 14.7% swing from else if to elseif
    • Chamilo removed 922 elseif statements using else if
  • 01 Aug 2015: there was a 1.23% swing from else if to elseif
  • 01 Mar 2016: there was a 1.83% swing from else if to elseif
    • Anchor CMS saw a 53.33% swing from else if to elseif
    • pimcore saw a 95.6% swing from else if to elseif
    • phpMyAdmin removed 1 elseif statements using else if
  • 01 Jun 2016: there was a 0.65% swing from else if to elseif
    • Chamilo saw a 4.76% swing from else if to elseif
    • Joomla! CMS removed 15 elseif statements using else if and added 197 elseif statements using elseif
  • 01 Nov 2016: there was a 0.92% swing from else if to elseif
    • PHP Parser saw a 9.82% swing from else if to elseif

Class opening brace placement

Is the opening brace of a class on the same line as the class keyword or the next line?

Current
Key Method Use
new line - Most popular method new line 78.35%
preferred by 90.72% of projects
same line same line 21.65%
preferred by 6.7% of projects
undecided 2.58% of projects are undecided

Based on 50,312 classes in 194 projects

176 projects prefer new line

Historical
  • 01 Feb 2015: there was a 0.81% swing from same line to new line
    • RoboTask saw a 55.44% swing from same line to new line
    • PHPMailer saw a 12.5% swing from same line to new line
    • QuickAppsCMS saw a 100% swing from same line to new line
  • 01 Mar 2015: there was a 0.91% swing from new line to same line
    • Chamilo saw a 11.47% swing from new line to same line
    • Chamilo removed 1662 classes using new line
  • 01 Jun 2015: there was a 0.82% swing from same line to new line
  • 01 Sep 2015: there was a 1.71% swing from same line to new line
    • Pux saw a 12.5% swing from same line to new line
    • SugarCRM CE saw a 24.7% swing from same line to new line
    • Stash saw a 5.56% swing from same line to new line
    • SugarCRM CE added 2998 classes using new line
  • 01 Nov 2015: there was a 7.31% swing from same line to new line
    • TYPO3 CMS saw a 96.78% swing from same line to new line
  • 01 Jan 2016: there was a 0.57% swing from new line to same line
  • 01 Feb 2016: there was a 1.27% swing from new line to same line
    • pimcore saw a 3.7% swing from new line to same line
    • pimcore added 575 classes using same line
  • 01 Mar 2016: there was a 3.01% swing from same line to new line
    • Anchor CMS saw a 98.31% swing from same line to new line
    • Faveo Help-desk saw a 94.32% swing from same line to new line
    • pimcore saw a 96.46% swing from same line to new line
  • 01 Nov 2016: there was a 3.8% swing from new line to same line

Space before operator

How many spaces precede comparison, arithmetic and assignment operators?

Current
Key Method Use
0 0 19.77%
preferred by 1.05% of projects
1 - Most popular method 1 78.72%
preferred by 93.16% of projects
newline newline 1.32%
preferred by 0% of projects
Other other 0.19%
undecided 5.79% of projects are undecided

Based on 393,950 operators in 190 projects

177 projects prefer 1

0 projects prefer newline

Historical
  • 01 Mar 2015: there was a 24.48% swing away from 0
    • Chamilo saw a 54.43% swing away from 0
    • Chamilo removed 175267 operators using 0
    • there was a 23.98% swing towards 1
    • Chamilo saw a 54.02% swing towards 1
  • 01 Dec 2015: there was a 0.91% swing from 1 to 0
    • Anchor CMS saw a 4.1% swing from 1 to 0
    • Chamilo saw a 6.31% swing away from 1
    • Faker saw a 49.82% swing away from 1
    • Chamilo saw a 6.35% swing towards 0
    • Faker saw a 49.93% swing towards 0
    • Chamilo added 3468 operators using 0
  • 01 Nov 2016: there was a 0.74% swing from 0 to 1

Adjacent assignments aligned

For a block of assignments, are the assignment operators (equals, plus-equals etc.) aligned?

Current
Key Method Use
no - Most popular method no 81.09%
preferred by 61.26% of projects
yes yes 18.91%
preferred by 11.52% of projects
undecided 27.23% of projects are undecided

Based on 178,345 assignment blocks in 191 projects

117 projects prefer no

Historical

One class per file

Is each class defined in a file by itself?

Current
Key Method Use
no no 16.68%
preferred by 1.03% of projects
yes - Most popular method yes 83.32%
preferred by 95.88% of projects
undecided 3.09% of projects are undecided

Based on 50,312 classes in 194 projects

186 projects prefer yes

Historical
  • 01 Sep 2015: there was a 5.61% swing from yes to no
  • 01 Dec 2015: there was a 2.56% swing from no to yes
  • 01 Feb 2016: there was a 1.02% swing from yes to no
    • pimcore saw a 53.17% swing from yes to no
    • pimcore added 571 classes using no
  • 01 Nov 2016: there was a 1.26% swing from no to yes

Declarations and side effects mixed

Do files both declare symbols (classes, functions, constants, etc.) and cause side-effects (e.g. generate output, change .ini settings, etc.)?

Current
Key Method Use
no - Most popular method no 85.58%
preferred by 94.33% of projects
yes yes 14.42%
preferred by 2.58% of projects
undecided 3.09% of projects are undecided

Based on 54,946 files in 194 projects

183 projects prefer no

Historical

PHP constant case

What case are PHP constants (true, false, null) written in?

Current
Key Method Use
lower - Most popular method lower 87.95%
preferred by 87.05% of projects
mixed mixed 0.07%
preferred by 0% of projects
upper upper 11.98%
preferred by 11.92% of projects
undecided 1.04% of projects are undecided

Based on 311,194 PHP constants in 193 projects

168 projects prefer lower

2 projects are undecided

Historical
  • 01 Sep 2015: there was a 1.58% swing from lower to upper
  • 01 Nov 2015: there was a 3.58% swing from upper to lower
  • 01 Dec 2015: there was a 2.19% swing from upper to lower
  • 01 Jan 2016: there was a 0.64% swing from upper to lower
    • Chamilo saw a 15.06% swing from upper to lower
    • Chamilo removed 4293 PHP constants using upper
  • 01 Apr 2016: there was a 1.16% swing from lower to upper
    • AWS SDK for PHP saw a 18.96% swing from lower to upper
    • AWS SDK for PHP removed 941 PHP constants using lower and added 3305 PHP constants using upper
  • 01 Nov 2016: there was a 4.04% swing from lower to upper
  • 01 Dec 2016: there was a 0.6% swing from lower to upper

Private method prefixed with underscore

Are private methods prefixed with an underscore?

Current
Key Method Use
no - Most popular method no 87.95%
preferred by 93.02% of projects
yes yes 12.05%
preferred by 4.65% of projects
undecided 2.33% of projects are undecided

Based on 10,150 private methods in 129 projects

120 projects prefer no

3 projects are undecided

Historical
  • 01 Apr 2015: there was a 2.18% swing from yes to no
  • 01 May 2015: there was a 0.59% swing from yes to no
    • Chamilo saw a 7.5% swing from yes to no
    • Chamilo removed 33 private methods using yes
    • Piwik added 44 private methods using no
  • 01 Nov 2016: there was a 0.76% swing from yes to no

CamelCase method name

Are class method names defined using CamelCase?

Current
Key Method Use
no no 11.24%
preferred by 2.06% of projects
yes - Most popular method yes 88.76%
preferred by 96.39% of projects
undecided 1.55% of projects are undecided

Based on 299,358 methods in 194 projects

187 projects prefer yes

Historical
  • 01 Mar 2015: there was a 0.98% swing from no to yes
    • Chamilo removed 3964 methods using no
  • 01 Sep 2015: there was a 1.2% swing from no to yes
    • Pux saw a 4.74% swing from no to yes
    • SugarCRM CE saw a 16.54% swing from no to yes
    • SugarCRM CE added 23435 methods using yes
  • 01 Nov 2016: there was a 0.59% swing from no to yes

Inline comment style

What comment style is used for non docblock comments?

Current
Key Method Use
# ... # ... 2.62%
preferred by 0.54% of projects
/* ... */ /* ... */ 8.6%
preferred by 0% of projects
// ... - Most popular method // ... 88.78%
preferred by 81.72% of projects
undecided 17.74% of projects are undecided

Based on 368,540 inline comments in 186 projects

1 project prefers # ...

0 projects prefer /* ... */

152 projects prefer // ...

Historical

Spaces after control structure open parenthesis

How many spaces follow the opening parenthesis of a control structure?

Current
Key Method Use
0 - Most popular method 0 91.8%
preferred by 97.93% of projects
1 1 8.02%
preferred by 1.55% of projects
Other other 0.18%
undecided 0.52% of projects are undecided

Based on 489,627 control structures in 193 projects

189 projects prefer 0

3 projects prefer 1

1 project is undecided

Historical

Constant name case

What case are user-defined constants defined in?

Current
Key Method Use
lower lower 0.9%
preferred by 1.27% of projects
mixed mixed 7.22%
preferred by 0.64% of projects
upper - Most popular method upper 91.89%
preferred by 98.09% of projects

Based on 22,071 constants in 157 projects

2 projects prefer lower

1 project prefers mixed

154 projects prefer upper

Historical
  • 01 Mar 2015: there was a 3.83% swing away from upper
    • Chamilo removed 16303 constants using upper
    • there was a 3.43% swing towards mixed

Line length

Including whitespace and comments, how many characters are in non-empty code lines?

Current
Key Method Use
80 or less - Most popular method 80 or less 92.53%
preferred by 99.48% of projects
81-120 81-120 6.11%
preferred by 0% of projects
121-150 121-150 0.78%
preferred by 0% of projects
151 or more 151 or more 0.58%
preferred by 0% of projects
undecided 0.52% of projects are undecided

Based on 9,220,039 lines in 194 projects

193 projects prefer 80 or less

1 project is undecided

Historical

Spaces before control structure close parenthesis

How many spaces precede the closing parenthesis of a control structure?

Current
Key Method Use
0 - Most popular method 0 92.65%
preferred by 98.45% of projects
1 1 7.34%
preferred by 1.55% of projects
2 2 0.01%
preferred by 0% of projects
3 3 < 0.01%
preferred by 0% of projects

Based on 489,627 control structures in 193 projects

190 projects prefer 0

3 projects prefer 1

Historical

Number of newlines at EOF

How many newline characters appear at the end of the file?

Current
Key Method Use
0 0 5.15%
preferred by 0.52% of projects
1 - Most popular method 1 92.78%
preferred by 95.36% of projects
2 2 1.59%
preferred by 0% of projects
Other other 0.48%
undecided 4.12% of projects are undecided

Based on 53,096 files in 194 projects

1 project prefers 0

185 projects prefer 1

Historical

PHP closing tag at EOF

Is there a PHP closing tag at the end of the file?

Current
Key Method Use
no - Most popular method no 95.15%
preferred by 98.45% of projects
yes yes 4.85%
preferred by 0.52% of projects
undecided 1.03% of projects are undecided

Based on 54,946 files in 194 projects

191 projects prefer no

1 project prefers yes

2 projects are undecided

Historical
  • 01 Mar 2015: there was a 1.07% swing from yes to no
    • Chamilo removed 847 files using yes
  • 01 Apr 2015: there was a 4.85% swing from yes to no
  • 01 Aug 2015: there was a 0.77% swing from yes to no