Embed Instructions

Across all 197 projects, 89.07% 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 197 PHP projects.

Conventions

Analysis of Coding Conventions

Back to top

View project specific report

Project
Consistency

Array end comma

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

Current
Key Method Use
no no 49%
preferred by 23.94% of projects
yes - Most popular method yes 51%
preferred by 52.11% of projects
undecided 23.94% of projects are undecided

Based on 14,772 array definitions in 142 projects

74 projects prefer yes

Historical
  • 01 Dec 2015: there was a 0.81% 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
    • PHPMailer saw a 9.52% swing from no to yes
    • Monolog saw a 12.5% swing from no to yes
    • Chamilo added 77 array definitions using yes
  • 01 Nov 2016: there was a 1.1% swing from no to yes
  • 01 May 2017: there was a 2.3% swing from no to yes
    • OpenEMR removed 783 array definitions using no
  • 01 Sep 2017: there was a 0.76% swing from no to yes
    • TYPO3 CMS saw a 20.09% swing from no to yes
    • TYPO3 CMS added 230 array definitions using yes
  • 01 Aug 2018: there was a 1.81% swing from no to yes

Spacing after string concat

How many spaces follow the string concatenation operator?

Current
Key Method Use
0 0 38.88%
preferred by 10.75% of projects
1 - Most popular method 1 53.46%
preferred by 75.27% of projects
newline newline 7.51%
preferred by 1.08% of projects
Other other 0.15%
undecided 12.9% of projects are undecided

Based on 432,253 concat operators in 186 projects

140 projects prefer 1

Historical
  • 01 Mar 2015: there was a 0.64% swing away from 0
    • Zikula saw a 3.52% swing away from 0
    • Chamilo removed 7443 concat operators using 0
  • 01 Oct 2016: there was a 1.18% swing away from newline
    • OpenEMR saw a 6.93% swing away from newline
    • OpenEMR removed 5793 concat operators using newline
    • there was a 1.1% swing towards 0
    • OpenEMR saw a 5.78% swing towards 0
    • OpenEMR added 1577 concat operators using 0
  • 01 Nov 2016: there was a 0.6% swing away from 0
  • 01 May 2017: there was a 1.32% swing towards 0
    • OpenEMR saw a 7.12% swing towards 0
    • there was a 1.59% swing away from 1
    • OpenEMR saw a 12.66% swing away from 1
    • OpenEMR removed 16775 concat operators using 1

Spacing before string concat

How many spaces precede the string concatenation operator?

Current
Key Method Use
0 0 39.58%
preferred by 10.75% of projects
1 - Most popular method 1 56.1%
preferred by 63.44% of projects
newline newline 3.76%
preferred by 2.15% of projects
Other other 0.56%
undecided 23.66% of projects are undecided

Based on 432,251 concat operators in 186 projects

118 projects prefer 1

Historical
  • 01 Mar 2015: there was a 0.62% swing away from 0
    • Chamilo removed 7486 concat operators using 0
  • 01 Oct 2016: there was a 1.11% swing from 1 to 0
    • OpenEMR saw a 6.84% swing away from 1
    • OpenEMR saw a 5.94% swing towards 0
    • OpenEMR removed 9057 concat operators using 1 and added 1593 concat operators using 0
  • 01 Nov 2016: there was a 0.62% swing away from 0
  • 01 May 2017: there was a 1.36% swing from newline to 0
    • OpenEMR saw a 10.88% swing away from newline
    • OpenEMR saw a 7.64% swing towards 0
    • OpenEMR removed 6988 concat operators using newline

Short array syntax used

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

Current
Key Method Use
no no 41.83%
preferred by 36.92% of projects
yes - Most popular method yes 58.17%
preferred by 61.03% of projects
undecided 2.05% of projects are undecided

Based on 597,364 array definitions in 195 projects

119 projects prefer yes

Historical

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.6%
preferred by 15.08% of projects
1 1 40.4%
preferred by 77.65% of projects
2 2 < 0.01%
preferred by 0% of projects
8 8 < 0.01%
preferred by 0% of projects
undecided 7.26% of projects are undecided

Based on 39,544 cast statements in 179 projects

139 projects prefer 1

Historical
  • 01 Mar 2015: there was a 0.65% swing from 1 to 0
  • 01 Apr 2015: there was a 0.58% swing from 1 to 0
    • Chamilo saw a 6.1% swing from 1 to 0
    • TYPO3 CMS saw a 3.17% swing from 1 to 0
    • Chamilo removed 188 cast statements using 1
  • 01 Oct 2016: there was a 1.83% swing from 1 to 0
    • OpenEMR saw a 38.5% swing from 1 to 0
    • OpenEMR removed 1132 cast statements using 1
  • 01 Nov 2016: there was a 2.19% 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 35.4%
preferred by 12.69% of projects
yes - Most popular method yes 64.6%
preferred by 83.76% of projects
undecided 3.55% of projects are undecided

Based on 55,017 classes in 197 projects

165 projects prefer yes

Historical
  • 01 Apr 2015: there was a 0.74% swing from no to yes
  • 01 Jun 2015: there was a 0.65% swing from yes to no
  • 01 Sep 2015: there was a 3.8% swing from yes to no
  • 01 Nov 2015: there was a 0.66% swing from no to yes
    • Chamilo saw a 4.42% swing from no to yes
    • phpMyAdmin saw a 70.26% swing from no to yes
  • 01 Dec 2015: there was a 1.99% swing from no to yes
    • Chamilo saw a 12.4% swing from no to yes
    • PHPMailer saw a 100% swing from no to yes
    • TYPO3 CMS saw a 39.86% swing from no to yes
    • Chamilo removed 3 classes using no and added 270 classes using yes
    • TYPO3 CMS removed 1318 classes using no
  • 01 Feb 2016: there was a 0.69% swing from no to yes
    • pimcore saw a 6.35% swing from no to yes
    • pimcore removed 9 classes using no and added 576 classes using yes
  • 01 Oct 2016: there was a 1.82% swing from yes to no
    • OpenEMR saw a 54.91% swing from yes to no
    • OpenEMR removed 2179 classes using yes
  • 01 Nov 2016: there was a 2.23% 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 66.49%
preferred by 86.8% of projects
yes yes 33.51%
preferred by 6.6% of projects
undecided 6.6% of projects are undecided

Based on 61,997 files in 197 projects

171 projects prefer no

Historical
  • 01 Mar 2015: there was a 0.57% swing from yes to no
    • Chamilo removed 1379 files using yes
  • 01 Apr 2015: there was a 2.77% swing from yes to no
  • 01 May 2016: there was a 0.57% swing from yes to no
    • ownCloud saw a 32.66% swing from yes to no
  • 01 Jun 2016: there was a 1.22% swing from yes to no
  • 01 Oct 2016: there was a 1.59% swing from no to yes
    • OpenEMR saw a 32.02% swing from no to yes
    • OpenEMR removed 2425 files using no and added 9 files using yes
  • 01 Nov 2016: there was a 1.85% 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 32.15%
preferred by 16.24% of projects
yes - Most popular method yes 67.85%
preferred by 64.47% of projects
undecided 19.29% of projects are undecided

Based on 55,017 classes in 197 projects

127 projects prefer yes

Historical
  • 01 Mar 2015: there was a 0.64% swing from yes to no
    • Chamilo removed 1606 classes using yes
  • 01 Apr 2015: there was a 0.61% swing from yes to no
  • 01 Sep 2015: there was a 3.22% swing from yes to no
  • 01 Dec 2015: there was a 1.21% swing from yes to no
  • 01 Oct 2016: there was a 1.09% swing from no to yes
  • 01 Nov 2016: there was a 2.57% swing from no to yes
    • pimcore saw a 27.68% swing from no to yes
  • 01 Jan 2017: there was a 0.85% 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.64%
preferred by 5.58% of projects
yes - Most popular method yes 72.36%
preferred by 78.17% of projects
undecided 16.24% of projects are undecided

Based on 370,045 functions in 197 projects

154 projects prefer yes

Historical
  • 01 Sep 2015: there was a 4.96% swing from yes to no
  • 01 Oct 2016: there was a 1.06% swing from yes to no
    • OpenEMR saw a 22.49% swing from yes to no
    • OpenEMR removed 11790 functions using yes
  • 01 Nov 2016: there was a 1.66% swing from no to yes
    • RoboTask saw a 50.37% swing from no to yes
  • 01 Mar 2018: there was a 1.06% swing from no to yes
    • Anchor CMS saw a 59.65% swing from no to yes
    • OpenEMR saw a 36.55% swing from no to yes
    • React.dns saw a 4.1% swing from no to yes
    • OpenEMR added 12309 functions using yes

PascalCase class name

Are class names defined using PascalCase?

Current
Key Method Use
no no 26.09%
preferred by 7.11% of projects
yes - Most popular method yes 73.91%
preferred by 90.36% of projects
undecided 2.54% of projects are undecided

Based on 55,017 classes in 197 projects

178 projects prefer yes

Historical
  • 01 Apr 2015: there was a 0.7% swing from no to yes
  • 01 Sep 2015: there was a 4.66% swing from yes to no
  • 01 Dec 2015: there was a 2.25% swing from no to yes
    • Chamilo saw a 5.16% swing from no to yes
    • PHPMailer saw a 15.38% swing from no to yes
    • TYPO3 CMS saw a 39.71% swing from no to yes
    • Chamilo removed 2 classes using no and added 269 classes using yes
    • TYPO3 CMS removed 1312 classes using no
  • 01 Feb 2016: there was a 0.67% swing from yes to no
    • PHPMailer saw a 8.33% swing from yes to no
    • pimcore saw a 46.21% swing from yes to no
    • pimcore added 550 classes using no
  • 01 Oct 2016: there was a 1.32% swing from yes to no
    • OpenEMR saw a 37.82% swing from yes to no
    • OpenEMR removed 2178 classes using yes
  • 01 Nov 2016: there was a 1.2% swing from no to yes
  • 01 Jan 2017: there was a 0.68% swing from no to yes
    • PHPUnit saw a 93.75% swing from no to yes
  • 01 Mar 2017: there was a 0.87% swing from no to yes
    • pimcore saw a 48.26% swing from no to yes
    • pimcore removed 571 classes using no

Use of ELSE IF or ELSEIF

Are elseif statements defined using elseif or else if?

Current
Key Method Use
else if else if 24.99%
preferred by 5.17% of projects
elseif - Most popular method elseif 75.01%
preferred by 87.93% of projects
undecided 6.9% of projects are undecided

Based on 30,035 elseif statements in 174 projects

153 projects prefer elseif

Historical
  • 01 Mar 2015: there was a 1.44% swing from else if to elseif
    • Chamilo saw a 15.37% swing from else if to elseif
    • Chamilo removed 963 elseif statements using else if
  • 01 Aug 2015: there was a 0.98% swing from else if to elseif
  • 01 Mar 2016: there was a 1.63% 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.85% swing from else if to elseif
    • Joomla! CMS removed 15 elseif statements using else if and added 197 elseif statements using elseif
  • 01 Oct 2016: there was a 0.62% swing from elseif to else if
    • OpenEMR saw a 7.32% swing from elseif to else if
    • OpenEMR removed 757 elseif statements using elseif and added 36 elseif statements using else if
  • 01 Nov 2016: there was a 0.9% swing from else if to elseif
    • PHP Parser saw a 9.82% swing from else if to elseif
  • 01 May 2017: there was a 0.68% swing from elseif to else if
    • OpenEMR saw a 11.37% swing from elseif to else if
    • React.http saw a 25% swing from elseif to else if
    • OpenEMR removed 977 elseif statements using elseif
  • 01 Mar 2018: there was a 2.08% swing from elseif to else if
    • OpenEMR saw a 13.02% swing from elseif to else if
    • OpenEMR added 802 elseif statements using else if
  • 01 Jun 2018: there was a 0.73% swing from else if to elseif
    • ownCloud saw a 64.61% swing from else if to elseif

File has doc comment

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

Current
Key Method Use
no no 24.64%
preferred by 19.8% of projects
yes - Most popular method yes 75.36%
preferred by 77.66% of projects
undecided 2.54% of projects are undecided

Based on 61,996 files in 197 projects

153 projects prefer yes

Historical
  • 01 Mar 2015: there was a 0.93% swing from no to yes
    • Chamilo saw a 12.51% 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 1.24% swing from yes to no
  • 01 Jun 2015: there was a 0.59% swing from yes to no
  • 01 Jan 2016: there was a 0.61% swing from yes to no
  • 01 Oct 2016: there was a 0.97% swing from yes to no
    • OpenEMR saw a 11.06% swing from yes to no
    • OpenEMR removed 2413 files using yes
  • 01 Nov 2016: there was a 1.45% swing from no to yes
  • 01 Jan 2017: there was a 1% swing from yes to no
  • 01 Feb 2017: there was a 1.22% swing from yes to no
    • Imagine saw a 18.87% swing from yes to no
    • Phing saw a 5.5% swing from yes to no
  • 01 Feb 2018: there was a 0.73% swing from yes to no
  • 01 Mar 2018: there was a 0.89% swing from yes to no
    • OpenEMR saw a 21.9% swing from yes to no
    • OpenEMR added 705 files using no

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 76.31%
preferred by 91.37% of projects
same line same line 23.69%
preferred by 6.6% of projects
undecided 2.03% of projects are undecided

Based on 352,527 functions in 197 projects

180 projects prefer new line

Historical
  • 01 Sep 2015: there was a 2.14% 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.18% 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.42% 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 Oct 2016: there was a 0.8% swing from new line to same line
    • OpenEMR saw a 26.28% swing from new line to same line
    • OpenEMR removed 11266 functions using new line
  • 01 Nov 2016: there was a 2.51% swing from new line to same line
  • 01 Aug 2017: there was a 2.34% swing from same line to new line
    • Agora Invoicing saw a 73.89% swing from same line to new line
    • OpenEMR saw a 70.85% swing from same line to new line
  • 01 Mar 2018: there was a 0.88% swing from same line to new line
    • OpenEMR added 12347 functions using new line

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.32%
preferred by 91.37% of projects
same line same line 21.68%
preferred by 6.09% of projects
undecided 2.54% of projects are undecided

Based on 55,017 classes in 197 projects

180 projects prefer new line

Historical
  • 01 Feb 2015: there was a 0.78% 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.81% swing from new line to same line
    • Chamilo saw a 12.02% swing from new line to same line
    • Chamilo removed 1662 classes using new line
  • 01 Jun 2015: there was a 0.77% swing from same line to new line
  • 01 Sep 2015: there was a 1.53% 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 6.81% swing from same line to new line
    • TYPO3 CMS saw a 96.78% swing from same line to new line
  • 01 Feb 2016: there was a 1.06% swing from new line to same line
    • PHPMailer saw a 8.33% swing from new line to same line
    • pimcore saw a 3.56% swing from new line to same line
    • pimcore added 565 classes using same line
  • 01 Mar 2016: there was a 2.94% 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
    • OpenEMR removed 13 classes using same line and added 286 classes using new line
  • 01 Oct 2016: there was a 0.8% swing from new line to same line
    • OpenEMR saw a 13.08% swing from new line to same line
    • OpenEMR removed 2179 classes using new line
  • 01 Nov 2016: there was a 3.67% swing from new line to same line
  • 01 Aug 2017: there was a 0.91% swing from same line to new line
    • Agora Invoicing saw a 50.14% swing from same line to new line
    • OpenEMR saw a 44.17% swing from same line to new line

Space before operator

How many spaces precede comparison, arithmetic and assignment operators?

Current
Key Method Use
0 0 19.94%
preferred by 1.04% of projects
1 - Most popular method 1 78.75%
preferred by 94.3% of projects
newline newline 1.15%
preferred by 0% of projects
Other other 0.16%
undecided 4.66% of projects are undecided

Based on 458,363 operators in 193 projects

182 projects prefer 1

0 projects prefer newline

Historical
  • 01 Mar 2015: there was a 18.12% swing away from 0
    • Chamilo saw a 49.36% swing away from 0
    • Chamilo removed 175949 operators using 0
    • there was a 17.74% swing towards 1
    • Chamilo saw a 48.99% swing towards 1
  • 01 Feb 2016: there was a 0.61% swing from 0 to 1
    • pimcore saw a 54.44% swing away from 0
    • pimcore saw a 54.26% swing towards 1
    • pimcore removed 3429 operators using 0 and added 9 operators using 1
  • 01 Mar 2016: there was a 0.8% swing from 1 to 0
  • 01 Oct 2016: there was a 0.64% swing from 1 to 0
    • OpenEMR saw a 5.52% swing away from 1
    • OpenEMR saw a 5.77% swing towards 0
    • OpenEMR removed 8965 operators using 1 and added 671 operators using 0
  • 01 Nov 2016: there was a 0.96% swing from 0 to 1
  • 01 May 2017: there was a 6.63% swing from 0 to 1
    • OpenEMR saw a 21.07% swing away from 0
    • pimcore saw a 5.72% swing away from 0
    • OpenEMR saw a 21.49% swing towards 1
    • pimcore saw a 5.91% swing towards 1
    • PHPUnit saw a 7.19% swing towards 1
    • OpenEMR removed 45795 operators using 0

Line indent

Are lines indented using spaces or tabs?

Current
Key Method Use
mixed mixed 0.32%
preferred by 0% of projects
spaces - Most popular method spaces 79.12%
preferred by 83.25% of projects
tabs tabs 20.56%
preferred by 16.75% of projects

Based on 8,280,976 indented lines in 197 projects

164 projects prefer spaces

Historical
  • 01 Aug 2015: there was a 1.88% swing from tabs to spaces
  • 01 Sep 2015: there was a 0.69% swing from tabs to spaces
  • 01 Nov 2015: there was a 4.83% swing from tabs to spaces
    • TYPO3 CMS saw a 96.61% swing from tabs to spaces
  • 01 Oct 2016: there was a 0.68% swing from spaces to tabs
    • OpenEMR saw a 9.26% swing away from spaces
    • OpenEMR saw a 8.77% swing towards tabs
    • OpenEMR removed 219266 indented lines using spaces and added 1162 indented lines using tabs
  • 01 Nov 2016: there was a 1.35% swing towards spaces
    • there was a 1.33% swing away from tabs
  • 01 Aug 2017: there was a 1.5% swing towards spaces
    • Agora Invoicing saw a 35.36% swing towards spaces
    • OpenEMR saw a 33.18% swing towards spaces
    • there was a 1.43% swing away from tabs
    • Agora Invoicing saw a 35.01% swing away from tabs
    • OpenEMR saw a 31.12% swing away from tabs
  • 01 Mar 2018: there was a 0.65% swing towards spaces
    • Anchor CMS saw a 15.2% swing towards spaces
    • OpenEMR added 231710 indented lines using spaces
    • there was a 0.64% swing away from tabs
    • Anchor CMS saw a 15.1% swing away from tabs

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 80.63%
preferred by 60.82% of projects
yes yes 19.37%
preferred by 10.31% of projects
undecided 28.87% of projects are undecided

Based on 196,599 assignment blocks in 194 projects

118 projects prefer no

Historical
  • 01 Sep 2015: there was a 0.68% swing from no to yes
  • 01 Oct 2016: there was a 0.79% swing from yes to no
    • OpenEMR saw a 7.55% swing from yes to no
    • OpenEMR removed 1975 assignment blocks using 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.13%
preferred by 94.42% of projects
yes yes 14.87%
preferred by 2.54% of projects
undecided 3.05% of projects are undecided

Based on 61,997 files in 197 projects

186 projects prefer no

Historical
  • 01 Apr 2015: there was a 0.73% swing from no to yes
  • 01 Oct 2016: there was a 0.74% swing from no to yes
    • OpenEMR saw a 19.73% swing from no to yes
    • OpenEMR removed 2402 files using no
  • 01 Nov 2016: there was a 1.15% swing from yes to no

One class per file

Is each class defined in a file by itself?

Current
Key Method Use
no no 14.39%
preferred by 1.02% of projects
yes - Most popular method yes 85.61%
preferred by 96.45% of projects
undecided 2.54% of projects are undecided

Based on 55,017 classes in 197 projects

190 projects prefer yes

Historical
  • 01 Sep 2015: there was a 5.22% swing from yes to no
  • 01 Dec 2015: there was a 2.39% swing from no to yes
    • PHPMailer saw a 7.69% swing from no to yes
    • TYPO3 CMS saw a 38.76% swing from no to yes
    • Chamilo removed 1 classes using no and added 268 classes using yes
    • TYPO3 CMS removed 1280 classes using no
  • 01 Feb 2016: there was a 0.88% swing from yes to no
    • pimcore saw a 51.39% swing from yes to no
    • pimcore added 562 classes using no
  • 01 Oct 2016: there was a 0.71% swing from yes to no
    • OpenEMR saw a 5.23% swing from yes to no
    • OpenEMR removed 2179 classes using yes
  • 01 Nov 2016: there was a 1.23% swing from no to yes
  • 01 Mar 2017: there was a 0.97% swing from no to yes
    • pimcore saw a 50.84% swing from no to yes
    • pimcore removed 569 classes using no

PHP constant case

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

Current
Key Method Use
lower - Most popular method lower 87.26%
preferred by 93.37% of projects
mixed mixed 0.05%
preferred by 0% of projects
upper upper 12.69%
preferred by 5.61% of projects
undecided 1.02% of projects are undecided

Based on 354,193 PHP constants in 196 projects

183 projects prefer lower

2 projects are undecided

Historical

CamelCase method name

Are class method names defined using CamelCase?

Current
Key Method Use
no no 12.61%
preferred by 2.03% of projects
yes - Most popular method yes 87.39%
preferred by 96.45% of projects
undecided 1.52% of projects are undecided

Based on 334,598 methods in 197 projects

190 projects prefer yes

Historical
  • 01 Mar 2015: there was a 0.84% swing from no to yes
    • Chamilo removed 3973 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.66% swing from no to yes

Private method prefixed with underscore

Are private methods prefixed with an underscore?

Current
Key Method Use
no - Most popular method no 89.97%
preferred by 93.53% of projects
yes yes 10.03%
preferred by 3.6% of projects
undecided 2.88% of projects are undecided

Based on 11,939 private methods in 139 projects

130 projects prefer no

Historical
  • 01 Apr 2015: there was a 2.16% swing from yes to no
  • 01 Nov 2016: there was a 0.89% swing from yes to no
  • 01 May 2017: there was a 2.57% swing from yes to no
    • OpenEMR saw a 63.29% swing from yes to no
    • OpenEMR removed 315 private methods using yes and added 2 private methods using no

Inline comment style

What comment style is used for non docblock comments?

Current
Key Method Use
# ... # ... 2.32%
preferred by 0.52% of projects
/* ... */ /* ... */ 7.55%
preferred by 1.04% of projects
// ... - Most popular method // ... 90.13%
preferred by 86.98% of projects
undecided 11.46% of projects are undecided

Based on 424,103 inline comments in 192 projects

1 project prefers # ...

2 projects prefer /* ... */

167 projects prefer // ...

Historical

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.26%
preferred by 99.49% of projects
81-120 81-120 6.26%
preferred by 0% of projects
121-150 121-150 0.84%
preferred by 0% of projects
151 or more 151 or more 0.64%
preferred by 0% of projects
undecided 0.51% of projects are undecided

Based on 10,378,431 lines in 197 projects

196 projects prefer 80 or less

1 project is undecided

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 92.44%
preferred by 98.47% of projects
1 1 7.39%
preferred by 1.53% of projects
Other other 0.17%

Based on 555,178 control structures in 196 projects

193 projects prefer 0

3 projects prefer 1

Historical

Constant name case

What case are user-defined constants defined in?

Current
Key Method Use
lower lower 0.86%
preferred by 0.63% of projects
mixed mixed 6.62%
preferred by 0.63% of projects
upper - Most popular method upper 92.52%
preferred by 98.73% of projects

Based on 24,155 constants in 158 projects

1 project prefers lower

1 project prefers mixed

156 projects prefer upper

Historical
  • 01 Mar 2015: there was a 3.18% swing away from upper
    • Chamilo removed 16556 constants using upper
    • there was a 2.84% swing towards mixed

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 93.14%
preferred by 98.47% of projects
1 1 6.85%
preferred by 1.53% of projects
2 2 < 0.01%
preferred by 0% of projects
3 3 < 0.01%
preferred by 0% of projects

Based on 555,178 control structures in 196 projects

193 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 4.6%
preferred by 0.51% of projects
1 - Most popular method 1 93.72%
preferred by 95.94% of projects
2 2 1.27%
preferred by 0% of projects
Other other 0.41%
undecided 3.55% of projects are undecided

Based on 59,406 files in 197 projects

1 project prefers 0

189 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.59%
preferred by 98.48% of projects
yes yes 4.41%
preferred by 0.51% of projects
undecided 1.02% of projects are undecided

Based on 61,997 files in 197 projects

194 projects prefer no

1 project prefers yes

2 projects are undecided

Historical
  • 01 Mar 2015: there was a 0.9% swing from yes to no
    • Chamilo removed 849 files using yes
  • 01 Apr 2015: there was a 4.3% swing from yes to no
  • 01 Aug 2015: there was a 0.7% swing from yes to no
  • 01 Mar 2016: there was a 0.83% swing from yes to no
    • OpenEMR saw a 9.72% swing from yes to no
  • 01 Aug 2017: there was a 1.51% swing from yes to no

Space after operator

How many spaces follow comparison, arithmetic and assignment operators?

Current
Key Method Use
0 0 2.54%
preferred by 0% of projects
1 - Most popular method 1 96.36%
preferred by 99.49% of projects
Other other 1.1%
undecided 0.51% of projects are undecided

Based on 3,482,842 operators in 196 projects

195 projects prefer 1

1 project is undecided

Historical
  • 01 Mar 2015: there was a 5.52% swing away from 0
    • Chamilo saw a 25.66% swing away from 0
    • Chamilo removed 175837 operators using 0
    • there was a 5.44% swing towards 1
    • Chamilo saw a 25.52% swing towards 1
  • 01 May 2017: there was a 1.31% swing from 0 to 1
    • OpenEMR saw a 13.44% swing away from 0
    • OpenEMR saw a 13.1% swing towards 1
    • OpenEMR removed 45716 operators using 0

Control structure defined inline

Are control structures defined inline (without braces)?

Current
Key Method Use
no - Most popular method no 96.67%
preferred by 98.98% of projects
yes yes 3.33%
preferred by 0% of projects
undecided 1.02% of projects are undecided

Based on 620,685 control structures in 196 projects

194 projects prefer no

0 projects prefer yes

Historical
  • 01 Aug 2015: there was a 2.26% swing from yes to no
  • 01 Aug 2017: there was a 1.03% swing from yes to no

Spacing before object operator

How many spaces precede the object operator (->)?

Current
Key Method Use
0 - Most popular method 0 98.18%
preferred by 100% of projects
1 1 0.16%
preferred by 0% of projects
newline newline 1.66%
preferred by 0% of projects

Based on 1,860,761 object operators in 196 projects

196 projects prefer 0

Historical

Closure opening brace placement

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

Current
Key Method Use
new line new line 1.39%
preferred by 1.48% of projects
same line - Most popular method same line 98.61%
preferred by 97.04% of projects
undecided 1.48% of projects are undecided

Based on 8,702 closures in 135 projects

2 projects prefer new line

131 projects prefer same line

2 projects are undecided

Historical
  • 01 Feb 2015: there was a 1.87% swing from new line to same line
  • 01 Aug 2015: there was a 3.27% swing from new line to same line
  • 01 Feb 2016: there was a 1.91% swing from same line to new line
  • 01 Mar 2016: there was a 2.2% swing from new line to same line

File extension for non-class files

For files that do not contain classes, what extension does the file use?

Current
Key Method Use
.inc .inc 0.8%
preferred by 0% of projects
.module .module 0.42%
preferred by 0% of projects
.php - Most popular method .php 98.78%
preferred by 98.65% of projects
undecided 1.35% of projects are undecided

Based on 14,897 non-class files in 74 projects

1 project is undecided

Historical
  • 01 Nov 2016: there was a 1.07% swing away from .php
    • there was a 0.63% swing towards .inc

Blank lines at start of control structure

How many blank lines precede the body of a control structure?

Current
Key Method Use
0 - Most popular method 0 99.1%
preferred by 100% of projects
1 1 0.9%
preferred by 0% of projects
2 2 0.01%
preferred by 0% of projects
3 3 < 0.01%
preferred by 0% of projects

Based on 618,230 control structures in 196 projects

196 projects prefer 0

Historical

Brackets around echoed strings

Are parenthesis placed around echo'd strings?

Current
Key Method Use
no - Most popular method no 99.14%
preferred by 100% of projects
yes yes 0.86%
preferred by 0% of projects

Based on 66,951 echo statements in 81 projects

81 projects prefer no

Historical

Blank lines at end of control structure

How many blank lines follow the body of a control structure?

Current
Key Method Use
0 - Most popular method 0 99.24%
preferred by 100% of projects
Other other 0.76%

Based on 617,520 control structures in 196 projects

196 projects prefer 0

Historical

EOL char

What character is used for line breaks?

Current
Key Method Use
\n - Most popular method \n 99.77%
preferred by 100% of projects
\r\n \r\n 0.23%
preferred by 0% of projects

Based on 61,997 files in 197 projects

197 projects prefer \n

Historical
  • 01 Mar 2015: there was a 0.56% swing from \r\n to \n
    • Chamilo saw a 4.12% swing from \r\n to \n
    • Chamilo removed 353 files using \r\n
  • 01 Aug 2015: there was a 0.7% swing from \r\n to \n
  • 01 Sep 2015: there was a 0.95% swing towards \n
    • pimcore saw a 91.05% swing towards \n
    • there was a 0.94% swing away from \r\n
    • pimcore saw a 91.05% swing away from \r\n

Multiple statements on same line

Are multiple statements defined on the same line of code?

Current
Key Method Use
no - Most popular method no 99.78%
preferred by 100% of projects
yes yes 0.22%
preferred by 0% of projects

Based on 2,509,209 statements in 197 projects

197 projects prefer no

Historical

Spacing after object operator

How many spaces follow the object operator (->)?

Current
Key Method Use
0 - Most popular method 0 99.81%
preferred by 100% of projects
1 1 0.19%
preferred by 0% of projects
newline newline < 0.01%
preferred by 0% of projects

Based on 1,860,761 object operators in 196 projects

196 projects prefer 0

Historical

Array keyword case

When defining an array, how is the array keyword written?

Current
Key Method Use
lower - Most popular method lower 99.85%
preferred by 100% of projects
mixed mixed 0.15%
preferred by 0% of projects

Based on 249,896 array definitions in 95 projects

95 projects prefer lower

Historical

PHP type case

What case are PHP types (int, bool, string) written in?

Current
Key Method Use
lower - Most popular method lower 99.89%
preferred by 100% of projects
mixed mixed 0.11%
preferred by 0% of projects

Based on 67,637 PHP types in 189 projects

189 projects prefer lower

Historical

PHP keyword case

What case are PHP keywords (function, echo, foreach etc.) written in?

Current
Key Method Use
lower - Most popular method lower 99.92%
preferred by 100% of projects
mixed mixed 0.02%
preferred by 0% of projects
upper upper 0.06%
preferred by 0% of projects

Based on 3,065,526 keywords in 197 projects

197 projects prefer lower

Historical

File extension for class files

For files that contain classes, what extension does the file use?

Current
Key Method Use
.inc .inc < 0.01%
preferred by 0% of projects
.php - Most popular method .php 100%
preferred by 100% of projects

Based on 47,100 class files in 197 projects

197 projects prefer .php

Historical

PHP short open tag used

Is the PHP short open tag syntax used?

Current
Key Method Use
no - Most popular method no 100%
preferred by 100% of projects

Based on 559,637 open tags in 197 projects

197 projects prefer no

Historical